--- projects/cms/source/ihost/ihost.c 2002/05/21 16:04:34 1.22 +++ projects/cms/source/ihost/ihost.c 2002/05/29 23:03:53 1.27 @@ -1,5 +1,6 @@ /* * i-scream central monitoring system + * http://www.i-scream.org.uk * Copyright (C) 2000-2002 i-scream * * This program is free software; you can redistribute it and/or @@ -17,6 +18,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -32,10 +37,7 @@ #include #include -#define VERSION_NO "0.8" #define RECONFIGURE_RETURN_CODE 2 -#define UDP_MAX_PACKET_SIZE 8192 -#define PID_FILE "/var/tmp/.ihost.pid" #define logmessage(level, ...) do { cur_level = level; errf(__VA_ARGS__); } while (0) @@ -138,7 +140,8 @@ int ihost_configure(ihost_state_t *ihost_state){ logmessage(LOG_ERR, "sa family is wrong type"); return -1; } - + + if(ihost_state->my_ip!=NULL) free(ihost_state->my_ip); if((ihost_state->my_ip=strdup(inet_ntoa(((struct sockaddr_in *)&ip)->sin_addr)))==NULL){ logmessage(LOG_ERR, "Failed to get IP (%m)"); return -1; @@ -484,6 +487,7 @@ int main(int argc, char **argv){ ihost_state.last_modified=NULL; ihost_state.files_list=NULL; ihost_state.key=NULL; + ihost_state.my_ip=NULL; errf_set_progname(argv[0]); @@ -509,7 +513,7 @@ int main(int argc, char **argv){ break; case 'V': - errf("%s version %s",argv[0], VERSION_NO); + errf("%s version %s",argv[0], VERSION); break; default: @@ -576,10 +580,10 @@ int main(int argc, char **argv){ logmessage(LOG_DEBUG,"Writing PID FILE"); pid=getpid(); if((f=fopen(PID_FILE,"w")) == NULL){ - logmessage(LOG_WARNING, "Failed to write PID file"); + logmessage(LOG_WARNING, "Failed to write PID file (%m)"); }else{ - if((fprintf(f,"%d",(int)pid)) > 0 ){ - logmessage(LOG_WARNING, "Failed to write PID file"); + if((fprintf(f,"%d",(int)pid)) <= 0 ){ + logmessage(LOG_WARNING, "Failed to write PID file (%m)"); } if((fclose(f))!=0){ logmessage(LOG_ERR, "failed to close PID file");