|
|
@ -29,22 +29,19 @@ void printHelp(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char**argv){ |
|
|
|
int main(int argc, char**argv){ |
|
|
|
char *database = DEFAULT_DATABASE; |
|
|
|
Config *config = configDefaults(); |
|
|
|
char *config = DEFAULT_CONFIG; |
|
|
|
|
|
|
|
unsigned int port = DEFAULT_PORT; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Config *defaultconfig = configDefaults(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( unsigned int i = 1; i < argc; i++ ){ |
|
|
|
for ( unsigned int i = 1; i < argc; i++ ){ |
|
|
|
if ( strcmp( argv[i], "--config" ) == 0 ){ |
|
|
|
if ( strcmp( argv[i], "--config" ) == 0 ){ |
|
|
|
if ( i + 2 < argc ){ |
|
|
|
if ( i + 2 < argc ){ |
|
|
|
setConfig( defaultconfig, argv[i + 1], argv[i + 2] ); |
|
|
|
setConfig( config, argv[i + 1], argv[i + 2] ); |
|
|
|
|
|
|
|
i += 2; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
printf("--config requires 2 positional arguments\n"); |
|
|
|
printf("--config requires 2 positional arguments\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ( strcmp( argv[i], "--print-config" ) == 0 ){ |
|
|
|
} else if ( strcmp( argv[i], "--print-config" ) == 0 ){ |
|
|
|
printConfig(defaultconfig); |
|
|
|
printConfig(config); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} else if ( strcmp( argv[i], "--help" ) == 0 ){ |
|
|
|
} else if ( strcmp( argv[i], "--help" ) == 0 ){ |
|
|
|
printHelp(); |
|
|
|
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"); |
|
|
|
printf("Creating DB"); |
|
|
|
db_create(database); |
|
|
|
db_create(config->database); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
proxy_startListener(port); |
|
|
|
proxy_startListener(config->port); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|