aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;