# # old_revision [8ceea9d20d313dbf6715b4f1e34ad2c517811786] # # patch "peep-0.5.0-rc2/server/Makefile.in" # from [ef4bccc99a35e0974eff71a7c1fa545fcf3aee45] # to [e26423ae2636eefc1dd8507fb6fc662fee0217ba] # # patch "peep-0.5.0-rc2/server/cmdline.c" # from [9a76bcfe4baaf11a9994d462f1bdbbcf9c9d53b8] # to [d464590f8c8981ac93769bda0db0ace9c0c04f85] # # patch "peep-0.5.0-rc2/server/cmdline.h" # from [83e62a8db5117b75f333450ef240ca94239e4aff] # to [80677cbd08b164cd949eac4306ef14625393c6ad] # # patch "peep-0.5.0-rc2/server/debug.c" # from [d57e2db5bfa388a43a2e2ca2a54a0b7df9bb6fff] # to [1df39546ba7eb7e845006b490e24e862fd215ee5] # # patch "peep-0.5.0-rc2/server/debug.h" # from [94fa9d4f58d4cf8337be4110a0bc576d298dbe16] # to [caa26a381625a860730579c6a5b627b49019e6b8] # # patch "peep-0.5.0-rc2/server/engine.c" # from [193790ce9a81312816cf826228de8c71dcafb6ae] # to [4e68651c2c01ae59178edf958b2b7d515ff794f6] # # patch "peep-0.5.0-rc2/server/engine.h" # from [9f8ee670d0a42f1d3ef68d7933e4caf5dc46673a] # to [d77e4bc5126fb0cfbe3b7583b7157a9fad8497ce] # # patch "peep-0.5.0-rc2/server/main.c" # from [a8e02bd355754afd429afce4583f8e961e299b0a] # to [c9d4949cdc532b1603fa74ce3342acb78bfefcbc] # # patch "peep-0.5.0-rc2/server/mixer.c" # from [870da1d2b1f4406cc589e75ea73648bff2082118] # to [0ca59b016bdabe47e75e7d137b69ae581daf8677] # # patch "peep-0.5.0-rc2/server/mixer_queue.h" # from [6ada4f50ad42c9e7e130b3e284a4f86cd25599ef] # to [6cc9e810bc4566051ea3bb22e9f66986534e0bcd] # # patch "peep-0.5.0-rc2/server/notice.h" # from [c84ed89358a55820ea8cdc37321d714db97bc00f] # to [3b9185fd4f0be98ea471f1fc0eb165ee9ae2966a] # # patch "peep-0.5.0-rc2/server/oss.c" # from [2146b5001dc1a3c421bdb6b58fc4acb7e7dd579d] # to [40bed24c269e565f43ae01da37dd548e335c450a] # # patch "peep-0.5.0-rc2/server/parser.c" # from [a3f4500d0510caad77302efd8707e24195b66999] # to [5cc04c1c0328fa4b9394bfdcaba44ba557a8f91e] # # patch "peep-0.5.0-rc2/server/playback.c" # from [0802724e0ec65bda11e47ee79609dae98b0fd9e0] # to [55568af8631ad87771b7d52fb1241beebfbd5c74] # # patch "peep-0.5.0-rc2/server/playback.h" # from [cdfabe13acd90648727b3f281d7602e791b5495b] # to [4d2476746b9b6cf779e0be9b5c6396472dc45bd1] # # patch "peep-0.5.0-rc2/server/server.c" # from [1d96b0cd10d029fb8c68314b6df708a9afeb7f05] # to [0ad85b76c3ad892ff3a327aaef0ed31a1b2ab5e0] # # patch "peep-0.5.0-rc2/server/tcp_server.c" # from [a4916ecd2057631fe4389198beadcea214d7ab10] # to [7e45f2e8bd84001cfdbe46e9bcc5ab84aab80264] # # patch "peep-0.5.0-rc2/server/thread.c" # from [6cc1374c68dcf663d61e6b1e5df63dd5f058f4b1] # to [8218e36b252f2d5d10735e7a9e5939f7754f9b06] # # patch "peep-0.5.0-rc2/server/xml.c" # from [ace9983c85c153059eae1fa54de65bf1947628ca] # to [bef779f803e99a292c21d051c6939961acd68cab] # # patch "peep-0.5.0-rc2/server/xml_notice.c" # from [7b6c498cac0b38521cef3e5318e6d0dc242ab9b9] # to [4587ca60765b5c4e3a9da152342e6796b6c0aa8e] # # patch "peep-0.5.0-rc2/server/xml_notice.h" # from [94cac47df0b71ccbbb256771b396f5a7a6f84f09] # to [6c2ee83d1b0c35333bfe789d89d9b4cf85977372] # # patch "peep-0.5.0-rc2/server/xml_theme.c" # from [46b990789e7fe975d434c70b89cc7e7e96763a70] # to [7b1463512afddc8f6f3c1f5693070b087c25e453] # ============================================================ --- peep-0.5.0-rc2/server/Makefile.in ef4bccc99a35e0974eff71a7c1fa545fcf3aee45 +++ peep-0.5.0-rc2/server/Makefile.in e26423ae2636eefc1dd8507fb6fc662fee0217ba @@ -157,7 +157,7 @@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $( $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ -Wall -Werror DIST_SOURCES = $(peepd_SOURCES) DIST_COMMON = Makefile.am Makefile.in SOURCES = $(peepd_SOURCES) ============================================================ --- peep-0.5.0-rc2/server/cmdline.c 9a76bcfe4baaf11a9994d462f1bdbbcf9c9d53b8 +++ peep-0.5.0-rc2/server/cmdline.c d464590f8c8981ac93769bda0db0ace9c0c04f85 @@ -316,7 +316,7 @@ void printHelp (void) { printVersion (); - printf (" + printf ("\ Usage: %s [OPTIONS]...\n\ -h --help Print help and exit\n\ -V --version Print version and exit\n\ ============================================================ --- peep-0.5.0-rc2/server/cmdline.h 83e62a8db5117b75f333450ef240ca94239e4aff +++ peep-0.5.0-rc2/server/cmdline.h 80677cbd08b164cd949eac4306ef14625393c6ad @@ -71,8 +71,9 @@ struct args_info { #define GET_INT_ARG(x, y) \ { if (argv[1][2] != '\0') \ - if (!sscanf ((char *)&(argv[1][2]), "%d", &x)) \ + { if (!sscanf ((char *)&(argv[1][2]), "%d", &x)) \ optError (y); \ + } \ else { \ argc--; argv++; \ if (!sscanf (argv[1], "%d", &x)) \ ============================================================ --- peep-0.5.0-rc2/server/debug.c d57e2db5bfa388a43a2e2ca2a54a0b7df9bb6fff +++ peep-0.5.0-rc2/server/debug.c 1df39546ba7eb7e845006b490e24e862fd215ee5 @@ -43,7 +43,7 @@ int assert (int boolean, char *boolstr, { if (!boolean) - log (DBG_ASSRT, "Assertion %s failed in line %d of file %s\n", boolstr, line, file); + mylog (DBG_ASSRT, "Assertion %s failed in line %d of file %s\n", boolstr, line, file); /* else log(DBG_ASSRT, "Assertion %s succeeded in line %d of file %s\n", * boolstr,line,file); */ @@ -78,7 +78,7 @@ int logInit (char *log_file) } -int logClose (void) +void logClose (void) { if (fclose (log_handle) != 0) @@ -86,7 +86,7 @@ int logClose (void) } -void log (int level, char *s, ...) +void mylog (int level, char *s, ...) { va_list ap; @@ -114,7 +114,7 @@ void log (int level, char *s, ...) sprintf (log_string, "[%s] %s", time_string, output); /* Output and flush the stream so we don't hang onto logging info */ - fprintf (log_handle, log_string); + fprintf (log_handle, "%s", log_string); fflush (log_handle); free (log_string); ============================================================ --- peep-0.5.0-rc2/server/debug.h 94fa9d4f58d4cf8337be4110a0bc576d298dbe16 +++ peep-0.5.0-rc2/server/debug.h caa26a381625a860730579c6a5b627b49019e6b8 @@ -56,15 +56,17 @@ int logInit (char *log_file); int logInit (char *log_file); /* Close the logfile and clean up */ -int logClose (void); +void logClose (void); #define LOG_BUF 1024 /* Include stdio so we don't have problems with using * a FILE * type */ #include +#include +#include /* Variable argument logging function */ -void log (int level, char *s, ...); +void mylog (int level, char *s, ...); #endif ============================================================ --- peep-0.5.0-rc2/server/engine.c 193790ce9a81312816cf826228de8c71dcafb6ae +++ peep-0.5.0-rc2/server/engine.c 4e68651c2c01ae59178edf958b2b7d515ff794f6 @@ -21,6 +21,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include #include "engine.h" #include "engine_queue.h" +#include "mixer_queue.h" #include "thread.h" #include "mixer.h" #include "playback.h" @@ -138,11 +139,9 @@ void *engineSoundTableRetrieve (char *na int index = engineSoundHash (name); struct sound_entry *p = NULL; - for (p = sound_table[index]; p; p ->next) { - + for (p = sound_table[index]; p; p=p->next) { if (!strcasecmp (p->name, name)) return p; - } return NULL; @@ -398,7 +397,7 @@ void engineIO (EVENT *incoming_event) if (! playbackRecordEvent (*engine_event)) { - log (DBG_GEN, "WARNING: Error recording an event. Event not recorded.\n"); + mylog (DBG_GEN, "WARNING: Error recording an event. Event not recorded.\n"); /* continue anyway */ } @@ -615,8 +614,6 @@ void engineShutdown (void) void engineShutdown (void) { - int i, j; - /* Free the engine scheduler data structure */ cfree (sched); ============================================================ --- peep-0.5.0-rc2/server/engine.h 9f8ee670d0a42f1d3ef68d7933e4caf5dc46673a +++ peep-0.5.0-rc2/server/engine.h d77e4bc5126fb0cfbe3b7583b7157a9fad8497ce @@ -104,7 +104,7 @@ struct sound_entry { }; /* Allocate and create the sound table data structure */ -int engineSoundTableInit (void); +int engineInitSoundTable (void); /* Inserts an event entry into the sound table */ int engineSoundTableInsertEvent (char *name, EVENT_ENTRY *event); ============================================================ --- peep-0.5.0-rc2/server/main.c a8e02bd355754afd429afce4583f8e961e299b0a +++ peep-0.5.0-rc2/server/main.c c9d4949cdc532b1603fa74ce3342acb78bfefcbc @@ -30,6 +30,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include "mixer.h" #include "playback.h" #include "debug.h" +#include "parser.h" static struct args_info args_info; static FILE *pid_file = NULL; @@ -77,14 +78,14 @@ int main (int argc, char *argv[]) if ((pid_file = fopen (pid_path, "w")) == NULL) { - log (DBG_DEF, "Couldn't write pid to file %s: %s.\n", pid_path, strerror (errno)); - log (DBG_DEF, "Continuing anyway...\n"); + mylog (DBG_DEF, "Couldn't write pid to file %s: %s.\n", pid_path, strerror (errno)); + mylog (DBG_DEF, "Continuing anyway...\n"); } else { /* Write our pid out to the file */ - fprintf (pid_file, "%d\n", pid_file); + fprintf (pid_file, "%d\n", pid); fflush (pid_file); fclose (pid_file); @@ -102,27 +103,27 @@ int main (int argc, char *argv[]) switch (DEBUG_LEVEL) { case DBG_LOWER: - log (DBG_GEN, "%s %s\n", str, "LOWER"); + mylog (DBG_GEN, "%s %s\n", str, "LOWER"); break; case DBG_MEDIUM: - log (DBG_GEN, "%s %s\n", str, "MEDIUM"); + mylog (DBG_GEN, "%s %s\n", str, "MEDIUM"); break; case DBG_HIGHER: - log (DBG_GEN, "%s %s\n", str, "HIGHER"); + mylog (DBG_GEN, "%s %s\n", str, "HIGHER"); break; case DBG_HIGHEST: - log (DBG_GEN, "%s %s\n", str, "HIGHEST"); + mylog (DBG_GEN, "%s %s\n", str, "HIGHEST"); break; case DBG_ALL_W_ASSERT: - log (DBG_GEN, "%s %s\n", str, "HIGHEST WITH ASSERTIONS!"); + mylog (DBG_GEN, "%s %s\n", str, "HIGHEST WITH ASSERTIONS!"); break; default: - log (DBG_GEN, "%s %s\n", str, "UNKNOWN. WEIRD."); + mylog (DBG_GEN, "%s %s\n", str, "UNKNOWN. WEIRD."); break; } @@ -132,14 +133,14 @@ int main (int argc, char *argv[]) if (!args_info.voices_given) args_info.voices_arg = DEFAULT_MIXER_VOICES; - log (DBG_DEF, "Mixing voices: %d\n", args_info.voices_arg); - log (DBG_DEF, "Initializing the sound engine and mixer...\n"); + mylog (DBG_DEF, "Mixing voices: %d\n", args_info.voices_arg); + mylog (DBG_DEF, "Initializing the sound engine and mixer...\n"); #ifdef STATIC_VOLUME - log (DBG_DEF, "Using static volume mixing...\n"); + mylog (DBG_DEF, "Using static volume mixing...\n"); #endif #ifdef DYNAMIC_VOLUME - log (DBG_DEF, "Using dynamic volume mixing...\n"); + mylog (DBG_DEF, "Using dynamic volume mixing...\n"); #endif /* Perform some error checking to set arguments correctly */ @@ -160,7 +161,7 @@ int main (int argc, char *argv[]) } - log (DBG_DEF, "Parsing configuration...\n"); + mylog (DBG_DEF, "Parsing configuration...\n"); if (!args_info.config_given) args_info.config_arg = DEFAULT_CONFIG_PATH; @@ -179,20 +180,20 @@ int main (int argc, char *argv[]) if (parsed < 0) { - log (DBG_GEN, "Error parsing peep configuration file...\n"); + mylog (DBG_GEN, "Error parsing peep configuration file...\n"); shutDown (); } } - log (DBG_DEF, "Finished configuration...\n"); + mylog (DBG_DEF, "Finished configuration...\n"); - log (DBG_DEF, "Starting mixer thread...\n"); + mylog (DBG_DEF, "Starting mixer thread...\n"); startThread (doMixing, 0, &mthread); - log (DBG_DEF, "Starting engine thread...\n"); + mylog (DBG_DEF, "Starting engine thread...\n"); startThread (engineLoop, 0, ðread); @@ -216,11 +217,11 @@ int main (int argc, char *argv[]) if (!args_info.record_file_given) args_info.record_file_arg = DEFAULT_RECORD_FILE; - log (DBG_DEF, "Initializing playback file...\n"); + mylog (DBG_DEF, "Initializing playback file...\n"); if (!playbackFileInit (args_info.record_file_arg)) { - log (DBG_DEF, "Uh Oh! Couldn't successfully initiliaze playback file! Giving up.\n"); + mylog (DBG_DEF, "Uh Oh! Couldn't successfully initiliaze playback file! Giving up.\n"); shutDown (); } @@ -232,7 +233,7 @@ int main (int argc, char *argv[]) */ if (playbackModeOn (NULL) && playbackSetMode (NULL) == PLAY_MODE) { - log (DBG_DEF, "Entering playback mode...\n"); + mylog (DBG_DEF, "Entering playback mode...\n"); if (!args_info.start_time_given) args_info.start_time_arg = NULL; @@ -245,12 +246,12 @@ int main (int argc, char *argv[]) } else { - log (DBG_DEF, "Initializing server...\n"); + mylog (DBG_DEF, "Initializing server...\n"); setSigHandlers (); if (playbackModeOn (NULL) && playbackSetMode (NULL) == RECORD_MODE) - log (DBG_DEF, "Record mode on - Recording events to %s.\n", args_info.record_file_arg); + mylog (DBG_DEF, "Record mode on - Recording events to %s.\n", args_info.record_file_arg); /* Check whether the port has been set */ if (!args_info.port_given) @@ -260,29 +261,30 @@ int main (int argc, char *argv[]) if (serverInit () < 0) { - log (DBG_GEN, "Uh Oh! Error initializing server!\n"); + mylog (DBG_GEN, "Uh Oh! Error initializing server!\n"); shutDown (); } - log (DBG_DEF, "Starting server...\n"); + mylog (DBG_DEF, "Starting server...\n"); serverStart (); } + return 0; } void printGreeting (void) { - log (DBG_DEF, "\n"); - log (DBG_DEF, "========================================================\n"); - log (DBG_DEF, "Welcome to Peep (The Network Auralizer).\n"); - log (DBG_DEF, "Copyright (C) 2000 Michael Gilfix.\n"); - log (DBG_DEF, "v%s\n", PACKAGE_VERSION); - log (DBG_DEF, "=========================================================\n"); - log (DBG_DEF, "\n"); + mylog (DBG_DEF, "\n"); + mylog (DBG_DEF, "========================================================\n"); + mylog (DBG_DEF, "Welcome to Peep (The Network Auralizer).\n"); + mylog (DBG_DEF, "Copyright (C) 2000 Michael Gilfix.\n"); + mylog (DBG_DEF, "v%s\n", PACKAGE_VERSION); + mylog (DBG_DEF, "=========================================================\n"); + mylog (DBG_DEF, "\n"); } @@ -293,24 +295,24 @@ void setSigHandlers (void) if ((handler = signal (SIGINT, handleSignal)) == SIG_ERR) { - log (DBG_GEN, "Error registering SIGINT handler: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error registering SIGINT handler: %s\n", strerror (errno)); shutDown (); } #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "Registered SIGINT handler.\n"); + mylog (DBG_SETUP, "Registered SIGINT handler.\n"); #endif if ((handler = signal (SIGHUP, handleSignal)) == SIG_ERR) { - log (DBG_GEN, "Error registering SIGHUP handler: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error registering SIGHUP handler: %s\n", strerror (errno)); shutDown (); } #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "Registered SIGHUP handler.\n"); + mylog (DBG_SETUP, "Registered SIGHUP handler.\n"); #endif } @@ -348,17 +350,17 @@ void *engineLoop (void *data) client_event = engineDequeue (); #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "\n"); - log (DBG_SRVR, "Received Event:\n"); - log (DBG_SRVR, "\ttype: %d\n", client_event.type); - log (DBG_SRVR, "\tlen: %d\n", client_event.sound_len); - log (DBG_SRVR, "\tsound: %s\n", client_event.sound); - log (DBG_SRVR, "\tloc: %d\n", client_event.loc); - log (DBG_SRVR, "\tprior: %d\n", client_event.prior); - log (DBG_SRVR, "\tvol: %d\n", client_event.vol); - log (DBG_SRVR, "\tdither: %d\n", client_event.dither); - log (DBG_SRVR, "\tflags: 0x%04x\n", client_event.flags); - log (DBG_SRVR, "\n"); + mylog (DBG_SRVR, "\n"); + mylog (DBG_SRVR, "Received Event:\n"); + mylog (DBG_SRVR, "\ttype: %d\n", client_event.type); + mylog (DBG_SRVR, "\tlen: %d\n", client_event.sound_len); + mylog (DBG_SRVR, "\tsound: %s\n", client_event.sound); + mylog (DBG_SRVR, "\tloc: %d\n", client_event.loc); + mylog (DBG_SRVR, "\tprior: %d\n", client_event.prior); + mylog (DBG_SRVR, "\tvol: %d\n", client_event.vol); + mylog (DBG_SRVR, "\tdither: %d\n", client_event.dither); + mylog (DBG_SRVR, "\tflags: 0x%04x\n", client_event.flags); + mylog (DBG_SRVR, "\n"); #endif /* Check if we have a valid event */ @@ -366,8 +368,8 @@ void *engineLoop (void *data) if (entry == NULL) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Server does not have event [%s] in its sound table!\n", client_event.sound); - log (DBG_SRVR, "Discarding....\n"); + mylog (DBG_SRVR, "Server does not have event [%s] in its sound table!\n", client_event.sound); + mylog (DBG_SRVR, "Discarding....\n"); #endif continue; @@ -376,7 +378,7 @@ void *engineLoop (void *data) else if (client_event.type != entry->type) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received invalid event type or type does not match sound table.\n"); + mylog (DBG_SRVR, "Received invalid event type or type does not match sound table.\n"); #endif continue; @@ -403,7 +405,7 @@ void handleSignal (int sig) void handleSignal (int sig) { - log (DBG_DEF, "Performing shutdown...\n"); + mylog (DBG_DEF, "Performing shutdown...\n"); if (ethread) threadKill (ethread); @@ -413,23 +415,23 @@ void handleSignal (int sig) /* cleanup */ - log (DBG_DEF, "Cleaning up engine...\n"); + mylog (DBG_DEF, "Cleaning up engine...\n"); engineShutdown (); - log (DBG_DEF, "Cleaning up mixer...\n"); + mylog (DBG_DEF, "Cleaning up mixer...\n"); mixerShutdown (); - log (DBG_DEF, "Cleaning up server...\n"); + mylog (DBG_DEF, "Cleaning up server...\n"); serverShutdown (); if (playbackModeOn (NULL)) { - log (DBG_DEF, "Closing playback file...\n"); - playbackFileShutdown (); + mylog (DBG_DEF, "Closing playback file...\n"); + playbackFileShutdown(); } - log (DBG_DEF, "Exiting...\n"); + mylog (DBG_DEF, "Exiting...\n"); /* Close logging routines */ logClose (); ============================================================ --- peep-0.5.0-rc2/server/mixer.c 870da1d2b1f4406cc589e75ea73648bff2082118 +++ peep-0.5.0-rc2/server/mixer.c 0ca59b016bdabe47e75e7d137b69ae581daf8677 @@ -208,7 +208,6 @@ void mixerAddOldEvent (unsigned int j) struct timeval tp; double tp_conv; ENGINE_EVENT *old_event = mixerDequeue (); - EVENT_ENTRY *entry = engineSoundTableDataRetrieve (old_event->event.sound); ASSERT (old_event != NULL && entry != NULL) @@ -355,6 +354,7 @@ int mixerGetStateThreshIndex (unsigned i return i; } + return 0; } ============================================================ --- peep-0.5.0-rc2/server/mixer_queue.h 6ada4f50ad42c9e7e130b3e284a4f86cd25599ef +++ peep-0.5.0-rc2/server/mixer_queue.h 6cc9e810bc4566051ea3bb22e9f66986534e0bcd @@ -45,8 +45,8 @@ ENGINE_EVENT *mixerDequeue (void); ENGINE_EVENT *mixerDequeue (void); /* Check the status of the queue */ -int MixerQueueEmpty (void); -int MixerQueueFull (void); +int mixerQueueEmpty (void); +int mixerQueueFull (void); /*************************************************************** * Internal function ============================================================ --- peep-0.5.0-rc2/server/notice.h c84ed89358a55820ea8cdc37321d714db97bc00f +++ peep-0.5.0-rc2/server/notice.h 3b9185fd4f0be98ea471f1fc0eb165ee9ae2966a @@ -60,8 +60,14 @@ char *noticeCreateNoticeString (int len) /* Destroys an allocated notice structure and any allocated * sub-components. */ + +void noticeFreeNotice (NOTICE *notice); + +/* Destroys the string part of a notice, I guess */ + void noticeFreeNoticeString (char *string); + /* Processes the XML event notice string passed along with a * client event and passes control to the event notice hook */ ============================================================ --- peep-0.5.0-rc2/server/oss.c 2146b5001dc1a3c421bdb6b58fc4acb7e7dd579d +++ peep-0.5.0-rc2/server/oss.c 40bed24c269e565f43ae01da37dd548e335c450a @@ -48,7 +48,7 @@ void *soundInit (void *snd_device, int m if ((audio_fd = open (dev, mode, O_NONBLOCK)) == -1) { /* Tell the world that opening the device failed */ - log (DBG_GEN, "Couldn't open the sound device: %s\n", strerror (errno)); + mylog (DBG_GEN, "Couldn't open the sound device: %s\n", strerror (errno)); shutDown (); } @@ -74,7 +74,7 @@ int soundSetFormat (void *handle, unsign /* Set sound format */ if (ioctl (*(int *)handle, SNDCTL_DSP_SETFMT, &format_type) == -1) { - log (DBG_GEN, "Couldn't set sound format: %s\n", strerror (errno)); + mylog (DBG_GEN, "Couldn't set sound format: %s\n", strerror (errno)); return 0; } @@ -82,7 +82,7 @@ int soundSetFormat (void *handle, unsign /* Select the number of channels */ if (ioctl (*(int *)handle, SNDCTL_DSP_CHANNELS, &chans) == -1) { - log (DBG_GEN, "Couldn't set the number of sound channels: %s\n", strerror (errno)); + mylog (DBG_GEN, "Couldn't set the number of sound channels: %s\n", strerror (errno)); return 0; } @@ -90,7 +90,7 @@ int soundSetFormat (void *handle, unsign /* Set the sample rate */ if (ioctl (*(int *)handle, SNDCTL_DSP_SPEED, &rate) == -1) { - log (DBG_GEN, "Couldn't set the sample rate: %s\n", strerror (errno)); + mylog (DBG_GEN, "Couldn't set the sample rate: %s\n", strerror (errno)); return 0; } @@ -110,7 +110,7 @@ int soundSetFormat (void *handle, unsign if (ioctl (*(int *)handle, AUDIO_SETINFO, &info) == -1) { - log (DBG_GEN, "Couldn't set audio formatting: %s\n", strerror (errno)); + mylog (DBG_GEN, "Couldn't set audio formatting: %s\n", strerror (errno)); return 0; } ============================================================ --- peep-0.5.0-rc2/server/parser.c a3f4500d0510caad77302efd8707e24195b66999 +++ peep-0.5.0-rc2/server/parser.c 5cc04c1c0328fa4b9394bfdcaba44ba557a8f91e @@ -31,12 +31,18 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include #include #include +#include +#include +#include + #include "parser.h" #include "engine.h" #include "mixer.h" #include "debug.h" #include "main.h" +#include "xml_theme.h" +#include "server.h" extern int errno; @@ -78,7 +84,7 @@ int parserParseConfigFile (char *file) { FILE *config_file = NULL; - char buffer[PARSER_BUFFER_LEN], *p; + char buffer[PARSER_BUFFER_LEN]; char *import_dir = NULL; struct tok tok; int success = 0; @@ -88,14 +94,14 @@ int parserParseConfigFile (char *file) if (import_dir) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tAdding directory [%s] to the import stack...\n", import_dir); + mylog (DBG_SETUP, "\tAdding directory [%s] to the import stack...\n", import_dir); #endif /* Add the directory to the search location for imports */ if (parserImportStackAdd (import_dir) == PARSER_FAILURE) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tError adding directory [%s] to import stack.\n", import_dir); + mylog (DBG_SETUP, "\tError adding directory [%s] to import stack.\n", import_dir); #endif } @@ -112,14 +118,14 @@ int parserParseConfigFile (char *file) if (config_file == NULL) { - log (DBG_GEN, "Couldn't find peep configuration file at: %s\n", file); + mylog (DBG_GEN, "Couldn't find peep configuration file at: %s\n", file); success = PARSER_FAILURE; goto parser_failure; } #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tStarting parse of: [%s].\n", file); + mylog (DBG_SETUP, "\tStarting parse of: [%s].\n", file); #endif while (fgets (buffer, sizeof (buffer), config_file)) { @@ -138,12 +144,12 @@ int parserParseConfigFile (char *file) if (!strcasecmp (tok.token, PARSER_GENERAL_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tParsing 'general' section...\n"); + mylog (DBG_SETUP, "\tParsing 'general' section...\n"); #endif if (parserParseGeneral (config_file) < 0) { - log (DBG_GEN, "Error parsing general information...\n"); + mylog (DBG_GEN, "Error parsing general information...\n"); success = PARSER_GENERAL_ERROR; goto parser_failure; @@ -160,12 +166,12 @@ int parserParseConfigFile (char *file) classname = tok.token; #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tParsing 'class' section for [%s]...\n", classname); + mylog (DBG_SETUP, "\tParsing 'class' section for [%s]...\n", classname); #endif if (parserParseClass (classname, config_file) < 0) { - log (DBG_GEN, "Error parsing class: %s...\n", classname); + mylog (DBG_GEN, "Error parsing class: %s...\n", classname); success = PARSER_CLASS_ERROR; goto parser_failure; @@ -178,7 +184,7 @@ int parserParseConfigFile (char *file) parserTokenize (&tok); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tSkipping section for client: [%s]...\n", tok.token); + mylog (DBG_SETUP, "\tSkipping section for client: [%s]...\n", tok.token); #endif /* this is irrelevant to us, so let's skip the closing brace */ @@ -204,12 +210,12 @@ int parserParseConfigFile (char *file) if (!strcasecmp (tok.token, PARSER_EVENT_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tLoading event:\n"); + mylog (DBG_SETUP, "\tLoading event:\n"); #endif if (parserParseEvent (config_file) < 0) { - log (DBG_GEN, "Error parsing an event...\n"); + mylog (DBG_GEN, "Error parsing an event...\n"); success = PARSER_EVENT_ERROR; goto parser_failure; @@ -220,12 +226,12 @@ int parserParseConfigFile (char *file) if (!strcasecmp (tok.token, PARSER_STATE_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tLoading state:\n"); + mylog (DBG_SETUP, "\tLoading state:\n"); #endif if (parserParseState (config_file) < 0) { - log (DBG_GEN, "Error parsing a state...\n"); + mylog (DBG_GEN, "Error parsing a state...\n"); success = PARSER_STATE_ERROR; goto parser_failure; @@ -238,12 +244,12 @@ int parserParseConfigFile (char *file) parserTokenize (&tok); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tImporting configuration file: [%s]\n", tok.token); + mylog (DBG_SETUP, "\tImporting configuration file: [%s]\n", tok.token); #endif if (parserParseConfigFile (tok.token) < 0) { - log (DBG_GEN, "import failed! Aborting!\n"); + mylog (DBG_GEN, "import failed! Aborting!\n"); success = PARSER_IMPORT_ERROR; goto parser_failure; @@ -260,20 +266,22 @@ int parserParseConfigFile (char *file) parserTokenize (&tok); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\n"); - log (DBG_SETUP, "Loading theme file: [%s]...\n", tok.token); + mylog (DBG_SETUP, "\n"); + mylog (DBG_SETUP, "Loading theme file: [%s]...\n", tok.token); #endif if ((infile = fopen (tok.token, "r")) == NULL) { - log (DBG_GEN, "Error opening theme file %s: %s\n", tok.token, strerror (errno)); + mylog (DBG_GEN, "Error opening theme file %s: %s\n", tok.token, strerror (errno)); success = PARSER_THEME_ERROR; goto parser_failure; } xml_string = (char *)malloc (parserGetFileSize (tok.token) + 1); - fgets (buf, sizeof (buf), infile); + if (fgets (buf, sizeof (buf), infile) == NULL) { + mylog (DBG_GEN, "Error reading theme file, fgets fail\n"); + } strcpy (xml_string, buf); while (fgets (buf, sizeof (buf), infile)) @@ -281,7 +289,7 @@ int parserParseConfigFile (char *file) if (!xmlParseTheme (xml_string, sound_path, &event_cnt, &state_cnt)) { - log (DBG_GEN, "Error parsing theme file: %s\n", tok.token); + mylog (DBG_GEN, "Error parsing theme file: %s\n", tok.token); success = PARSER_THEME_ERROR; goto parser_failure; @@ -334,21 +342,21 @@ int parserIsMyClass (char *host) { struct hostent *entry = NULL; - struct in_addr ipaddr, listaddr; + struct in_addr ipaddr; char localhost[1024]; int i; /* Retreive host info */ if (gethostname (localhost, 1024) < 0) { - log (DBG_GEN, "Error retrieving hostname: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error retrieving hostname: %s\n", strerror (errno)); return 0; } if ((entry = gethostbyname (localhost)) == NULL) { - log (DBG_GEN, "Error getting host by name for %s: %s\n", localhost, strerror (errno)); + mylog (DBG_GEN, "Error getting host by name for %s: %s\n", localhost, strerror (errno)); return 0; } @@ -414,7 +422,7 @@ int parserParseGeneral (FILE *config_fil * any trailing '-' for other releases. */ strncpy (version, PACKAGE_VERSION, 5); - version[5] = '\0'; + version[4] = '\0'; major = atoi (strtok (p, ".")); minor = atoi (strtok (p, ".")); release = atoi (p); @@ -422,7 +430,7 @@ int parserParseGeneral (FILE *config_fil if (major < config_major || minor < config_minor || release < config_release) { - log (DBG_GEN, + mylog (DBG_GEN, "Uh Oh! The config file is incompatible with the current version of peepd: %s\n", VERSION); return PARSER_FAILURE; @@ -430,7 +438,7 @@ int parserParseGeneral (FILE *config_fil } #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tChecked configuration file of appropriate version.\n"); + mylog (DBG_SETUP, "\t\tChecked configuration file of appropriate version.\n"); #endif } @@ -442,7 +450,7 @@ int parserParseGeneral (FILE *config_fil strcpy (sound_path, tok.token); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tSet top-level sound path to: %s.\n", sound_path); + mylog (DBG_SETUP, "\t\tSet top-level sound path to: %s.\n", sound_path); #endif /* Check if we need a trailing "/" */ @@ -497,7 +505,7 @@ int parserParseClass (char *class, FILE serverAddBroadcastPort (atoi (tok.token)); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tAdded broadcast port: [%d].\n", atoi (tok.token)); + mylog (DBG_SETUP, "\t\tAdded broadcast port: [%d].\n", atoi (tok.token)); #endif } @@ -526,7 +534,7 @@ int parserParseClass (char *class, FILE serverAddIDClass (class); serverSetPort (atoi (++q)); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tAdded class [%s] to identifier string.\n", class); + mylog (DBG_SETUP, "\t\tAdded class [%s] to identifier string.\n", class); #endif break; @@ -586,7 +594,7 @@ int parserParseEvent (FILE *config_file) strcpy (name, tok.token); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tName: [%s].\n", tok.token); + mylog (DBG_SETUP, "\t\tName: [%s].\n", tok.token); #endif } @@ -600,7 +608,7 @@ int parserParseEvent (FILE *config_file) strcat (snd_path, tok.token); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tAdding sounds from: [%s]...\n", snd_path); + mylog (DBG_SETUP, "\t\tAdding sounds from: [%s]...\n", snd_path); #endif } @@ -617,8 +625,8 @@ int parserParseEvent (FILE *config_file) if (name == NULL || snd_path == NULL) { #if DEBUG_LEVEL & DBG_GEN - log (DBG_GEN, "Error loading event:\n"); - log (DBG_GEN, "\tFailed to provide a name identifier or a valid path\n"); + mylog (DBG_GEN, "Error loading event:\n"); + mylog (DBG_GEN, "\tFailed to provide a name identifier or a valid path\n"); #endif goto event_failure; @@ -628,7 +636,7 @@ int parserParseEvent (FILE *config_file) /* Now load the actual sound */ if (!parserLoadEventSndDir (name, snd_path)) { - log (DBG_GEN, "Error loading sounds from: %s\n", snd_path); + mylog (DBG_GEN, "Error loading sounds from: %s\n", snd_path); goto event_failure; } @@ -660,13 +668,14 @@ int parserLoadEventSndDir (char *name, c char *path = NULL; short *sound = NULL; - int snd_cnt = 0, length = 0, index = 0; + int snd_cnt = 0, index = 0; + unsigned int length = 0; struct dirent **namelist = NULL; EVENT_ENTRY *entry = NULL; if ((snd_cnt = parserScanDir (snd_path, &namelist, parserScanCompar)) < 0) { - log (DBG_GEN, "Error scanning directory: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error scanning directory: %s\n", strerror (errno)); return 0; } @@ -750,7 +759,7 @@ int parserParseState (FILE *config_file) /* Reset our position and break */ if (fseek (config_file, pos, SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); goto state_failure; } @@ -764,7 +773,7 @@ int parserParseState (FILE *config_file) } #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tState has [%d] thresholds.\n", thresh_cnt); + mylog (DBG_SETUP, "\t\tState has [%d] thresholds.\n", thresh_cnt); #endif /* Allocate the state */ @@ -787,7 +796,7 @@ int parserParseState (FILE *config_file) strcpy (name, tok.token); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tName: [%s].\n", tok.token); + mylog (DBG_SETUP, "\t\tName: [%s].\n", tok.token); #endif } @@ -795,7 +804,7 @@ int parserParseState (FILE *config_file) if (!strcasecmp (tok.token, PARSER_THRESHOLD_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tAdding threshold...\n"); + mylog (DBG_SETUP, "\t\tAdding threshold...\n"); #endif if (!parserParseThreshold (config_file, t_count++)) @@ -812,8 +821,8 @@ int parserParseState (FILE *config_file) if (name == NULL) { #if DEBUG_LEVEL && DBG_GEN - log (DBG_GEN, "Failed to load state sound:\n"); - log (DBG_GEN, "\tNo name identifying the state sound provided.\n"); + mylog (DBG_GEN, "Failed to load state sound:\n"); + mylog (DBG_GEN, "\tNo name identifying the state sound provided.\n"); #endif goto state_failure; @@ -886,8 +895,8 @@ int parserParseThreshold (FILE *config_f h_bound = strtod (tok.token, NULL); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\t\tlower bound: [%lf].\n", l_bound); - log (DBG_SETUP, "\t\t\tupper bound: [%lf].\n", h_bound); + mylog (DBG_SETUP, "\t\t\tlower bound: [%lf].\n", l_bound); + mylog (DBG_SETUP, "\t\t\tupper bound: [%lf].\n", h_bound); #endif } @@ -900,7 +909,7 @@ int parserParseThreshold (FILE *config_f sprintf (path, "%s%s", sound_path, tok.token); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\t\tAdding sounds from: [%s].\n", path); + mylog (DBG_SETUP, "\t\t\tAdding sounds from: [%s].\n", path); #endif } @@ -911,7 +920,7 @@ int parserParseThreshold (FILE *config_f fade = strtod (tok.token, NULL); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\t\tFade time: [%lf].\n", fade); + mylog (DBG_SETUP, "\t\t\tFade time: [%lf].\n", fade); #endif } @@ -940,8 +949,8 @@ int parserParseThreshold (FILE *config_f } else { - log (DBG_GEN, "Error attempted to add incorrect threshold entry.\n"); - log (DBG_GEN, "Bailing...\n"); + mylog (DBG_GEN, "Error attempted to add incorrect threshold entry.\n"); + mylog (DBG_GEN, "Bailing...\n"); shutDown (); } @@ -961,13 +970,14 @@ int parserLoadStateSndDir (int thresh_cn { short *sound = NULL; - int snd_cnt = 0, length = 0, index = 0; + int snd_cnt = 0, index = 0; + unsigned int length = 0; struct dirent **namelist = NULL; char *path = NULL; if (state_cnt >= mixerSBuffs () ) { - log (DBG_DEF, "Attempted to load one too many state sounds. Skipped: %d\n", + mylog (DBG_DEF, "Attempted to load one too many state sounds. Skipped: %d\n", (state_cnt++) - mixerSBuffs ()); return 0; @@ -975,7 +985,7 @@ int parserLoadStateSndDir (int thresh_cn if ((snd_cnt = parserScanDir (snd_path, &namelist, parserScanCompar)) < 0) { - log (DBG_GEN, "Error scanning directory: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error scanning directory: %s\n", strerror (errno)); return 0; } @@ -1097,7 +1107,6 @@ int parserScanDir (char *dir, struct dir DIR *dfile = NULL; struct dirent *dir_ptr = NULL; struct dirent **list_ptr = NULL; - unsigned int dir_size = 0; int items = 0; if ((dfile = opendir (dir)) == NULL) @@ -1146,7 +1155,7 @@ int parserGetFileSize (char *path) if (stat (path, &file_stat) < 0) { - log (DBG_GEN, "Error stat-ing file to obtain file size: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error stat-ing file to obtain file size: %s\n", strerror (errno)); return -1; } @@ -1164,8 +1173,8 @@ short *parserLoadSoundFile (unsigned int if ((infile = fopen (path, "r")) == NULL) { - log (DBG_DEF, "Error opening file at %s: %s\n", path, strerror (errno)); - log (DBG_DEF, "All attempts to play that file will be ignored...\n"); + mylog (DBG_DEF, "Error opening file at %s: %s\n", path, strerror (errno)); + mylog (DBG_DEF, "All attempts to play that file will be ignored...\n"); return NULL; } @@ -1175,7 +1184,7 @@ short *parserLoadSoundFile (unsigned int if ((snd = (short *)calloc (*array_size, sizeof (short))) == NULL) { - log (DBG_DEF, "Error allocating memory: %s\n", strerror (errno)); + mylog (DBG_DEF, "Error allocating memory: %s\n", strerror (errno)); return NULL; } @@ -1183,7 +1192,9 @@ short *parserLoadSoundFile (unsigned int /* Load sound into memory */ for (i = 0; i < *array_size; i++) { - (void)fread (&(snd[i]), 1, sizeof (short), infile); + if (fread (&(snd[i]), 1, sizeof (short), infile) == 0) { + mylog (DBG_DEF, "short read!\n"); + } #ifdef WORDS_BIGENDIAN /* Switch the byte order as we load */ @@ -1201,7 +1212,7 @@ short *parserLoadSoundFile (unsigned int fclose (infile); - log (DBG_DEF, "\t\tLoaded [%s]: %d bytes.\n", path, (*array_size * 2)); + mylog (DBG_DEF, "\t\tLoaded [%s]: %d bytes.\n", path, (*array_size * 2)); return snd; ============================================================ --- peep-0.5.0-rc2/server/playback.c 0802724e0ec65bda11e47ee79609dae98b0fd9e0 +++ peep-0.5.0-rc2/server/playback.c 55568af8631ad87771b7d52fb1241beebfbd5c74 @@ -23,6 +23,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include "main.h" #include "playback.h" #include "debug.h" +#include "engine_queue.h" static FILE *stream = NULL; /* Pointer to the file stream */ static struct playback_h header; /* The file header */ @@ -57,13 +58,13 @@ int playbackFileInit (char *file) { #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Playback routines using file: %s, ", file); + mylog (DBG_PLBK, "Playback routines using file: %s, ", file); #endif if (playbackSetMode (NULL) == RECORD_MODE) - log (DBG_PLBK, "mode: 'RECORD_MODE'\n"); + mylog (DBG_PLBK, "mode: 'RECORD_MODE'\n"); else - log (DBG_PLBK, "mode: 'PLAY_MODE'\n"); + mylog (DBG_PLBK, "mode: 'PLAY_MODE'\n"); switch (playbackSetMode (NULL)) { @@ -72,7 +73,7 @@ int playbackFileInit (char *file) if ((stream = fopen (file, "r")) == NULL) { - log (DBG_GEN, "Uh Oh! Couldn't open playback file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't open playback file: %s\n", strerror (errno)); shutDown (); } @@ -80,7 +81,7 @@ int playbackFileInit (char *file) /* Lead the header into memory */ if (fread (&header, sizeof (struct playback_h), 1, stream) == 0) { - log (DBG_GEN, "Error reading in playback header: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error reading in playback header: %s\n", strerror (errno)); return 0; } @@ -91,8 +92,8 @@ int playbackFileInit (char *file) if ((stream = fopen (file, "w")) == NULL) { - log (DBG_GEN, "Uh Oh! Couldn't create recoding file: %s\n", strerror (errno)); - shutdown (); + mylog (DBG_GEN, "Uh Oh! Couldn't create recoding file: %s\n", strerror (errno)); + shutDown (); } @@ -114,7 +115,7 @@ int playbackFileInit (char *file) */ if (fwrite (&header, sizeof (struct playback_h), 1, stream) == 0) { - log (DBG_GEN, "Error initializing file with playback header: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error initializing file with playback header: %s\n", strerror (errno)); return 0; } @@ -125,21 +126,21 @@ int playbackFileInit (char *file) default: - log (DBG_DEF, + mylog (DBG_DEF, "Uh Oh! peepd asked to use invalid mode for playback. Please specify: {PLAY_MODE, RECORD_MODE}\n"); - shutdown (); + shutDown (); } #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "The playback header is:\n"); - log (DBG_PLBK, "\tmajor ver: [%d]\n", header.major_ver); - log (DBG_PLBK, "\tminor ver: [%d]\n", header.minor_ver); - log (DBG_PLBK, "\tmax events: [%d]\n", header.max_events); - log (DBG_PLBK, "\tevents written: [%d]\n", header.written); - log (DBG_PLBK, "\tstart pos: [%d]\n", header.start_pos); - log (DBG_PLBK, "\tstart time: [%lf]\n", TP_IN_FP_SECS (header.start_t)); - log (DBG_PLBK, "\tend time: [%lf]\n", TP_IN_FP_SECS (header.end_t)); + mylog (DBG_PLBK, "The playback header is:\n"); + mylog (DBG_PLBK, "\tmajor ver: [%d]\n", header.major_ver); + mylog (DBG_PLBK, "\tminor ver: [%d]\n", header.minor_ver); + mylog (DBG_PLBK, "\tmax events: [%d]\n", header.max_events); + mylog (DBG_PLBK, "\tevents written: [%d]\n", header.written); + mylog (DBG_PLBK, "\tstart pos: [%d]\n", header.start_pos); + mylog (DBG_PLBK, "\tstart time: [%lf]\n", TP_IN_FP_SECS (header.start_t)); + mylog (DBG_PLBK, "\tend time: [%lf]\n", TP_IN_FP_SECS (header.end_t)); #endif return 1; @@ -152,11 +153,17 @@ long playbackFindFirstOffset (void) playback_t cur, prev; long initial_pos = ftell (stream); - fread (&prev, sizeof (playback_t), 1, stream); + if ( ! fread (&prev, sizeof (playback_t), 1, stream) ) { + mylog (DBG_PLBK, "short fread finding first offset: %s\n", + strerror (errno)); + } while (!feof (stream)) { - fread (&cur, sizeof (playback_t), 1, stream); + if ( ! fread (&cur, sizeof (playback_t), 1, stream) ) { + mylog (DBG_PLBK, "short fread reading stream: %s\n", + strerror (errno)); + } /* Check if the event we're reading in was earlier than the * previous event. If so, return the position right before @@ -188,7 +195,7 @@ int playbackRecordEvent (ENGINE_EVENT e) #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Recording event at time: %lf, file offset: %d\n", + mylog (DBG_PLBK, "Recording event at time: %lf, file offset: %d\n", TP_IN_FP_SECS (e.mix_time), ftell (stream)); #endif @@ -201,7 +208,7 @@ int playbackRecordEvent (ENGINE_EVENT e) if (fwrite (&rec, sizeof (playback_t), 1, stream) == 0) { - log (DBG_GEN, "Error writing to recording file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error writing to recording file: %s\n", strerror (errno)); return 0; } @@ -214,14 +221,14 @@ int playbackRecordEvent (ENGINE_EVENT e) /* Else, reset our position, right after the header */ if (fseek (stream, sizeof (struct playback_h), SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); return 0; } if (fwrite (&rec, sizeof (playback_t), 1, stream) == 0) { - log (DBG_GEN, "Error writing to recording file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error writing to recording file: %s\n", strerror (errno)); return 0; } @@ -243,6 +250,7 @@ void playbackGo (char *start_t, char *en long start_pos, end_pos; playback_t rec; char *time_format = PLAYBACK_TIME_FORMAT; + end_pos = 0; /* Check if we've been given a start time */ if (start_t != NULL) { @@ -258,14 +266,14 @@ void playbackGo (char *start_t, char *en start.tv_usec = 0; #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Converted start time is: %lf\n", TP_IN_FP_SECS (start)); + mylog (DBG_PLBK, "Converted start time is: %lf\n", TP_IN_FP_SECS (start)); #endif /* Now find the starting time */ header.start_pos = playbackFindFirstOffset (); if ((start_pos = playbackFindTime (start, header.start_pos)) == 0) { - log (DBG_DEF, + mylog (DBG_DEF, "Couldn't find start time in playback file. Playing from beginning."); start_pos = sizeof (struct playback_h); @@ -280,7 +288,7 @@ void playbackGo (char *start_t, char *en end.tv_usec = 0; #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Converted end time is: %lf\n", TP_IN_FP_SECS (end)); + mylog (DBG_PLBK, "Converted end time is: %lf\n", TP_IN_FP_SECS (end)); #endif /* Check if there's an ending time */ @@ -300,24 +308,24 @@ void playbackGo (char *start_t, char *en /* Now set ourselves at the start position to be sure we're there */ if (fseek (stream, start_pos, SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); - shutdown (); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + shutDown (); } } else { /* Otherwise, just play from the beginning */ - log (DBG_DEF, "No start and end time given.\n"); - log (DBG_DEF, "Starting playback from the earliest event in file...\n"); + mylog (DBG_DEF, "No start and end time given.\n"); + mylog (DBG_DEF, "Starting playback from the earliest event in file...\n"); /* Check if we last closed the file correctly */ if (TP_IN_FP_SECS (header.end_t) != 0.0) { if (fseek (stream, header.start_pos, SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); - shutdown (); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + shutDown (); } @@ -328,8 +336,8 @@ void playbackGo (char *start_t, char *en * where the starting position is in the round robin */ if (fseek (stream, playbackFindFirstOffset (), SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); - shutdown (); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + shutDown (); } @@ -340,17 +348,20 @@ void playbackGo (char *start_t, char *en } /* Figure out time diff with respect to our current time */ - fread (&rec, sizeof (playback_t), 1, stream); + if ( ! fread (&rec, sizeof (playback_t), 1, stream) ) { + mylog (DBG_GEN, "short fread looking for next event: %s\n", + strerror (errno)); + } event_offset = rec.record.mix_time; gettimeofday (&time_offset, NULL); fseek (stream, -sizeof (playback_t), SEEK_CUR); #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Calculated event offset: %lf and time offset: %lf...\n", + mylog (DBG_PLBK, "Calculated event offset: %lf and time offset: %lf...\n", TP_IN_FP_SECS (event_offset), TP_IN_FP_SECS (time_offset)); - log (DBG_PLBK, "Expected start position: %ld and end position: %ld\n", + mylog (DBG_PLBK, "Expected start position: %ld and end position: %ld\n", start_pos, end_pos); #endif @@ -359,7 +370,7 @@ void playbackGo (char *start_t, char *en do { #if DEBUG_LEVEL & DBG_PLBK - log (DBG_DEF, "We're currently looking at position: %ld\n", + mylog (DBG_DEF, "We're currently looking at position: %ld\n", ftell (stream)); #endif @@ -370,7 +381,7 @@ void playbackGo (char *start_t, char *en case EINTR: #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Hit eof. Reseting to end of header...\n"); + mylog (DBG_PLBK, "Hit eof. Reseting to end of header...\n"); #endif fseek (stream, sizeof (struct playback_h), SEEK_SET); @@ -379,7 +390,7 @@ void playbackGo (char *start_t, char *en default: { - log (DBG_GEN, + mylog (DBG_GEN, "Error reading in event: %s. Attempting to continue...\n", strerror (errno)); /* Attempting to continue */ @@ -394,28 +405,30 @@ void playbackGo (char *start_t, char *en cur_time_offset = TP_IN_FP_SECS (current) - TP_IN_FP_SECS (time_offset); #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "Playback Event:\n"); - log (DBG_PLBK, "\tmix in time: [%lf]\n", TP_IN_FP_SECS (rec.record.mix_time)); - log (DBG_PLBK, "\tcurrent time: [%lf]\n", TP_IN_FP_SECS (current)); - log (DBG_PLBK, "\tmix offset: [%lf]\n", plbk_offset); - log (DBG_PLBK, "\ttime offset: [%lf]\n", cur_time_offset); - log (DBG_PLBK, "\tsleeping: [%lf]\n", plbk_offset - cur_time_offset); + mylog (DBG_PLBK, "Playback Event:\n"); + mylog (DBG_PLBK, "\tmix in time: [%lf]\n", TP_IN_FP_SECS (rec.record.mix_time)); + mylog (DBG_PLBK, "\tcurrent time: [%lf]\n", TP_IN_FP_SECS (current)); + mylog (DBG_PLBK, "\tmix offset: [%lf]\n", plbk_offset); + mylog (DBG_PLBK, "\ttime offset: [%lf]\n", cur_time_offset); + mylog (DBG_PLBK, "\tsleeping: [%lf]\n", plbk_offset - cur_time_offset); #endif /* Sleep our event offset if necessary */ if (plbk_offset > cur_time_offset) usleep ((unsigned long)((plbk_offset - cur_time_offset) * 1000000.0)); - engineEnqueue (rec.record); + EVENT recording; + recording = rec.record.event; + engineEnqueue (recording); event_cnt++; } while (ftell (stream) != end_pos && ftell (stream) != start_pos); /* Now that we're done playback, let's wait a bit for the next sound to play - * and then shutdown */ + * and then shutDown */ sleep (PLAYBACK_TRAIL_TIME); - shutdown (); + shutDown (); } @@ -427,14 +440,17 @@ long playbackFindTime (struct timeval t, if (fseek (stream, start_pos, SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); return 0; } do { - fread (&rec, sizeof (playback_t), 1, stream); + if ( !fread (&rec, sizeof (playback_t), 1, stream) ) { + mylog (DBG_GEN, "short fread in the do loop: %s\n", + strerror (errno)); + } time = rec.record.mix_time; if (TP_IN_FP_SECS (time) >= TP_IN_FP_SECS (t)) { @@ -448,7 +464,7 @@ long playbackFindTime (struct timeval t, if (fseek (stream, sizeof (struct playback_h), SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error seeking in file: %s\n", strerror (errno)); return 0; } @@ -481,22 +497,22 @@ int playbackFileShutdown (void) #if DEBUG_LEVEL & DBG_PLBK - log (DBG_PLBK, "On shutdown, the playback header is:\n"); - log (DBG_PLBK, "\tmajor ver: [%d]\n", header.major_ver); - log (DBG_PLBK, "\tminor ver: [%d]\n", header.minor_ver); - log (DBG_PLBK, "\tmax events: [%d]\n", header.max_events); - log (DBG_PLBK, "\tevents written: [%d]\n", header.written); - log (DBG_PLBK, "\tstart pos: [%d]\n", header.start_pos); - log (DBG_PLBK, "\tstart time: [%lf]\n", TP_IN_FP_SECS (header.start_t)); - log (DBG_PLBK, "\tend time: [%lf]\n", TP_IN_FP_SECS (header.end_t)); + mylog (DBG_PLBK, "On shutDown, the playback header is:\n"); + mylog (DBG_PLBK, "\tmajor ver: [%d]\n", header.major_ver); + mylog (DBG_PLBK, "\tminor ver: [%d]\n", header.minor_ver); + mylog (DBG_PLBK, "\tmax events: [%d]\n", header.max_events); + mylog (DBG_PLBK, "\tevents written: [%d]\n", header.written); + mylog (DBG_PLBK, "\tstart pos: [%d]\n", header.start_pos); + mylog (DBG_PLBK, "\tstart time: [%lf]\n", TP_IN_FP_SECS (header.start_t)); + mylog (DBG_PLBK, "\tend time: [%lf]\n", TP_IN_FP_SECS (header.end_t)); #endif /* Now seek to the start of the file and write out the header */ if (fseek (stream, 0, SEEK_SET) < 0) { - log (DBG_GEN, "Error seeking in file: %s", strerror (errno)); - return 0; + mylog (DBG_GEN, "Error seeking in file: %s", strerror (errno)); + return 1; } @@ -506,14 +522,16 @@ int playbackFileShutdown (void) case PLAY_MODE: - log (DBG_DEF, "Finished playback. You just heard %d events.\n", + mylog (DBG_DEF, "Finished playback. You just heard %d events.\n", event_cnt); break; default: - log (DBG_DEF, "Warning: peepd was in an invalid playback mode."); - log (DBG_DEF, "shutdown may not have been successful\n"); + mylog (DBG_DEF, "Warning: peepd was in an invalid playback mode."); + mylog (DBG_DEF, "shutDown may not have been successful\n"); } + return 0; + } ============================================================ --- peep-0.5.0-rc2/server/playback.h cdfabe13acd90648727b3f281d7602e791b5495b +++ peep-0.5.0-rc2/server/playback.h 4d2476746b9b6cf779e0be9b5c6396472dc45bd1 @@ -40,6 +40,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #endif #include +char *strptime(const char *s, const char *format, struct tm *tm); + struct playback_h { char major_ver; /* version of the playback format */ ============================================================ --- peep-0.5.0-rc2/server/server.c 1d96b0cd10d029fb8c68314b6df708a9afeb7f05 +++ peep-0.5.0-rc2/server/server.c 0ad85b76c3ad892ff3a327aaef0ed31a1b2ab5e0 @@ -31,6 +31,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include "server.h" #include "debug.h" +#include +#include "engine_queue.h" +#include "tcp_server.h" +#include "udp_server.h" + static int broadcast_fd = 0; static int port = 0; static BROADCAST *broadcast_list = NULL; @@ -92,12 +97,12 @@ int initializeBroadcast (void) BROADCAST *cur_bc; #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Opening udp socket for initial broadcast...\n"); + mylog (DBG_SRVR, "Opening udp socket for initial broadcast...\n"); #endif if ((prot = getprotobyname ("udp")) == NULL) { - log (DBG_GEN, "Uh Oh! Error resolving protocl info for 'udp': %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Error resolving protocl info for 'udp': %s\n", strerror (errno)); return SERVER_FAILURE; } @@ -106,7 +111,7 @@ int initializeBroadcast (void) if ((broadcast_fd = socket (AF_INET, SOCK_DGRAM, prot_no)) < 0) { - log (DBG_GEN, "Uh Oh! Couldn't open udp socket for broadcasting: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't open udp socket for broadcasting: %s\n", strerror (errno)); return SERVER_FAILURE; } @@ -118,7 +123,7 @@ int initializeBroadcast (void) if (setsockopt (broadcast_fd, SOL_SOCKET, SO_BROADCAST, &x, sizeof (x)) == -1) { - log (DBG_GEN, "Uh Oh! Error setting socket options: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Error setting socket options: %s\n", strerror (errno)); return SERVER_FAILURE; } @@ -131,7 +136,7 @@ int initializeBroadcast (void) if (setsockopt (broadcast_fd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) { - log (DBG_GEN, "Uh Oh! Error setting socket options: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Error setting socket options: %s\n", strerror (errno)); return SERVER_FAILURE; } @@ -145,7 +150,7 @@ int initializeBroadcast (void) if (bind (broadcast_fd, (struct sockaddr *)&baddr, sizeof (struct sockaddr_in)) < 0) { - log (DBG_GEN, "Uh Oh! Couldn't bind to udp broadcast port: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't bind to udp broadcast port: %s\n", strerror (errno)); return SERVER_FAILURE; } @@ -157,12 +162,12 @@ int initializeBroadcast (void) identifier = (MSG_STRING)malloc (2 * sizeof (char)); strcpy ((char *)identifier, ""); - log (DBG_DEF, "\nWarning: Could not assemble a class identifier strings.\n"); - log (DBG_DEF, "Check your classes in peep.conf. Using blank identifier instead.\n"); + mylog (DBG_DEF, "\nWarning: Could not assemble a class identifier strings.\n"); + mylog (DBG_DEF, "Check your classes in peep.conf. Using blank identifier instead.\n"); } - log (DBG_DEF, "Server class identifier string: %s\n", identifier); + mylog (DBG_DEF, "Server class identifier string: %s\n", identifier); for (cur_bc = broadcast_list; cur_bc; cur_bc = cur_bc->next) { @@ -193,14 +198,14 @@ int initializeBroadcast (void) if (sendto (broadcast_fd, buffer, buf_len, 0, (struct sockaddr *)&bc, sizeof (struct sockaddr_in)) < 0) { - log (DBG_GEN, "Warning: received a broadcast error message: %s\n", strerror (errno)); + mylog (DBG_GEN, "Warning: received a broadcast error message: %s\n", strerror (errno)); /* Don't return. Let's try to continue */ } freePacketBuffer (buffer); - log (DBG_DEF, "Broadcasting existence to port [%d].\n", cur_bc->port); + mylog (DBG_DEF, "Broadcasting existence to port [%d].\n", cur_bc->port); } @@ -229,7 +234,7 @@ void receiveUDPPacket (int fd) if (size_recv == -1 && errno == ECONNREFUSED) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Hmm, it seems a UDP packet did not reach its destination.\n"); + mylog (DBG_SRVR, "Hmm, it seems a UDP packet did not reach its destination.\n"); return; #endif @@ -246,7 +251,7 @@ void receiveUDPPacket (int fd) if (msg.header.magic != PROT_MAGIC_NUMBER) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received UDP packet with bad magic number. Discarding...\n"); + mylog (DBG_SRVR, "Received UDP packet with bad magic number. Discarding...\n"); #endif return; @@ -255,44 +260,38 @@ void receiveUDPPacket (int fd) /* Print out packet header */ #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Packet header:\n"); - log (DBG_SRVR, "\tversion: [%d]\n", msg.header.version); - log (DBG_SRVR, "\ttype: [%d]\n", msg.header.type); - log (DBG_SRVR, "\tcontent: [%d]\n", msg.header.content); - log (DBG_SRVR, "\tmagic: [0x%x]\n", msg.header.magic); - log (DBG_SRVR, "\tlen: [%d]\n", msg.header.len); + mylog (DBG_SRVR, "Packet header:\n"); + mylog (DBG_SRVR, "\tversion: [%d]\n", msg.header.version); + mylog (DBG_SRVR, "\ttype: [%d]\n", msg.header.type); + mylog (DBG_SRVR, "\tcontent: [%d]\n", msg.header.content); + mylog (DBG_SRVR, "\tmagic: [0x%x]\n", msg.header.magic); + mylog (DBG_SRVR, "\tlen: [%d]\n", msg.header.len); #endif switch (msg.header.type) { - case PROT_BC_SERVER: + case PROT_BC_SERVER: + /* Do nothing */ + break; - /* Do nothing */ - break; - - case PROT_BC_CLIENT: - - msg.body = (void *)malloc (msg.header.len + 1); - memcpy (msg.body, buffer + sizeof (HEADER), msg.header.len); - ((char *)msg.body)[msg.header.len] = '\0'; - + case PROT_BC_CLIENT: + msg.body = (void *)malloc (msg.header.len + 1); + memcpy (msg.body, buffer + sizeof (HEADER), msg.header.len); + ((char *)msg.body)[msg.header.len] = '\0'; #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received client broadcast packet.\n"); + mylog (DBG_SRVR, "Received client broadcast packet.\n"); #endif + serverProcessClientBC ((MSG_STRING)msg.body, msg.header.len, &from); + break; - serverProcessClientBC ((MSG_STRING)msg.body, msg.header.len, &from); - break; - - default: - + default: #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received unsupported packet type from broadcast. Discarding...\n"); + mylog (DBG_SRVR, "Received unsupported packet type from broadcast. Discarding...\n"); #endif - break; + break; } -udpERR: free (msg.body); } @@ -389,7 +388,7 @@ void serverProcessClientEvent (int conte case PROT_CONTENT_XML: #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Got client event with XML content.\n"); + mylog (DBG_SRVR, "Got client event with XML content.\n"); #endif notice_string = (char *)malloc (msg_len + 1); @@ -411,7 +410,7 @@ void serverProcessClientEvent (int conte if (notice == NULL) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Error converting XML notice to engine event. Discarding...\n"); + mylog (DBG_SRVR, "Error converting XML notice to engine event. Discarding...\n"); #endif noticeFreeNotice (notice); @@ -427,7 +426,7 @@ void serverProcessClientEvent (int conte case PROT_CONTENT_EVENT: #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Got client event with ENGINE EVENT type content.\n"); + mylog (DBG_SRVR, "Got client event with ENGINE EVENT type content.\n"); #endif engineEnqueue (* (EVENT *)msg); @@ -588,7 +587,7 @@ void serverRespondToClient (struct in_ad if (sendto (broadcast_fd, buffer, buf_len, 0, (struct sockaddr *)&addr, sizeof (struct sockaddr_in)) < 0) { - log (DBG_GEN, "Warning: received a broadcast error message: %s\n", strerror (errno)); + mylog (DBG_GEN, "Warning: received a broadcast error message: %s\n", strerror (errno)); /* Don't return. Let's try to continue */ } @@ -596,7 +595,7 @@ void serverRespondToClient (struct in_ad freePacketBuffer (buffer); #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Sent response to client.\n"); + mylog (DBG_SRVR, "Sent response to client.\n"); #endif } ============================================================ --- peep-0.5.0-rc2/server/tcp_server.c a4916ecd2057631fe4389198beadcea214d7ab10 +++ peep-0.5.0-rc2/server/tcp_server.c 7e45f2e8bd84001cfdbe46e9bcc5ab84aab80264 @@ -49,19 +49,19 @@ int serverRealInit (void) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Initializing TCP server routines...\n"); + mylog (DBG_SRVR, "Initializing TCP server routines...\n"); #endif if (gethostname (localhost, PROT_MAX_HOSTNAME) < 0) { - log (DBG_GEN, "Uh Oh! Couldn't get my hostname: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't get my hostname: %s\n", strerror (errno)); return SERVER_FAILURE; } if ((host = gethostbyname (localhost)) == NULL) { - log (DBG_GEN, "Uh Oh! Peep couldn't get local host information: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Peep couldn't get local host information: %s\n", strerror (errno)); return SERVER_FAILURE; } @@ -84,7 +84,7 @@ int serverInitSocket (void) /* Create the tcp socket for connections */ if ((server_fd = socket (AF_INET, SOCK_STREAM, 0)) < 0) { - log (DBG_GEN, "Uh Oh! Couldn't create server socket: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't create server socket: %s\n", strerror (errno)); return 0; } @@ -96,7 +96,7 @@ int serverInitSocket (void) if (setsockopt (server_fd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) { - log (DBG_GEN, "Uh Oh! Error setting socket options: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Error setting socket options: %s\n", strerror (errno)); return 0; } @@ -106,7 +106,7 @@ int serverInitSocket (void) /* Set non blocking flag so we don't wait on a false accept */ if (fcntl (server_fd, F_SETFL, O_NONBLOCK) < 0) { - log (DBG_GEN, "Uh Oh! Error setting socket O_NONBLOCK option: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Error setting socket O_NONBLOCK option: %s\n", strerror (errno)); return 0; } @@ -119,14 +119,14 @@ int serverInitSocket (void) if (bind (server_fd, (struct sockaddr *)&saddr, sizeof (struct sockaddr_in)) < 0) { - log (DBG_GEN, "Uh Oh! Couldn't bind to socket: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't bind to socket: %s\n", strerror (errno)); return 0; } if (listen (server_fd, PROT_LISTEN_QUEUE) < 0) { - log (DBG_GEN, "Uh Oh! Couldn't setup listen queue: %s\n", strerror (errno)); + mylog (DBG_GEN, "Uh Oh! Couldn't setup listen queue: %s\n", strerror (errno)); return 0; } @@ -143,12 +143,11 @@ void serverRealStart (void) fd_set read_set; /* for use with select */ pthread_t client_thread; /* handler for creating client thread */ int cli = 0, highest_fd = 0; - char *host_string = NULL; /* For passing to the servlets */ struct servlet_data *data = NULL; - log (DBG_DEF, "%s | using INET address %s:%d\n", localhost, + mylog (DBG_DEF, "%s | using INET address %s:%d\n", localhost, inet_ntoa (*host_node), serverGetPort ()); highest_fd = (server_fd < broadcast_fd) ? broadcast_fd : server_fd; @@ -174,7 +173,7 @@ void serverRealStart (void) cli = accept (server_fd, (struct sockaddr *)&from, (socklen_t *)&from_len); #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received connection: %s:%d\n", + mylog (DBG_SRVR, "Received connection: %s:%d\n", inet_ntoa (from.sin_addr), ntohs(from.sin_port)); #endif @@ -197,7 +196,6 @@ void *serverServlet (void *thread_data) PACKET msg; fd_set read_set; int size_recv = 0; - EVENT *event = NULL; int fd = ((struct servlet_data *)thread_data)->fd; struct sockaddr_in client = ((struct servlet_data *)thread_data)->client; @@ -217,7 +215,7 @@ void *serverServlet (void *thread_data) if (size_recv < 0) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Error while reading from tcp socket: %s\n", strerror (errno)); + mylog (DBG_SRVR, "Error while reading from tcp socket: %s\n", strerror (errno)); #endif close (fd); return NULL; @@ -239,12 +237,12 @@ void *serverServlet (void *thread_data) /* Print out packet header */ #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Packet header:\n"); - log (DBG_SRVR, "\tversion: [%d]\n", msg.header.version); - log (DBG_SRVR, "\ttype: [%d]\n", msg.header.type); - log (DBG_SRVR, "\tcontent: [%d]\n", msg.header.content); - log (DBG_SRVR, "\tmagic: [0x%x]\n", msg.header.magic); - log (DBG_SRVR, "\tlen: [%d]\n", msg.header.len); + mylog (DBG_SRVR, "Packet header:\n"); + mylog (DBG_SRVR, "\tversion: [%d]\n", msg.header.version); + mylog (DBG_SRVR, "\ttype: [%d]\n", msg.header.type); + mylog (DBG_SRVR, "\tcontent: [%d]\n", msg.header.content); + mylog (DBG_SRVR, "\tmagic: [0x%x]\n", msg.header.magic); + mylog (DBG_SRVR, "\tlen: [%d]\n", msg.header.len); #endif if (msg.header.magic != PROT_MAGIC_NUMBER) @@ -261,7 +259,7 @@ void *serverServlet (void *thread_data) if (!size_recv != msg.header.len) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Error while reading body of client broadcast packet: %s\n", strerror (errno)); + mylog (DBG_SRVR, "Error while reading body of client broadcast packet: %s\n", strerror (errno)); #endif goto servletERR; @@ -279,7 +277,7 @@ void *serverServlet (void *thread_data) if (size_recv != msg.header.len) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Error while reading body of client event packet: %s\n", strerror (errno)); + mylog (DBG_SRVR, "Error while reading body of client event packet: %s\n", strerror (errno)); #endif continue; @@ -299,14 +297,14 @@ void *serverServlet (void *thread_data) if (size_recv != msg.header.len) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Error while reading body of server broadcast packet: %s\n", strerror (errno)); + mylog (DBG_SRVR, "Error while reading body of server broadcast packet: %s\n", strerror (errno)); #endif goto servletERR; } #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received broadcast from other server. Discarding...\n"); + mylog (DBG_SRVR, "Received broadcast from other server. Discarding...\n"); #endif break; @@ -318,7 +316,7 @@ void *serverServlet (void *thread_data) if (!size_recv != msg.header.len) { #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Error while reading body of unsupported packet type: %s\n", strerror (errno)); + mylog (DBG_SRVR, "Error while reading body of unsupported packet type: %s\n", strerror (errno)); #endif goto servletERR; @@ -326,7 +324,7 @@ void *serverServlet (void *thread_data) #if DEBUG_LEVEL & DBG_SRVR - log (DBG_SRVR, "Received unsupported packet type. Discarding...\n"); + mylog (DBG_SRVR, "Received unsupported packet type. Discarding...\n"); #endif break; ============================================================ --- peep-0.5.0-rc2/server/thread.c 6cc1374c68dcf663d61e6b1e5df63dd5f058f4b1 +++ peep-0.5.0-rc2/server/thread.c 8218e36b252f2d5d10735e7a9e5939f7754f9b06 @@ -108,14 +108,14 @@ sem_t *semaphoreCreate (int value) if ((sem = (sem_t *)malloc (sizeof (sem_t))) == NULL) { - log (DBG_GEN, "Error creating a new semaphore: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error creating a new semaphore: %s\n", strerror (errno)); return NULL; } if (sem_init (sem, 0, value) < 0) { - log (DBG_GEN, "Error initializing a new semaphore: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error initializing a new semaphore: %s\n", strerror (errno)); free (sem); return NULL; @@ -134,7 +134,7 @@ int semaphoreAcquire (sem_t *sem, int bl if ((ret = sem_wait (sem)) < 0) { - log (DBG_GEN, "Error waiting on and decrementing a semaphore: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error waiting on and decrementing a semaphore: %s\n", strerror (errno)); return 0; } @@ -145,7 +145,7 @@ int semaphoreAcquire (sem_t *sem, int bl if ((ret = sem_trywait (sem)) < 0) { if (ret != EAGAIN) - log (DBG_GEN, "Error performing non-blocking acquire of a semaphore: %s\n", + mylog (DBG_GEN, "Error performing non-blocking acquire of a semaphore: %s\n", strerror (errno)); return 0; @@ -163,7 +163,7 @@ int semaphoreRelease (sem_t *sem) if (sem_post (sem) < 0) { - log (DBG_GEN, "Error incrementing a semaphore: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error incrementing a semaphore: %s\n", strerror (errno)); return 0; } @@ -177,7 +177,7 @@ int semaphoreDestroy (sem_t *sem) if (sem && sem_destroy (sem) < 0) { - log (DBG_GEN, "Error destroying a semaphore: %s\n", strerror (errno)); + mylog (DBG_GEN, "Error destroying a semaphore: %s\n", strerror (errno)); free (sem); return 0; ============================================================ --- peep-0.5.0-rc2/server/xml.c ace9983c85c153059eae1fa54de65bf1947628ca +++ peep-0.5.0-rc2/server/xml.c bef779f803e99a292c21d051c6939961acd68cab @@ -19,6 +19,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include #include "xml.h" +#include + char *createXmlNormalizedString (char *s, int len) { ============================================================ --- peep-0.5.0-rc2/server/xml_notice.c 7b6c498cac0b38521cef3e5318e6d0dc242ab9b9 +++ peep-0.5.0-rc2/server/xml_notice.c 4587ca60765b5c4e3a9da152342e6796b6c0aa8e @@ -25,6 +25,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICU #include "xml_notice.h" #include "debug.h" +#include + + void xmlParseClientEvent (char *xml_string, int len, NOTICE *notice) { @@ -37,7 +40,7 @@ void xmlParseClientEvent (char *xml_stri if (!parser) { - log (DBG_GEN, "Couldn't create an XML parsing object: %s\n", + mylog (DBG_GEN, "Couldn't create an XML parsing object: %s\n", (char *)XML_ErrorString (XML_GetErrorCode (parser) )); return; @@ -60,7 +63,7 @@ void xmlParseClientEvent (char *xml_stri */ if (! XML_Parse (parser, xml_string, len, 1) ) { - log (DBG_GEN, "Uh Oh! There was an XML parsing error: %s\n", + mylog (DBG_GEN, "Uh Oh! There was an XML parsing error: %s\n", (char *)XML_ErrorString ( XML_GetErrorCode (parser) )); /* Try to continue */ @@ -88,7 +91,7 @@ void xmlParseClientEnd (void *data, cons void xmlParseClientEnd (void *data, const XML_Char *tag_name) { - CLIENT_PARSE_INFO *client_info = (CLIENT_PARSE_INFO *)data; + mylog (DBG_GEN, "done parsing XML\n"); } @@ -149,8 +152,8 @@ void xmlParseClientChar (void *data, con else { /* We have an unsupported tag */ - log (DBG_HOOK, "WARNING: Encountered unsupported XML tag: [%s]\n", client_info->current_tag); - log (DBG_HOOK, "WARNING: XML text is: [%s]\n", string); + mylog (DBG_HOOK, "WARNING: Encountered unsupported XML tag: [%s]\n", client_info->current_tag); + mylog (DBG_HOOK, "WARNING: XML text is: [%s]\n", string); } ============================================================ --- peep-0.5.0-rc2/server/xml_notice.h 94cac47df0b71ccbbb256771b396f5a7a6f84f09 +++ peep-0.5.0-rc2/server/xml_notice.h 6c2ee83d1b0c35333bfe789d89d9b4cf85977372 @@ -36,6 +36,8 @@ void freeXmlNormalizedString (char *s); #include #include "notice.h" +char *strptime(const char *s, const char *format, struct tm *tm); + typedef struct { NOTICE *notice; XML_Parser parser; ============================================================ --- peep-0.5.0-rc2/server/xml_theme.c 46b990789e7fe975d434c70b89cc7e7e96763a70 +++ peep-0.5.0-rc2/server/xml_theme.c 7b1463512afddc8f6f3c1f5693070b087c25e453 @@ -51,7 +51,7 @@ int xmlParseTheme (char *xml_string, cha if (!parser) { - log (DBG_GEN, "Couldn't create an XML parsing object: %s\n", + mylog (DBG_GEN, "Couldn't create an XML parsing object: %s\n", (char *)XML_ErrorString (XML_GetErrorCode (parser) )); return XML_PARSER_FAILURE; @@ -66,13 +66,13 @@ int xmlParseTheme (char *xml_string, cha XML_SetUserData (parser, first_info); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "Starting first pass of theme file...\n"); + mylog (DBG_SETUP, "Starting first pass of theme file...\n"); #endif if (!XML_Parse (parser, xml_string, strlen (xml_string), 1)) { - log (DBG_GEN, "Uh Oh! There was an xml parsing error while parsing the xml configuration file:\n"); - log (DBG_GEN, "\tLine %d: %s\n", XML_GetCurrentLineNumber(parser), (char *)XML_ErrorString ( XML_GetErrorCode (parser) )); + mylog (DBG_GEN, "Uh Oh! There was an xml parsing error while parsing the xml configuration file:\n"); + mylog (DBG_GEN, "\tLine %d: %s\n", XML_GetCurrentLineNumber(parser), (char *)XML_ErrorString ( XML_GetErrorCode (parser) )); return XML_PARSER_FAILURE; } @@ -84,7 +84,7 @@ int xmlParseTheme (char *xml_string, cha if (!parser) { - log (DBG_GEN, "Couldn't create an XML parsing object: %s\n", + mylog (DBG_GEN, "Couldn't create an XML parsing object: %s\n", (char *)XML_ErrorString (XML_GetErrorCode (parser) )); return XML_PARSER_FAILURE; @@ -100,13 +100,13 @@ int xmlParseTheme (char *xml_string, cha XML_SetUserData (parser, second_info); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "Starting second pass of theme file...\n"); + mylog (DBG_SETUP, "Starting second pass of theme file...\n"); #endif if (!XML_Parse (parser, xml_string, strlen (xml_string), 1)) { - log (DBG_GEN, "Uh Oh! There was an xml parsing error while parsing the xml configuration file:\n"); - log (DBG_GEN, "\tLine %d: %s\n", XML_GetCurrentLineNumber(parser), (char *)XML_ErrorString ( XML_GetErrorCode (parser) )); + mylog (DBG_GEN, "Uh Oh! There was an xml parsing error while parsing the xml configuration file:\n"); + mylog (DBG_GEN, "\tLine %d: %s\n", XML_GetCurrentLineNumber(parser), (char *)XML_ErrorString ( XML_GetErrorCode (parser) )); return XML_PARSER_FAILURE; } @@ -152,7 +152,7 @@ void xmlParseFirstPassStart (void *data, info->cur_ent = xmlThemeCreateTransEntry (); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tExtracting sound definition:\n"); + mylog (DBG_SETUP, "\tExtracting sound definition:\n"); #endif } @@ -201,29 +201,29 @@ void xmlParseFirstPassChar (void *data, strcpy (info->cur_ent->name, string); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tName: [%s]\n", string); + mylog (DBG_SETUP, "\t\tName: [%s]\n", string); #endif } #if DEBUG_LEVEL & DBG_SETUP if (!strcasecmp (info->current_tag, XML_CATEGORY_TOKEN)) { - log (DBG_SETUP, "\t\tCategory: [%s]\n", string); + mylog (DBG_SETUP, "\t\tCategory: [%s]\n", string); info->cur_ent->category = (char *)malloc (strlen (string) + 1); strcpy (info->cur_ent->category, string); } else if (!strcasecmp (info->current_tag, XML_TYPE_TOKEN)) { - log (DBG_SETUP, "\t\tType: [%s]\n", string); + mylog (DBG_SETUP, "\t\tType: [%s]\n", string); info->cur_ent->type = (char *)malloc (strlen (string) + 1); strcpy (info->cur_ent->type, string); } else if (!strcasecmp (info->current_tag, XML_FORMAT_TOKEN)) { - log (DBG_SETUP, "\t\tFormat: [%s]\n", string); + mylog (DBG_SETUP, "\t\tFormat: [%s]\n", string); info->cur_ent->format = (char *)malloc (strlen (string) + 1); strcpy (info->cur_ent->format, string); } else if (!strcasecmp (info->current_tag, XML_DESCRIPTION_TOKEN)) { - log (DBG_SETUP, "\t\tDescription: [%s]\n", string); + mylog (DBG_SETUP, "\t\tDescription: [%s]\n", string); info->cur_ent->desc = (char *)malloc (strlen (string) + 1); strcpy (info->cur_ent->desc, string); } @@ -232,7 +232,7 @@ void xmlParseFirstPassChar (void *data, if (!strcasecmp (info->current_tag, XML_PATH_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tPath: [%s]...\n", string); + mylog (DBG_SETUP, "\t\tPath: [%s]...\n", string); #endif info->cur_ent->path = (char *)malloc (strlen (string) + strlen (info->sound_path) + 1); strcpy (info->cur_ent->path, info->sound_path); @@ -325,7 +325,7 @@ void xmlParseSecondPassStart (void *data #if DEBUG_LEVEL & DBG_SETUP if (!strcasecmp (attribs[i], XML_NAME_TOKEN)) - log (DBG_SETUP, "\tTheme Name: [%s]\n", attribs[i+1]); + mylog (DBG_SETUP, "\tTheme Name: [%s]\n", attribs[i+1]); #endif } @@ -341,7 +341,7 @@ void xmlParseSecondPassStart (void *data if (!strcasecmp (tag_name, XML_EVENT_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tLoading Theme Event Sound:\n"); + mylog (DBG_SETUP, "\tLoading Theme Event Sound:\n"); #endif } @@ -357,8 +357,8 @@ void xmlParseSecondPassStart (void *data if (!strcasecmp (tag_name, XML_STATE_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\tLoad Theme State Sound:\n"); - log (DBG_SETUP, "\t\tState has [%d] thresholds.\n", info->thresholds[info->thresh_index]); + mylog (DBG_SETUP, "\tLoad Theme State Sound:\n"); + mylog (DBG_SETUP, "\t\tState has [%d] thresholds.\n", info->thresholds[info->thresh_index]); #endif /* Allocate the state */ @@ -369,7 +369,7 @@ void xmlParseSecondPassStart (void *data else if (!strcasecmp (tag_name, XML_THRESHOLD_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tAdding threshold...\n"); + mylog (DBG_SETUP, "\t\tAdding threshold...\n"); #endif info->context = THRESHOLD_CONTEXT; @@ -396,8 +396,8 @@ void xmlParseSecondPassEnd (void *data, if (info->path == NULL || info->name == NULL) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_GEN, "\t\tFailed to load event sound:\n"); - log (DBG_GEN, "\t\t\tNo name identifying the event sound provided or unable to translate name to path.\n"); + mylog (DBG_GEN, "\t\tFailed to load event sound:\n"); + mylog (DBG_GEN, "\t\t\tNo name identifying the event sound provided or unable to translate name to path.\n"); #endif } @@ -408,7 +408,7 @@ void xmlParseSecondPassEnd (void *data, */ if (!parserLoadEventSndDir (info->name, info->path)) { - log (DBG_GEN, "Error loading sounds from: %s\n", info->path); + mylog (DBG_GEN, "Error loading sounds from: %s\n", info->path); return; } @@ -432,8 +432,8 @@ void xmlParseSecondPassEnd (void *data, if (info->name == NULL) { #if DEBUG_LEVEL & DBG_GEN - log (DBG_GEN, "Failed to load state sound:\n"); - log (DBG_GEN, "\tNo name identifying the state sound provided.\n"); + mylog (DBG_GEN, "Failed to load state sound:\n"); + mylog (DBG_GEN, "\tNo name identifying the state sound provided.\n"); #endif return; @@ -469,8 +469,8 @@ void xmlParseSecondPassEnd (void *data, else if (!strcasecmp (tag_name, XML_THEME_TOKEN)) { #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "Finished Loading theme. Resuming configuration parsing...\n"); - log (DBG_SETUP, "\n"); + mylog (DBG_SETUP, "Finished Loading theme. Resuming configuration parsing...\n"); + mylog (DBG_SETUP, "\n"); #endif } @@ -492,7 +492,7 @@ void xmlParseSecondPassChar (void *data, info->name = (char *)malloc (strlen (string) + 1); strcpy (info->name, string); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tName: [%s]\n", string); + mylog (DBG_SETUP, "\t\tName: [%s]\n", string); #endif } @@ -500,17 +500,17 @@ void xmlParseSecondPassChar (void *data, info->path = xmlThemeLookupTransPath (string); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tSound: [%s]\n", string); + mylog (DBG_SETUP, "\t\tSound: [%s]\n", string); if (info->path) - log (DBG_SETUP, "\t\tTranslated -> [%s]\n", info->path); + mylog (DBG_SETUP, "\t\tTranslated -> [%s]\n", info->path); else - log (DBG_SETUP, "\t\tTranslated -> [(null)]\n"); + mylog (DBG_SETUP, "\t\tTranslated -> [(null)]\n"); #endif } #if DEBUG_LEVEL & DBG_SETUP else if (!strcasecmp (info->current_tag, XML_DESCRIPTION_TOKEN)) - log (DBG_SETUP, "\t\tDescription: [%s]\n", string); + mylog (DBG_SETUP, "\t\tDescription: [%s]\n", string); #endif @@ -523,13 +523,13 @@ void xmlParseSecondPassChar (void *data, strcpy (info->name, string); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\tName: [%s]\n", string); + mylog (DBG_SETUP, "\t\tName: [%s]\n", string); #endif } #if DEBUG_LEVEL & DBG_SETUP else if (!strcasecmp (info->current_tag, XML_DESCRIPTION_TOKEN)) - log (DBG_SETUP, "\t\tDescription: [%s]\n", string); + mylog (DBG_SETUP, "\t\tDescription: [%s]\n", string); #endif } @@ -550,8 +550,8 @@ void xmlParseSecondPassChar (void *data, info->h_bound = strtod (string, NULL); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\t\tLower bound: [%lf]\n", info->l_bound); - log (DBG_SETUP, "\t\t\tUpper bound: [%lf]\n", info->h_bound); + mylog (DBG_SETUP, "\t\t\tLower bound: [%lf]\n", info->l_bound); + mylog (DBG_SETUP, "\t\t\tUpper bound: [%lf]\n", info->h_bound); #endif } @@ -560,7 +560,7 @@ void xmlParseSecondPassChar (void *data, info->fade = strtod (string, NULL); #if DEBUG_LEVEL & DBG_SETUP - log (DBG_SETUP, "\t\t\tFade: [%lf]\n", info->fade); + mylog (DBG_SETUP, "\t\t\tFade: [%lf]\n", info->fade); #endif } @@ -570,9 +570,9 @@ void xmlParseSecondPassChar (void *data, #if DEBUG_LEVEL & DBG_SETUP if (info->path) - log (DBG_SETUP, "\t\t\tAdding sound from: [%s]\n", info->path); + mylog (DBG_SETUP, "\t\t\tAdding sound from: [%s]\n", info->path); else - log (DBG_SETUP, "\t\t\tLookup on sound [%s] failed.\n", info->path); + mylog (DBG_SETUP, "\t\t\tLookup on sound [%s] failed.\n", info->path); #endif }