My pretty neat website
git clone git://soophie.de/soso
diff --git a/src/main.c b/src/main.c
index 2aa0013..cc34490 100644
--- a/src/main.c
+++ b/src/main.c
1
@@ -14,7 +14,7 @@2
#define UTIL_IMPL3
#include "util.h" // IWYU pragma: keep5
-#define PORT 80876
+#define SOSO_PORT "SOSO_PORT"8
#include "module/page.h"9
#include "module/default.h"10
@@ -208,15 +208,26 @@ int main(void) {11
sigint_action.sa_flags = 0;12
sigemptyset(&sigint_action.sa_mask);13
sigaction(SIGSEGV, &sigint_action, NULL);14
+ char *port_str = getenv(SOSO_PORT);15
+ if (!port_str) {16
+ printf("no port specified! set environment variable SOSO_PORT.\n");17
+ return 1;18
+ }19
+ char *end = NULL;20
+ int port = strtoimax(port_str, &end, 10);21
+ if (end == port_str || *end != '\0') {22
+ printf("invalid port specified! set environment variable SOSO_PORT.\n");23
+ return 1;24
+ }25
tpee_t *tpee = tpee_init();26
- if (tpee_bind(tpee, "0.0.0.0", PORT, NULL, 0) != TPEE_ERR_OK) {27
+ if (tpee_bind(tpee, "0.0.0.0", port, NULL, 0) != TPEE_ERR_OK) {28
printf("failed to bind port!\n");29
return 1;30
}31
git_libgit2_init();32
git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 0);33
if (tpee_listen(tpee) == TPEE_ERR_OK) {34
- printf("ready and listening (pid: %d)\n", getpid());35
+ printf("ready and listening (pid: %d, port: %d)\n", getpid(), port);36
pause();37
}38
git_libgit2_shutdown();