/************************************************************************** Main function, called from dproxy.c */ int conf_load (char *conf_file) { FILE *fp; char line[256], *cmd = NULL, *arg1 = NULL; conf_defaults(); /* load default settings first */ fp = fopen (conf_file, "r"); if (!fp) { /* specified file does not exist... try default file */ fp = fopen (config.config_file, "r"); if (!fp) { /* there is no config file.... use defaults */ perror("no config file"); return 0; } } else { strcpy(config.config_file, conf_file); } while (fgets(line, 256, fp)) { if (!(line[0]=='#')) { /* skip lines with comment */ line[strlen(line) - 1] = 0; /* kill '\n' */ cmd = strtok( line, " =" ); arg1 = strtok( NULL, " ="); conf_cmdparse(cmd, arg1); } } fclose(fp); return 0; }
/***************************************************************************** * get commandline options. * * @return 0 on success, < 0 on error. *****************************************************************************/ int get_options( int argc, char ** argv ) { char c = 0; int not_daemon = 0, cc; int want_printout = 0; char * progname = argv[0]; conf_defaults(); while( (cc = getopt( argc, argv, "c:dhP")) != EOF ) { c = (char)cc; //added by CMC 8/3/2001 switch(c) { case 'c': conf_load(optarg); break; case 'd': not_daemon = 1; break; case 'h': usage(progname,""); return -1; case 'P': want_printout = 1; break; default: usage(progname,""); return -1; } } /** unset daemon-mode if -d was given. */ if( not_daemon ) { config.daemon_mode = 0; } if( want_printout ) { conf_print(); exit(0); } return 0; }