aboutsummaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorverdant <im@verdant.ee>2026-06-09 20:20:11 +0800
committerverdant <im@verdant.ee>2026-06-09 20:20:11 +0800
commitf96dfd22403a935dc5eec18cb094a22565250ace (patch)
treef2204008b4f960123847e4e2fbbfd7484183b1cb /server.c
parent5b0c5b88351d8f4e5e087e194735ae2431c179fe (diff)
downloadshsd-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.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/server.c b/server.c
index 109e4a4..0c8fa56 100644
--- a/server.c
+++ b/server.c
@@ -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;