#include <fcntl.h>
#include <stdio.h>
#include <ctype.h>
-#include <time.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
#include <signal.h>
#include <errno.h>
#include <syslog.h>
fp = fopen("./network/filterlist", "r");
if (fp == NULL)
return;
- while (fgets(sbuf, 256, fp) != NULL) {
+ while (fgets(sbuf, sizeof sbuf, fp) != NULL) {
if (sbuf[0] != '#') {
sbuf[strlen(sbuf) - 1] = 0;
fbuf = (struct filterlist *)
int valid_msg;
/* temp file names */
- strcpy(tname, tmpnam(NULL));
- strcpy(iname, tmpnam(NULL));
+ sprintf(tname, "%s.netproc.%d", tmpnam(NULL), __LINE__);
+ sprintf(iname, "%s.netproc.%d", tmpnam(NULL), __LINE__);
load_filterlist();
{
struct msglist *cmptr;
FILE *mmfp;
- char fbuf[128];
+ char fbuf[1024];
int a;
int msgs_spooled = 0;
long msg_len;
}
/* download the message from the server... */
mmfp = tmpfile();
+ if (mmfp == NULL) {
+ syslog(LOG_NOTICE, "tmpfile() failed: %s\n",
+ strerror(errno) );
+ }
sprintf(buf, "MSG3 %ld", cmptr->m_num);
serv_puts(buf);
serv_gets(buf);
char tempflnm[64];
char buf[256];
struct msglist *cmlist = NULL;
+ struct msglist *cmlast = NULL;
struct rmlist *crmlist = NULL;
struct rmlist *rmptr, *rmptr2;
- struct msglist *cmptr, *cmptr2;
+ struct msglist *cmptr;
FILE *sysflfp, *tempflfp;
- int outgoing_msgs;
+ int outgoing_msgs = 0;
long thismsg;
- strcpy(tempflnm, tmpnam(NULL));
+ sprintf(tempflnm, "%s.netproc.%d", tmpnam(NULL), __LINE__);
tempflfp = fopen(tempflnm, "w");
if (tempflfp == NULL)
return;
cmptr->m_num = thismsg;
strcpy(cmptr->m_rmname, rmptr->rm_name);
- if (cmlist == NULL)
+ if (cmlist == NULL) {
cmlist = cmptr;
+ }
else {
- cmptr2 = cmlist;
- while (cmptr2->next != NULL)
- cmptr2 = cmptr2->next;
- cmptr2->next = cmptr;
+ cmlast->next = cmptr;
}
+ cmlast = cmptr;
+ ++outgoing_msgs;
}
} else { /* print error from "msgs all" */
syslog(LOG_ERR, "%s", buf);
}
}
- outgoing_msgs = 0;
- cmptr2 = cmlist; /* this loop counts the messages */
- while (cmptr2 != NULL) {
- ++outgoing_msgs;
- cmptr2 = cmptr2->next;
- }
syslog(LOG_NOTICE, "%d messages to be spooled to %s",
outgoing_msgs, sysname);
/*
* Spool out the messages, but only if there are any.
*/
- if (outgoing_msgs != 0)
+ if (outgoing_msgs != 0) {
outgoing_msgs = spool_out(cmlist, tempflfp, sysname);
- syslog(LOG_NOTICE, "%d messages actually spooled",
- outgoing_msgs);
+ }
+
+ syslog(LOG_NOTICE, "%d messages actually spooled", outgoing_msgs);
/*
* Deallocate list of spooled messages.