|
|
|
@ -29,22 +29,19 @@ void printHelp(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(int argc, char**argv){ |
|
|
|
|
char *database = DEFAULT_DATABASE; |
|
|
|
|
char *config = DEFAULT_CONFIG; |
|
|
|
|
unsigned int port = DEFAULT_PORT; |
|
|
|
|
|
|
|
|
|
Config *defaultconfig = configDefaults(); |
|
|
|
|
Config *config = configDefaults(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( unsigned int i = 1; i < argc; i++ ){ |
|
|
|
|
if ( strcmp( argv[i], "--config" ) == 0 ){ |
|
|
|
|
if ( i + 2 < argc ){ |
|
|
|
|
setConfig( defaultconfig, argv[i + 1], argv[i + 2] ); |
|
|
|
|
setConfig( config, argv[i + 1], argv[i + 2] ); |
|
|
|
|
i += 2; |
|
|
|
|
} else { |
|
|
|
|
printf("--config requires 2 positional arguments\n"); |
|
|
|
|
} |
|
|
|
|
} else if ( strcmp( argv[i], "--print-config" ) == 0 ){ |
|
|
|
|
printConfig(defaultconfig); |
|
|
|
|
printConfig(config); |
|
|
|
|
return 0; |
|
|
|
|
} else if ( strcmp( argv[i], "--help" ) == 0 ){ |
|
|
|
|
printHelp(); |
|
|
|
@ -54,12 +51,20 @@ int main(int argc, char**argv){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( !db_file_exists(database) ){ |
|
|
|
|
if (path_exists( config->userConfig ) ){ |
|
|
|
|
printf("User config file exists but still needs to be parsed\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (path_exists( config->localConfig ) ){ |
|
|
|
|
printf("Local config file exists but still needs to be parsed\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( !db_file_exists(config->database) ){ |
|
|
|
|
printf("Creating DB"); |
|
|
|
|
db_create(database); |
|
|
|
|
db_create(config->database); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
proxy_startListener(port); |
|
|
|
|
proxy_startListener(config->port); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|