time(&nowtime);
localtime_r(&nowtime, &tm);
- strftime(datetime, sizeof(datetime), "%a %b %d %X %Z %Y ", &tm);
+ strftime(datetime, sizeof(datetime), "%a %b %d %X %Z %Y ", &tm);
write(event_fd, datetime, strlen(datetime));
lm = strlen(msg);
- if (msg[lm-1] != '\n')
- msg[lm++] = '\n';
+ if (msg[lm-1] != '\n')
+ msg[lm++] = '\n';
write(event_fd, msg, lm);
}
}
#define MAXLE 50 /* truncate file when this many events */
/*
- * If the EVENTS file exceeds MAXLE records, truncate it.
+ * If the EVENTS file exceeds MAXLE records, truncate it.
*
* Returns:
*
int trunc = FALSE;
FILE *events_file;
int stat = 0;
-
+
if ((events_file = fopen(ups->eventfile, "r+")) == NULL)
return 0;
for (i=0; i<NLE; i++)
*buf = 0;
/* Put records in single buffer in correct order */
for (j=0; j < nrec; j++) {
- strcat(buf, le[i++]);
+ strcat(buf, le[i++]);
if (i >= NLE)
i = 0;
}
extern UPSINFO myUPS;
extern int shm_OK;
-/*
+/*
* Fill the Events list box with the last events
- *
+ *
*/
void FillEventsBox(HWND hwnd, int idlist)
{
char buf[1000];
int len;
FILE *events_file;
-
+
if (!shm_OK || myUPS.eventfile[0] == 0 ||
- (events_file = fopen(myUPS.eventfile, "r")) == NULL) {
- SendDlgItemMessage(hwnd, idlist, LB_ADDSTRING, 0,
- (LONG)"Events not available");
+ (events_file = fopen(myUPS.eventfile, "r")) == NULL) {
+ SendDlgItemMessage(hwnd, idlist, LB_ADDSTRING, 0,
+ (LONG)"Events not available");
return;
}
while (fgets(buf, sizeof(buf), events_file) != NULL) {
len = strlen(buf);
/* strip trailing cr/lfs */
- while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r'))
+ while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r'))
buf[--len] = 0;
SendDlgItemMessage(hwnd, idlist, LB_ADDSTRING, 0, (LONG)buf);
}