diff --git a/src/rhosts.c b/src/rhosts.c index 6b30520..94259ad 100644 --- a/src/rhosts.c +++ b/src/rhosts.c @@ -23,13 +23,19 @@ #include "rhosts.h" #endif + + + int main(int argc, char *argv[]){ struct entry *entries; + struct config config; + config.loglevel = CLOGS_WARNING; int rc =0; - - + if (argc >1){ + consume_args(&config, argc, argv); + } clogs_init_config(CLOGS_TIMESTAMP | CLOGS_USELOGFILE, \ - "/var/log/rhosts.log", CLOGS_DEBUG); + "/var/log/rhosts.log", config.loglevel); clogs_print(CLOGS_DEBUG,"Initialized settting up logs"); rc = parse_config(&entries); @@ -247,3 +253,11 @@ int copy_tmp_to_hosts(){ remove(TMPLOCATION); return 0; } +int consume_args(struct config *config, int argc, char **argv){ + int i=0; + for (i=1;i < argc;i++){ + if (strcmp(argv[i], "-d") == 0) + config->loglevel = CLOGS_DEBUG; + } + return 0; +} diff --git a/src/rhosts.h b/src/rhosts.h index c930aa0..e3f893a 100644 --- a/src/rhosts.h +++ b/src/rhosts.h @@ -56,6 +56,9 @@ struct entry{ int entrytype; char entry[MAXSTRSIZE]; }; +struct config{ + uint8_t loglevel; +}; int parse_config(struct entry **entries); @@ -65,6 +68,7 @@ short int determine_config_entry_value(char *buff); int preserve_static_entries(); int add_site_entries(struct entry **entries); int copy_tmp_to_hosts(); +int consume_args(struct config *config, int argc, char **argv); #endif #ifndef DOWNLOAD_HEADER #include "download.h"