cpfsyslog/src/main.c

38 lines
834 B
C
Raw Normal View History

2018-05-09 20:42:19 -07:00
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
2018-07-19 21:09:51 -07:00
#include "config.h"
2018-07-14 19:23:50 -07:00
#include "server.h"
2018-07-19 21:09:51 -07:00
#include "helpers.h"
2018-05-09 20:42:19 -07:00
int main(int argc, char** argv) {
if (argc != 2) {
2018-07-19 21:09:51 -07:00
fprintf(stderr, "usage: %s <config.json>\n", argv[0]);
2018-05-09 20:42:19 -07:00
exit(1);
}
/*Parse port number to integer*/
2018-07-19 21:09:51 -07:00
/*char* portend;
2018-05-10 22:40:00 -07:00
unsigned int portl;
portl = strtol(argv[1], &portend, 10);
2018-07-15 17:41:13 -07:00
if (portend == NULL || portend == argv[1]) {
2018-07-14 19:23:50 -07:00
fprintf(stderr, "usage: %s <port>\n", argv[0]);
exit(1);
}
2018-05-09 20:42:19 -07:00
assert(portl < USHRT_MAX);
2018-07-19 21:09:51 -07:00
unsigned short port = (unsigned short)portl;*/
struct config* conf = config_load(argv[1]);
printf("url: %s\n", conf->url);
printf("port: %d\n", conf->port);
run_server(conf->port, conf->url);
config_free(conf);
2018-05-09 20:42:19 -07:00
exit(EXIT_SUCCESS);
}