optionfile parsing active

This commit is contained in:
john stone 2013-11-07 06:44:08 +01:00
parent d4849849a8
commit e3f5b5284e
1 changed files with 63 additions and 3 deletions

View File

@ -1,8 +1,68 @@
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include "options.h"
int main(int argc, char *argv[])
static struct sic_conf args_info;
using std::cout;
int main(int argc, char **argv)
{
std::cout << "Test for compilesetup purpose \n";
return 0;
int result = 0;
struct cmd_parser_params *params;
/* initialize the parameters structure */
params = cmd_parser_params_create();
/* call the command line parser */
if (cmd_parser(argc, argv, &args_info) != 0) {
result = 1;
goto stop;
}
/*
override command line options,
but do not initialize args_info, check for required options.
NOTICE: we must NOT skip the 0 assignment to initialize,
since its default value is 1 and override defaults to 0
while check_required is already set to its default value, 1
*/
params->initialize = 1;
params->override = 0;
/* call the config file parser */
if (cmd_parser_config_file
(args_info.conffile_arg, &args_info, params) != 0) {
result = 1;
goto stop;
}
//debugcode:
cout << "value of port: " << args_info.port_arg << std::endl;
cout << "value of daemonize: " << static_cast<bool>(args_info.daemonize_flag) << std::endl;
cout << "value of listen_given: "<< args_info.listen_given << std::endl ;
for (unsigned int i = 0; i < args_info.listen_given; i++)
cout << "value of listen: " << args_info.listen_arg[i] <<std::endl;
if (args_info.saveconf_given) {
if (cmd_parser_file_save
(args_info.conffile_arg, &args_info) == EXIT_FAILURE)
result = 1;
else
cout << "saved configuration file "<<
args_info.conffile_arg <<
", \n" << std::endl;
}
stop:
/* deallocate structures */
cmd_parser_free(&args_info);
free(params);
return result;
}