Added basics for config file and fixed makefile
This commit is contained in:
13
src/server.c
13
src/server.c
@ -12,6 +12,7 @@
|
||||
#include <conn.h>
|
||||
#include <util.h>
|
||||
#include <serverWorker.h>
|
||||
#include <ini.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -55,7 +56,7 @@ static void *sigHandler(void *arg) {
|
||||
|
||||
static void usage(const char *argv0) {
|
||||
// TODO change this
|
||||
fprintf(stderr, "use: %s threads-in-the-pool\n", argv0);
|
||||
fprintf(stderr, "use: %s config file location\n", argv0);
|
||||
}
|
||||
|
||||
static void checkargs(int argc, char* argv[]) {
|
||||
@ -64,17 +65,21 @@ static void checkargs(int argc, char* argv[]) {
|
||||
usage(argv[0]);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((int) strtol(argv[1], NULL, 10) <= 0) {
|
||||
fprintf(stderr, "ERROR: threads-in-the-pool must be greater than zero\n\n");
|
||||
ini_t *config = ini_load(argv[1]);
|
||||
if ( config == NULL) {
|
||||
fprintf(stderr, "ERROR: unable to read config file\n");
|
||||
usage(argv[0]);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
ini_free(config);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// TODO read config file
|
||||
checkargs(argc, argv);
|
||||
int threadsInPool = (int) strtol(argv[1], NULL, 10);
|
||||
ini_t *config = ini_load(argv[1]);
|
||||
int threadsInPool = (int) strtol(ini_get(config, "threadpool", "quantity"), null, 10);
|
||||
ini_free(config);
|
||||
|
||||
sigset_t mask;
|
||||
sigemptyset(&mask);
|
||||
|
||||
Reference in New Issue
Block a user