--- projects/cms/source/ihost/ihost.c 2003/09/26 21:22:44 1.42 +++ projects/cms/source/ihost/ihost.c 2004/01/07 11:37:10 1.48 @@ -170,24 +170,6 @@ void log_msg(int level, char *format, ...){ } } -/* Takes many pointers, checks if they are NULL or not, and then free's them */ -/* Deprciated - and i only wrote it today! :) -void m_free(int num_pointers, ...){ - int x=0; - va_list ap; - void *p; - - va_start(ap, num_pointers); - for(;x.\n", PACKAGE_BUGREPORT); exit(1); } @@ -746,7 +731,8 @@ int main(int argc, char **argv){ ihost_config.log=stderr; /* Blank ihost_state to default settings */ - ihost_state.filtermanager_host=NULL; + ihost_state.filtermanager_host=DEF_SERVER_NAME; + ihost_state.filtermanager_port=DEF_SERVER_PORT; ihost_state.host_fqdn=NULL; ihost_state.host_ip=NULL; ihost_state.preset_fqdn = 0; @@ -755,7 +741,7 @@ int main(int argc, char **argv){ ihost_state.file_list=NULL; ihost_state.last_modified=NULL; - while((cmdopt=getopt(argc, argv, "vfhVs:i:")) != -1){ + while((cmdopt=getopt(argc, argv, "vfVn:i:s:p:h")) != -1){ switch(cmdopt){ case 'v': ihost_config.verbose++; @@ -766,14 +752,10 @@ int main(int argc, char **argv){ ihost_config.daemon=0; break; - case 'h': - usage(argv[0]); - break; - case 'V': fprintf(stderr, "%s version %s\n", argv[0], VERSION); break; - case 's': + case 'n': ihost_state.preset_fqdn = 1; ihost_state.host_fqdn = strdup(optarg); if(ihost_state.host_fqdn == NULL){ @@ -791,20 +773,21 @@ int main(int argc, char **argv){ } break; + case 's': + ihost_state.filtermanager_host=strdup(optarg); + break; + + case 'p': + ihost_state.filtermanager_port=atoi(optarg); + break; + + case 'h': default: usage(argv[0]); exit(1); } } - if(argc!=optind+2){ - usage(argv[0]); - exit(1); - } - - ihost_state.filtermanager_host=strdup(argv[optind]); - ihost_state.filtermanager_port=atoi(argv[optind+1]); - if(gethostbyname(ihost_state.filtermanager_host)==NULL){ log_msg(LOG_CRIT, "Failed to lookup hostname. Please check settings"); exit(1); @@ -841,7 +824,13 @@ int main(int argc, char **argv){ } - log_msg(LOG_INFO, "Starting ihost"); + log_msg(LOG_INFO, "Starting ihost..."); + + log_msg(LOG_DEBUG, "Running statgrab_init()"); + if(statgrab_init()){ + log_msg(LOG_CRIT, "statgrab_init failed (%m)"); + exit(1); + } log_msg(LOG_DEBUG,"Writing PID FILE"); @@ -869,7 +858,6 @@ int main(int argc, char **argv){ sleep(10); } - printf("%s\n%d\n", ihost_state.server_fqdn, ihost_state.server_udp_port); while((create_udp_sockinfo(&udp_sockinfo, ihost_state.server_fqdn, ihost_state.server_udp_port))!=0){ log_msg(LOG_ERR, "Failed to create udp socket"); sleep(10);