From f96dfd22403a935dc5eec18cb094a22565250ace Mon Sep 17 00:00:00 2001 From: verdant Date: Tue, 9 Jun 2026 20:20:11 +0800 Subject: Add version and copyright information When run in flag "-v" or "--version", print version and copyright information. --- server.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'server.c') diff --git a/server.c b/server.c index 109e4a4..0c8fa56 100644 --- a/server.c +++ b/server.c @@ -12,6 +12,11 @@ #include #include +#define PROGRAM_NAME "shsd" +#define VERSION "0.0.1" +#define COPYRIGHT_YEAR "2026" +#define AUTHOR "Verdant " + typedef enum { GET = 0, POST = 1, UNKNOWN = -1 } HTTP_METHODS; static void usage(const char *progname) @@ -20,6 +25,15 @@ static void usage(const char *progname) exit(EXIT_FAILURE); } +static void version() +{ + printf("%s %s\n", PROGRAM_NAME, VERSION); + printf("Copyright (C) %s %s\n", COPYRIGHT_YEAR, AUTHOR); + printf("License GPLv3+: GNU GPL version 3 or later .\n"); + printf("This is free software: you are free to change and redistribute it.\n"); + printf("There is NO WARRANTY, to the extent permitted by law.\n"); +} + static int shsd_sendfile(int in_fd, FILE *ou_fd) { struct stat s; @@ -99,7 +113,13 @@ int main(int argc, char **argv) { if (argc < 2) { usage(argv[0]); + exit(1); + } else if (strcmp(argv[1], "-v") == 0 || + strcmp(argv[1], "--version") == 0) { + version(); + exit(0); } + struct addrinfo hints, *res; struct sockaddr_storage their_addr; socklen_t addr_size; -- cgit v1.2.3