summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-09-25 21:38:58 -0500
committericeyrazor <iceyrazor@mailfence.com>2026-09-25 21:38:58 -0500
commitb6436e0ef6029c6cf002bc5fea599f64253cb206 (patch)
tree284bb5195c586e0bfb1520273f3486a9c8a81f8c /src
init
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100755
index 0000000..47619e5
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,41 @@
+#include <launch-web.c>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+// dont use stdio in these
+sig_atomic_t running = 1;
+void sig_int_handler(int num)
+{
+ running = 0;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc<2){
+ fprintf(stderr, "arg1 must be set for port\n");
+ exit(-1);
+ }
+ int port = atoi(argv[1]);
+ if (port == 0) {
+ fprintf(stderr, "port must not be 0\n");
+ exit(-1);
+ }
+
+ struct Server server = server_constructor(AF_INET, SOCK_STREAM, 0, INADDR_ANY, port, 10, launch);
+ server.html_folder = "./public_html/";
+
+ struct sigaction act = { 0 };
+ act.sa_handler = &sig_int_handler;
+ sigaction(SIGINT, &act, NULL);
+
+ server.launch(&server);
+
+ while (running) { }
+
+ usleep(1);
+ server_close(&server);
+
+ return 0;
+} \ No newline at end of file