if ((x=access(_PATH_LOG,W_OK))) {  if ( (x=startDaemon()) ==-1) { logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo)); logData[logEntries]= (*logEnt); logEntries++; } else { if (logEntries>0) { for (x=0;x<logEntries;x++) { openlog(logData[x].cmd,0,logData[x].fac); syslog(logData[x].pri,"%s",logData[x].line); closelog(); } free(logData); logEntries = 0; } openlog(logEnt->cmd,0,logEnt->fac); syslog(logEnt->pri,"%s",logEnt->line); closelog();
if ( (stat(_PATH_LOG,&statbuf)==-1) && ((x=startDaemon())) ) { logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo)); logData[logEntries]= (*logEnt); logEntries++; } else { if (logEntries>0) { for (x=0;x<logEntries;x++) { openlog(logData[x].cmd,0,logData[x].fac); syslog(logData[x].pri,"%s",logData[x].line); closelog(); } free(logData); logEntries = 0;
int logLine(struct logInfo *logEnt) {    /* Logs a line... somewhere. */    int x;        /* Don't log empty or null lines */    if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0;    if ((x=access(_PATH_LOG,W_OK))) {       /* syslog isn't running, so start something... */       if ( (x=startDaemon()) ==-1) {	    logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo));	    logData[logEntries]= (*logEnt);	    logEntries++;	} else {	   if (logEntries>0) {	      for (x=0;x<logEntries;x++) {		 openlog(logData[x].cmd,0,logData[x].fac);		 syslog(logData[x].pri,"%s",logData[x].line);		 closelog();	      }	      free(logData);	      logEntries = 0;	   }	   openlog(logEnt->cmd,0,logEnt->fac);	   syslog(logEnt->pri,"%s",logEnt->line);	   closelog();	}    } else {       if (logEntries>0) {	  for (x=0;x<logEntries;x++) {	     openlog(logData[x].cmd,0,logData[x].fac);	     printf("flushing %s\n",logData[x].line);	     syslog(logData[x].pri,"%s",logData[x].line);	     closelog();	  }	  free(logData);	  logEntries = 0;       }       openlog(logEnt->cmd,0,logEnt->fac);       syslog(logEnt->pri,"%s",logEnt->line);       closelog();    }    return 0;}