💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Upload › files › 827c3884f97c00fe0f3fd03d63a… captured on 2023-11-04 at 12:27:25. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
0 /* See LICENSE for license details. */
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <time.h>
4 #include <sys/stat.h>
5 #include "server.h"
6 #include "sandbox.h"
7
8 int main(int argc, char* argv[]) {
9 struct stat sb;
10 int port;
11
12 if (argc < 3) {
13 invalid_args:
14 printf("%s <download directory> <port>\n", argv[0]);
15 return -1;
16 }
17
18 port = atoi(argv[2]);
19 if (!port) port = 8080;
20
21 if (stat(argv[1], &sb) || !S_ISDIR(sb.st_mode)) {
22 goto invalid_args;
23 }
24
25 srand(time(NULL));
26
27 sandbox_start(argv[1]);
28 if (server_init(port)) {
29 printf("Failed to initialize the server\n");
30 return -1;
31 }
32 server_thread();
33 server_stop();
34
35 return 0;
36 }
37