diff options
| author | verdant <im@verdant.ee> | 2026-06-09 20:20:11 +0800 |
|---|---|---|
| committer | verdant <im@verdant.ee> | 2026-06-09 20:20:11 +0800 |
| commit | f96dfd22403a935dc5eec18cb094a22565250ace (patch) | |
| tree | f2204008b4f960123847e4e2fbbfd7484183b1cb /server.c | |
| parent | 5b0c5b88351d8f4e5e087e194735ae2431c179fe (diff) | |
| download | shsd-f96dfd22403a935dc5eec18cb094a22565250ace.tar.gz shsd-f96dfd22403a935dc5eec18cb094a22565250ace.zip | |
Add version and copyright information
When run in flag "-v" or "--version", print version and copyright
information.
Diffstat (limited to 'server.c')
| -rw-r--r-- | server.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -12,6 +12,11 @@ #include <sys/sendfile.h> #include <unistd.h> +#define PROGRAM_NAME "shsd" +#define VERSION "0.0.1" +#define COPYRIGHT_YEAR "2026" +#define AUTHOR "Verdant <im@verdant.ee>" + 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 <https://www.gnu.org/licenses/gpl-3.0.html>.\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; |
