-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
25 lines (19 loc) · 697 Bytes
/
main.c
File metadata and controls
25 lines (19 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
#include <stdlib.h>
#include "arguments.h"
#include "epoll.h"
#include "handlers.h"
#include "log.h"
#include "socket.h"
int main(int argc, const char* argv[]) {
setbuf(stdout, NULL);
srand(42); // TODO(torilov): initialize as command line argument.
struct arguments arguments = parse_arguments(argc, argv);
kSaveFilesDirname = arguments.dirname;
struct epoll* epoll = make_epoll();
int listener_socket_fd = make_listener_socket(arguments.port);
add_listener_fd(epoll, listener_socket_fd);
LOG_INFO("serving on port %d with folder %s", arguments.port,
arguments.dirname);
serve_connections(epoll); // TODO(torilov): add graceful shutdown.
}