home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
PPPBCKP
/
SRC
/
SRC15B99.ZIP
/
EXP.CPP
< prev
next >
Wrap
Text File
|
1999-01-28
|
70KB
|
2,439 lines
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <ctype.h>
#include <mem.h>
#include <conio.h>
#include <io.h>
#include <share.h>
#include <errno.h>
#include <dir.h>
#include <time.h>
#include <alloc.h>
#include <process.h>
#include <direct.h>
#include "vardec.h"
#include "net.h"
#include "retcode.h"
#include "version.h"
#define WAIT_TIME 10
#define TRIES 100
#define SHARE_LEVEL 10
struct msghdr {
char fromUserName[205];
char toUserName[81];
char subject[81];
char dateTime[81];
};
typedef struct {
char ownername[60];
char subtype[8];
char opttext[30];
} MAILLISTREC;
MAILLISTREC *maillist;
configrec syscfg;
char net_name[31], postmaster[31], net_data[MAXPATH];
char POPNAME[21], REPLYTO[81], DOMAIN[81], deftagfile[MAXPATH], tagfile[MAXPATH], maindir[MAXPATH], spamname[81];
unsigned short net_sysnum, defuser, use_alias, usermail, instance, spam;
unsigned curuser, num_users;
int nlists = 0, jdater, DIGEST;
char alphasubtype[8];
unsigned long cur_daten;
struct ts_os_ver {
int maj;
int min;
};
#define DOS 0
#define OS2 1
#define DV 2
#define WINS 3
#define WIN3 4
#define MT_DOS 0x01
#define MT_OS2 0x02
#define MT_DV 0x04
#define MT_WINS 0x08
#define MT_WIN3 0x10
struct ts_os_ver t_os_ver[5];
int t_os_type;
int t_os;
char t_os_name[41];
int detect_multitask(void)
{
union REGS t_regs;
t_os_type = 0;
t_os = 0;
if (_osmajor < 10) {
t_os_ver[DOS].maj = _osmajor;
t_os_ver[DOS].min = _osminor;
t_os_type = t_os_type | MT_DOS;
strcpy(t_os_name, "DOS");
} else {
t_os_type = t_os_type | MT_OS2;
t_os_ver[OS2].maj = _osmajor / 10;
t_os_ver[OS2].min = _osminor;
if (t_os_ver[OS2].maj == 3) {
strcpy(t_os_name, "OS/2 Warp");
} else {
strcpy(t_os_name, "OS/2");
}
}
t_regs.x.ax = 0x4680;
int86(0x2F, &t_regs, &t_regs);
if (t_regs.x.ax == 0x0000) {
t_os_ver[WINS].maj = 3;
t_os_ver[WINS].min = 0;
t_os_type = t_os_type | MT_WINS;
} else {
t_regs.x.ax = 0x1600;
int86(0x2F, &t_regs, &t_regs);
switch (t_regs.h.al) {
case 0x00:
case 0x80:
case 0x01:
case 0xFF:
break;
default:
t_os_type = t_os_type | MT_WIN3;
t_os_ver[WIN3].maj = t_regs.h.al;
t_os_ver[WIN3].min = t_regs.h.ah;
if (t_os_ver[WIN3].maj == 4) {
strcpy(t_os_name, "Windows 95");
t_os_ver[WIN3].maj = t_os_ver[WIN3].maj - 3;
} else {
strcpy(t_os_name, "Windows");
}
break;
}
}
t_regs.x.cx = 0x4445;
t_regs.x.dx = 0x5351;
t_regs.x.ax = 0x2B01;
intdos(&t_regs, &t_regs);
if (t_regs.h.al != 0xFF) {
t_os_type = t_os_type | MT_DV;
t_os_ver[DV].maj = t_regs.h.bh;
t_os_ver[DV].min = t_regs.h.bl;
strcpy(t_os_name, "DESQview");
}
if (t_os_type & MT_DOS)
t_os = DOS;
if (t_os_type & MT_DV)
t_os = DV;
if (t_os_type & MT_WINS)
t_os = WINS;
if (t_os_type & MT_WIN3)
t_os = WIN3;
if (t_os_type & MT_OS2)
t_os = OS2;
return (t_os - 1);
}
void giveup_timeslice(void)
{
union REGS t_regs;
switch (t_os) {
case DOS:
break;
case OS2:
case WIN3:
case WINS:
t_regs.x.ax = 0x1680;
int86(0x2f, &t_regs, &t_regs);
break;
case DV:
t_regs.x.ax = 0x1000;
int86(0x15, &t_regs, &t_regs);
break;
}
}
int sh_write(int handle, void *buffer, unsigned long len)
{
if (handle == -1) {
return (-1);
}
return (write(handle, buffer, (unsigned) len));
}
int sh_open(char *path, int file_access, unsigned fmode)
{
int handle, count, share;
char drive[MAXDRIVE], dir[MAXDIR], file[MAXFILE], ext[MAXEXT];
if ((file_access & O_RDWR) || (file_access & O_WRONLY) || (fmode & S_IWRITE)) {
share = SH_DENYRW;
} else {
share = SH_DENYWR;
}
handle = open(path, file_access | share, fmode);
if (handle < 0) {
count = 1;
fnsplit(path, drive, dir, file, ext);
if (access(path, 0) != -1) {
delay(WAIT_TIME);
handle = open(path, file_access | share, fmode);
while (((handle < 0) && (errno == EACCES)) && (count < TRIES)) {
if (count % 2)
delay(WAIT_TIME);
else
giveup_timeslice();
count++;
handle = open(path, file_access | share, fmode);
}
}
}
return (handle);
}
int sh_open1(char *path, int access)
{
unsigned fmode;
fmode = 0;
if ((access & O_RDWR) || (access & O_WRONLY))
fmode |= S_IWRITE;
if ((access & O_RDWR) || (access & O_RDONLY))
fmode |= S_IREAD;
return (sh_open(path, access, fmode));
}
int sh_close(int f)
{
if (f != -1)
close(f);
return (-1);
}
int sh_read(int handle, void *buf, unsigned len)
{
if (handle == -1) {
return (-1);
}
return (read(handle, buf, len));
}
long sh_lseek(int handle, long offset, int fromwhere)
{
if (handle == -1) {
return (-1L);
}
return (lseek(handle, offset, fromwhere));
}
FILE *fsh_open(char *path, char *fmode)
{
FILE *f;
int count, share, md, fd;
char drive[MAXDRIVE], dir[MAXDIR], file[MAXFILE], ext[MAXEXT];
share = SH_DENYWR;
md = 0;
if (((char *) _fstrchr(fmode, 'w')) != NULL) {
share = SH_DENYRD;
md = O_RDWR | O_CREAT | O_TRUNC;
} else
if (((char *) _fstrchr(fmode, 'a')) != NULL) {
share = SH_DENYRD;
md = O_RDWR | O_CREAT;
} else {
md = O_RDONLY;
}
if (((char *) _fstrchr(fmode, 'b')) != NULL) {
md |= O_BINARY;
}
if (((char *) _fstrchr(fmode, '+')) != NULL) {
md &= ~O_RDONLY;
md |= O_RDWR;
share = SH_DENYRD;
}
fd = open(path, md | share, S_IREAD | S_IWRITE);
if (fd < 0) {
count = 1;
fnsplit(path, drive, dir, file, ext);
if ((access(path, 0)) != -1) {
delay(WAIT_TIME);
fd = open(path, md | share, S_IREAD | S_IWRITE);
while (((fd < 0) && (errno == EACCES)) && (count < TRIES)) {
delay(WAIT_TIME);
count++;
fd = open(path, md | share, S_IREAD | S_IWRITE);
}
}
}
if (fd > 0) {
if (((char *) _fstrchr(fmode, 'a')) != NULL)
sh_lseek(fd, 0L, SEEK_END);
f = fdopen(fd, fmode);
if (!f) {
close(fd);
}
} else
f = 0;
return (f);
}
size_t fsh_write(void *ptr, size_t size, size_t n, FILE * stream)
{
if (stream == NULL) {
return (0);
}
return (fwrite(ptr, size, n, stream));
}
int exist(char *s)
{
int i;
struct ffblk ff;
i = findfirst(s, &ff, 0);
if (i)
return (0);
else
return (1);
}
char *stripspace(char *str)
{
char *obuf, *nbuf;
if (str) {
for (obuf = str, nbuf = str; *obuf; ++obuf) {
if (!isspace(*obuf))
*nbuf++ = *obuf;
}
*nbuf = NULL;
}
return (str);
}
static unsigned char *trimstr1(unsigned char *s)
{
int i;
static char *whitespace = " \r\n\t";
i = (int) strlen(s);
while ((i > 0) && ((char *) _fstrchr(whitespace, s[i - 1]) != NULL))
--i;
while ((i > 0) && ((char *) _fstrchr(whitespace, *s) != NULL)) {
memmove(s, s + 1, --i);
}
s[i] = 0;
return (s);
}
void output(char *fmt,...)
{
va_list v;
char s[255];
va_start(v, fmt);
vsprintf(s, fmt, v);
va_end(v);
fputs(s, stderr);
}
int log_it(int display, char *fmt,...)
{
va_list v;
char s[255], fn[MAXPATH];
FILE *fp;
sprintf(fn, "%sNEWS.LOG", net_data);
if ((fp = fsh_open(fn, "at")) == NULL) {
output("\n ! Error accessing %s.", fn);
return 1;
}
va_start(v, fmt);
vsprintf(s, fmt, v);
va_end(v);
fputs(s, fp);
fclose(fp);
if (display)
fputs(s, stderr);
return 0;
}
void get_list_addr(char *list_addr, char *list_name)
{
char *ss, fn[MAXPATH], s[101], buf[60];
int found;
FILE *fp;
found = 0;
*list_addr = 0;
sprintf(fn, "%sACCT.INI", net_data);
if ((fp = fsh_open(fn, "rt")) != NULL) {
while ((fgets(s, 100, fp)) && (!found)) {
if (strnicmp(s, "LIST", 4) == 0) {
ss = strtok(s, "=");
if (s[4] == '-') {
strcpy(buf, &s[5]);
trimstr1(buf);
if (stricmp(buf, list_name) == 0) {
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strcpy(list_addr, ss);
found = 1;
}
}
}
}
if (fp != NULL)
fclose(fp);
}
}
void properize(char *s)
{
int i;
for (i = 0; i < strlen(s); i++) {
if ((i == 0) || ((i > 0) && ((s[i - 1] == ' ') || (s[i - 1] == '.') ||
((s[i - 1] == 'c') && (s[i - 2] == 'M')) || ((s[i - 1] == 'c') &&
(s[i - 2] == 'a') && (s[i - 3] == 'M')) || (s[i - 1] == '-') ||
(s[i - 1] == '_') || ((s[i - 1] == '\'') && (s[i - 2] == 'O'))))) {
s[i] = toupper(s[i]);
} else
s[i] = tolower(s[i]);
}
}
int num_to_name(char *user_addr, char *user_name, int whichuser, int alias)
{
char *ss, fn[MAXPATH], s[101], buf[60];
int i, userfile, num_users, found;
long pos;
FILE *fp;
userrec ur;
if (alias == 2) {
strcpy(user_name, "Anonymous");
strcpy(user_addr, "user@wwivbbs.org");
return 1;
}
found = 0;
if (*user_addr) {
*user_addr = 0;
sprintf(fn, "%sACCT.INI", net_data);
if ((fp = fsh_open(fn, "rt")) != NULL) {
while ((fgets(s, 100, fp)) && (!found)) {
if (strnicmp(s, "USER", 4) == 0) {
ss = strtok(s, "=");
strcpy(buf, &s[4]);
if (isdigit(buf[0])) {
i = atoi(buf);
if (i == whichuser) {
ss = strtok(NULL, "\r\n");
if (ss) {
trimstr1(ss);
strcpy(user_addr, ss);
found = 1;
}
}
}
}
}
if (fp != NULL)
fclose(fp);
}
}
found = 0;
sprintf(fn, "%sUSER.LST", syscfg.datadir);
userfile = sh_open1(fn, O_RDONLY | O_BINARY);
if (userfile < 0) {
log_it(1, "\n ■ Cannot open %s.", fn);
return (found);
}
num_users = ((int) (filelength(userfile) / sizeof(userrec)));
if (whichuser > num_users) {
log_it(1, "\n ■ User #%d out of range.", whichuser);
return (found);
}
pos = ((long) sizeof(userrec) * ((long) whichuser));
lseek(userfile, pos, SEEK_SET);
sh_read(userfile, &ur, sizeof(userrec));
if (ur.realname[0] == 0)
log_it(1, "\n ■ User #%d has blank real name field!", whichuser);
else {
if (ur.inact == inact_deleted)
log_it(1, "\n ■ User #%d is marked as deleted!", whichuser);
else {
if (!alias)
strcpy(user_name, ur.realname);
else {
strcpy(user_name, ur.name);
properize(user_name);
}
found = 1;
}
}
sh_close(userfile);
return (found);
}
void parse_net_ini(void)
{
char s[MAXPATH], origline[121], line[121], *ss, inlist = 0;
FILE *fp;
long fptr;
defuser = 1;
use_alias = 1;
usermail = 1;
nlists = 0;
maillist = NULL;
*REPLYTO = 0;
sprintf(s, "%sNET.INI", maindir);
if ((fp = fsh_open(s, "rt")) == NULL) {
log_it(1, "\n ■ Unable to open %s.", s);
return;
}
while (fgets(line, 80, fp)) {
ss = NULL;
strcpy(origline, line);
stripspace(line);
if ((line[0] == ';') || (line[0] == '\n') || (line[0] == 0))
continue;
if (strnicmp(line, "[MAILLIST]", 10) == 0) {
fptr = ftell(fp);
while ((fgets(line, 80, fp)) && (line[0] != '[')) {
if ((line[0] != '[') && (line[0] != ';') && (line[0] != 0) &&
(strnicmp(line, "DIGEST", 6) != 0))
++nlists;
}
fseek(fp, fptr, SEEK_SET);
maillist = (MAILLISTREC *) malloc((nlists + 1) * sizeof(MAILLISTREC));
if (maillist == NULL)
log_it(1, "\n ■ Not enough memory to process %d mailing lists.", nlists);
else
inlist = 1;
nlists = 0;
continue;
} else
if (line[0] == '[') {
inlist = 0;
continue;
}
if (inlist) {
if ((line[0] != ';') && (line[0] != 0) && (strnicmp(line, "DIGEST", 6) != 0)) {
ss = strtok(line, "\"");
trimstr1(ss);
if (*ss) {
ss = strtok(NULL, "\"");
if (*ss) {
strncpy(maillist[nlists].opttext, ss, 29);
maillist[nlists].opttext[30] = '\0';
} else
maillist[nlists].opttext[0] = '\0';
}
ss = strtok(line, "*\n");
trimstr1(ss);
strcpy(maillist[nlists].ownername, ss);
ss = strtok(NULL, "\"\n");
trimstr1(ss);
if (*ss) {
strlwr(maillist[nlists].ownername);
strcpy(maillist[nlists++].subtype, ss);
} else
log_it(1, "\n ■ Missing *subtype in maillist for %s.",
maillist[nlists].ownername);
} else {
if (strnicmp(line, "DIGEST", 6) == 0) {
ss = strtok(line, "=");
if (*ss) {
ss = strtok(NULL, "\r\n");
trimstr1(ss);
if ((ss[0] == 'y') || (ss[0] == 'Y'))
DIGEST = 1;
}
}
}
continue;
}
if (strnicmp(line, "POSTMASTER", 10) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
if (ss)
defuser = atoi(ss);
}
continue;
}
if (strnicmp(line, "SPAMCONTROL", 11) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
if ((ss[0] == 'y') || (ss[0] == 'Y'))
spam = 1;
}
continue;
}
if (strnicmp(line, "USERMAIL", 8) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
if ((ss[0] == 'n') || (ss[0] == 'N'))
usermail = 0;
}
continue;
}
if (strnicmp(line, "SPAMADDRESS", 9) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
trimstr1(ss);
strcpy(spamname, ss);
if (stricmp(spamname, "DEFAULT") == 0)
strcpy(spamname, "WWIV_BBS@nospam.net");
}
continue;
}
if (strnicmp(line, "REPLYTO", 7) == 0) {
ss = strtok(origline, "=");
if (ss) {
ss = strtok(NULL, "\n");
trimstr1(ss);
strcpy(REPLYTO, ss);
}
continue;
}
if (strnicmp(line, "SIGNATURE", 9) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
trimstr1(ss);
strcpy(tagfile, ss);
if (!exist(tagfile)) {
log_it(1, "\n ■ Default signature file %s not found!", tagfile);
tagfile[0] = 0;
}
strcpy(deftagfile, tagfile);
}
continue;
}
if (strnicmp(line, "REALNAME", 8) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
if ((ss[0] == 'y') || (ss[0] == 'Y'))
use_alias = 0;
}
}
}
num_to_name(0, postmaster, defuser, 1);
if (fp != NULL)
fclose(fp);
return;
}
unsigned char *strrep(char *str, char old, char New)
{
int i;
for (i = 0; str[i]; i++)
if (str[i] == old)
str[i] = New;
return (str);
}
char *stristr(char *String, char *Pattern)
{
char *pptr, *sptr, *start;
unsigned int slen, plen;
for (start = String, pptr = Pattern, slen = strlen(String),
plen = strlen(Pattern); slen >= plen; start++, slen--) {
while (toupper(*start) != toupper(*Pattern)) {
start++;
slen--;
if (slen < plen)
return (NULL);
}
sptr = start;
pptr = Pattern;
while (toupper(*sptr) == toupper(*pptr)) {
sptr++;
pptr++;
if ('\0' == *pptr)
return (start);
}
}
return (NULL);
}
unsigned int name_to_num(char *name)
{
int userfile, usernum;
userrec ur;
long pos;
char fn[MAXPATH], ur_name[60], ur_realname[60];
if ((stristr(name, "Multiple recipients of") != NULL) || (strlen(name) == 0))
return 0;
sprintf(fn, "%sM%s.NET", net_data, name);
if (exist(fn)) {
log_it(1, "\n ■ Matched \"%s\" mailing list.", name);
strcpy(alphasubtype, name);
return (unsigned) (65535L);
}
sprintf(fn, "%sUSER.LST", syscfg.datadir);
userfile = sh_open1(fn, O_RDONLY | O_BINARY);
if (userfile < 0) {
log_it(1, "\n ■ Cannot open %s", fn);
return (0);
} else
log_it(1, "\n ■ Searching for user \"%s\"...", name);
num_users = ((int) (filelength(userfile) / sizeof(userrec)));
for (usernum = 1; usernum < num_users; usernum++) {
pos = ((long) sizeof(userrec) * ((long) usernum));
lseek(userfile, pos, SEEK_SET);
sh_read(userfile, &ur, sizeof(userrec));
strcpy(ur_realname, ur.realname);
strrep(ur_realname, ' ', '_');
strcpy(ur_name, ur.name);
strrep(ur_name, ' ', '_');
if ((strcmpi(ur.realname, name) == 0) || (strcmpi(ur_realname, name) == 0) ||
(strcmpi(ur.name, name) == 0) || (strcmpi(ur_name, name) == 0)) {
if (ur.inact == inact_deleted) {
log_it(1, " user #%d is deleted account.", usernum);
usernum = 0;
break;
} else {
log_it(1, " matched to user #%d.", usernum);
break;
}
}
}
userfile = sh_close(userfile);
if (usernum >= num_users) {
log_it(1, "... no match found.");
return 0;
}
return (usernum);
}
char *find_name(char *name)
{
char *ss, *ss1, hold[81];
int focus = 0;
curuser = 0;
strcpy(hold, name);
ss1 = NULL;
if ((ss = _fstrchr(name, '(')) != NULL) {
ss1 = strtok(name, "(");
ss1 = strtok(NULL, ")");
} else
if ((ss = _fstrchr(name, '\"')) != NULL) {
ss1 = strtok(ss, "\"");
} else
if ((ss = _fstrchr(name, '<')) != NULL) {
ss1 = strtok(name, "<");
} else
focus = 1;
trimstr1(ss1);
if (focus) {
stripspace(hold);
curuser = name_to_num(hold);
} else
curuser = name_to_num(ss1);
if (curuser == 0)
return ('\0');
else
if (curuser == ((unsigned) 65535L))
return (alphasubtype);
else
return (ss1);
}
char *find_focus(char *name)
{
char *ss, focus[121];
int i;
ss = name;
i = strcspn(ss, "<");
if (i < strlen(ss)) {
strcpy(focus, &ss[i+1]);
ss = strtok(focus, ">");
trimstr1(ss);
} else {
i = strcspn(ss, "(");
if (i < strlen(ss)) {
strcpy(focus, ss);
ss = strtok(focus, "(");
trimstr1(ss);
}
}
return (ss);
}
void name_packet(char *pktname)
{
int ok;
struct stat info;
unsigned i;
ok = 0;
for (i = 0; ((i < 1000) && (!ok)); i++) {
sprintf(pktname, "%sP0-%u.%3.3hu", net_data, i, instance);
if (stat(pktname, &info) == -1)
ok = 1;
}
}
void name_bad(char *newfn)
{
int ok;
struct stat info;
unsigned i;
ok = 0;
for (i = 0; ((i < 1000) && (!ok)); i++) {
sprintf(newfn, "%sINBOUND\\UNK-%3.3u.MSG", net_data, i);
if (stat(newfn, &info) == -1)
ok = 1;
}
}
void name_check(char *newfn)
{
int ok;
struct stat info;
unsigned i;
ok = 0;
for (i = 0; ((i < 1000) && (!ok)); i++) {
sprintf(newfn, "%sINBOUND\\CHK-%3.3u.MSG", net_data, i);
if (stat(newfn, &info) == -1)
ok = 1;
}
}
#define FROM_RETURN 0x01
#define FROM_FROM 0x02
#define FROM_REPLY 0x04
int import(char *fn)
{
char s[513], s1[121], pktname[MAXPATH], msgdate[61], *ss, *ss1, *p, *id, *name;
char alphatype[21], recvdate[81], realfrom[205];
int i, f, from, match, subj, intext, done, tolist, mailuser, bounce;
long textlen, reallen;
struct msghdr mh;
net_header_rec nh;
FILE *fp;
tolist = 0;
intext = 0;
mailuser = 0;
bounce = 0;
f = sh_open1(fn, O_RDONLY | O_BINARY);
if (f < 0)
return (1);
textlen = filelength(f);
if (textlen > 32767L) {
sh_close(f);
log_it(1, "\n ■ Skipping UU/Base64 %s.", fn);
return (1);
}
p = (char *) malloc((int) (textlen + 1));
if (p == NULL) {
sh_close(f);
log_it(1, "\n ■ Unable to allocate %ld bytes.", textlen);
return (1);
}
sh_read(f, (void *) p, (int) textlen);
sh_close(f);
nh.tosys = net_sysnum;
nh.fromsys = 32767;
nh.fromuser = 0;
nh.touser = defuser;
nh.main_type = main_type_email;
nh.minor_type = 0;
nh.list_len = 0;
++cur_daten;
nh.daten = cur_daten;
strncpy(msgdate, ctime(&(time_t) nh.daten), 24);
msgdate[24] = '\0';
sprintf(recvdate, "0RReceived: PPP Project %s on %s\r\n", VERSION, msgdate);
strcat(msgdate, "\r\n");
nh.method = 0;
strcpy(mh.fromUserName, "Unknown");
strcpy(mh.toUserName, "Unknown");
strcpy(mh.subject, "None");
realfrom[0] = 0;
if ((fp = fsh_open(fn, "rb")) == NULL) {
free(p);
return 1;
}
match = subj = done = from = 0;
while ((!done) && (fgets(s, 254, fp))) {
if (s[0] == 4) {
ss = strtok(s, "R");
ss = strtok(NULL, "\r\n");
if (ss == NULL)
s[0] = 0;
else
strcpy(s, ss);
} else
intext = 1;
if (!intext) {
if (stristr(s,"x-Mailer: Internet Rex") !=NULL) {
fclose(fp);
free(p);
return (1);
}
if (strncmpi(s, "x-wwiv-user", 11) == 0) {
ss1 = strtok(s, "#");
if (ss1) {
ss1 = strtok(NULL, "\r\n");
mailuser = atoi(ss1);
}
} else
if (strncmpi(s, "x-wwiv-list", 11) == 0) {
ss1 = strtok(s, "*");
if (ss1) {
ss1 = strtok(NULL, "\r\n");
strcpy(alphatype, ss1);
nh.main_type = main_type_new_post;
nh.minor_type = 0;
nh.touser = 0;
mailuser = -1;
tolist = 1;
}
} else
if (strncmpi(s, "from:", 5) == 0)
from = FROM_FROM;
else
if (strncmpi(s, "return-path:", 12) == 0)
from = FROM_RETURN;
else
if (strncmpi(s, "sender:", 7) == 0)
from = FROM_RETURN;
else
if (strncmpi(s, "x-sender:", 9) == 0)
from = FROM_RETURN;
else
if (strncmpi(s, "x-to:", 5) == 0)
from = FROM_RETURN;
else
if (strncmpi(s, "x-mailing-list:", 15) == 0)
from = FROM_RETURN;
else
if (strncmpi(s, "reply-to:", 9) == 0)
from = FROM_REPLY;
else
if (strncmpi(s, "x-reply-to:", 11) == 0)
from = FROM_REPLY;
else
if (s[0] != ' ')
from = 0;
if (from) {
if (s[0] != ' ') {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
}
trimstr1(ss);
}
if (from && (strchr(ss, '@') != NULL)) {
if (from && (nh.main_type == main_type_email)) {
strcpy(s1, ss);
strlwr(s1);
for (i = 0; (i < nlists) && (nh.main_type == main_type_email); i++) {
if (stristr(s1, maillist[i].ownername) != NULL) {
if (atoi(maillist[i].subtype)) {
nh.main_type = main_type_pre_post;
nh.minor_type = atoi(maillist[i].subtype);
} else {
nh.main_type = main_type_new_post;
nh.minor_type = 0;
strcpy(alphatype, maillist[i].subtype);
}
strcpy(alphasubtype, maillist[i].subtype);
nh.touser = 0;
from = 0;
}
}
}
if ((from > match) && ((nh.main_type == main_type_email) || (from == FROM_FROM))) {
match = from;
if (strcspn(ss, "<") != strlen(ss)) {
if ((strcspn(ss, " ")) < (strcspn(ss, "<"))) {
name = strtok(ss, "<");
trimstr1(name);
id = strtok(NULL, ">");
trimstr1(id);
sprintf(mh.fromUserName, "%s <%s>", name, id);
} else {
strncpy(mh.fromUserName, ss, 205);
trimstr1(mh.fromUserName);
if (strcspn(ss, " ") != strlen(ss))
log_it(1, "\n ! Error parsing return address \"%s\"", mh.fromUserName);
}
} else
strncpy(mh.fromUserName, ss, 205);
mh.fromUserName[190] = 0;
strcat(mh.fromUserName, "\r\n");
if (from == FROM_FROM)
strcpy(realfrom, mh.fromUserName);
}
} else
if ((strncmpi(s, "subject:", 8) == 0) && (!subj)) {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strncpy(mh.subject, ss, 81);
mh.subject[72] = 0;
subj = 1;
} else
if (strncmpi(s, "date:", 5) == 0) {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strncpy(msgdate, ss, 58);
msgdate[58] = '\0';
strcat(msgdate, "\r\n");
} else
if ((strncmpi(s, "to:", 3) == 0) || (strncmpi(s, "cc:", 3) == 0)) {
if (mailuser == 0) {
ss = strtok(s, ":");
ss = strtok(NULL, "\r\n");
strncpy(mh.toUserName, ss, 81);
mh.toUserName[80] = 0;
curuser = 0;
trimstr1(mh.toUserName);
find_name(mh.toUserName);
} else if (mailuser > 0) {
curuser = mailuser;
if (!num_to_name(0, mh.toUserName, curuser, use_alias)) {
curuser = 0;
mh.toUserName[0] = 0;
}
}
if ((stristr(mh.toUserName, "Multiple recipients of") != NULL) && (curuser != (unsigned) 65535L)) {
for (i = 0; (i < nlists) && (nh.main_type == main_type_email); i++) {
if (stristr(mh.toUserName, maillist[i].opttext) != NULL) {
if (atoi(maillist[i].subtype)) {
nh.main_type = main_type_pre_post;
nh.minor_type = atoi(maillist[i].subtype);
} else {
nh.main_type = main_type_new_post;
nh.minor_type = 0;
strcpy(alphatype, maillist[i].subtype);
}
strcpy(alphasubtype, maillist[i].subtype);
nh.touser = 0;
}
}
}
if ((curuser == (unsigned) 65535L) && (nh.main_type == main_type_email)) {
strcpy(alphatype, alphasubtype);
nh.main_type = main_type_new_post;
nh.minor_type = 0;
nh.touser = 0;
tolist = 1;
} else
if ((mh.toUserName[0] == 0) || (curuser == 0)) {
nh.touser = defuser;
strcpy(mh.toUserName, postmaster);
} else {
nh.touser = curuser;
}
} else
if (strncmpi(s, "message-id:", 11) == 0) {
sprintf(s1, "%s@wwivbbs.org", POPNAME);
if (stristr(s, s1) != NULL)
bounce = 1;
} else
if (strncmpi(s, "apparently-to:", 14) == 0) {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
strncpy(mh.toUserName, ss, 81);
mh.toUserName[80] = 0;
curuser = 0;
trimstr1(mh.toUserName);
if (_fstrstr(mh.toUserName, " "))
find_name(mh.toUserName);
else
mh.toUserName[0] = 0;
if ((curuser == (unsigned) 65535L) && (nh.main_type == main_type_email)) {
strcpy(alphatype, alphasubtype);
nh.main_type = main_type_new_post;
nh.minor_type = 0;
nh.touser = 0;
tolist = 1;
} else
if ((mh.toUserName[0] == 0) || (curuser == 0)) {
nh.touser = defuser;
strcpy(mh.toUserName, postmaster);
} else
nh.touser = curuser;
}
} else
done = 1;
}
if (fp != NULL)
fclose(fp);
if (mailuser == -1) {
strcpy(alphasubtype, alphatype);
curuser = (unsigned) 65535L;
}
trimstr1(mh.fromUserName);
strcat(mh.fromUserName, "\r\n");
log_it(1, "\n ■ From : %s", mh.fromUserName);
if ((nh.main_type == main_type_pre_post) ||
(nh.main_type == main_type_new_post)) {
nh.touser = 0;
log_it(1, " ■ Post to : Sub %s", alphasubtype);
if (bounce) {
log_it(1, "\n ■ Return Post from Listserv - not reposted.");
free(p);
return (0);
}
done = 0;
for (i = 0; i < nlists; i++)
if (strcmpi(alphasubtype, maillist[i].subtype) == 0)
done = 1;
if (!done) {
sprintf(s, "%sM%s.NET", net_data, alphasubtype);
if ((fp = fsh_open(s, "rb")) == NULL)
done = -1;
strcpy(s1, find_focus(realfrom));
trimstr1(s1);
while ((done == 0) && (fgets(s, 254, fp))) {
trimstr1(s);
if (stristr(s, s1) != 0)
done = 1;
}
if (fp != NULL)
fclose(fp);
}
if (done < 1) {
log_it(1, "\n ■ No \"%s\" in M%s.NET... message not posted.",
s1, alphasubtype);
name_check(pktname);
rename(fn, pktname);
free(p);
return (0);
}
} else
log_it(1, " ■ Sent to : %s #%hd", strupr(mh.toUserName), nh.touser);
log_it(1, "\n ■ Subject : %s", mh.subject);
name_packet(pktname);
if ((fp = fsh_open(pktname, "wb")) == NULL) {
log_it(1, "\n ■ Unable to create packet %s", pktname);
free(p);
return (1);
}
nh.length = textlen + strlen(mh.fromUserName) + strlen(mh.subject)
+ strlen(msgdate) + strlen(recvdate) + 1;
if (nh.main_type == main_type_new_post)
nh.length += strlen(alphatype) + 1;
while (tolist >= 0) {
fsh_write(&nh, sizeof(net_header_rec), 1, fp);
if (nh.main_type == main_type_new_post)
fsh_write(alphatype, sizeof(char), strlen(alphatype) +1, fp);
fsh_write(mh.subject, sizeof(char), strlen(mh.subject) +1, fp);
fsh_write(mh.fromUserName, sizeof(char), strlen(mh.fromUserName), fp);
fsh_write(msgdate, sizeof(char), strlen(msgdate), fp);
fsh_write(recvdate, sizeof(char), strlen(recvdate), fp);
reallen = fsh_write(p, sizeof(char), (int) textlen, fp);
if (reallen != textlen)
log_it(1, "\n ■ Expected %ld bytes, wrote %ld bytes.", textlen, reallen);
nh.tosys = 32767;
--tolist;
}
if (fp != NULL)
fclose(fp);
free(p);
return (0);
}
char *stripcolors(char *str)
{
char *obuf, *nbuf;
if (str) {
for (obuf = str, nbuf = str; *obuf; ++obuf) {
if (*obuf == 3)
++obuf;
else
if (((*obuf < 32) && (*obuf != 9)) || (*obuf > 126))
continue;
else
*nbuf++ = *obuf;
}
*nbuf = NULL;
}
return (str);
}
void move_dead(net_header_rec * nh, char *text)
{
char fn[81];
int f;
long l, l1;
sprintf(fn, "%sDEAD.NET", net_data);
f = sh_open(fn, O_RDWR | O_BINARY | SH_DENYRW | O_CREAT, S_IREAD | S_IWRITE);
if (f > 0) {
lseek(f, 0L, SEEK_END);
l = l1 = tell(f);
write(f, (void *) nh, sizeof(net_header_rec));
l1 += sizeof(net_header_rec);
write(f, (void *) text, (int) (nh->length));
l1 += nh->length;
if (l1 != tell(f))
chsize(f, l);
f = sh_close(f);
} else
log_it(1, "\n ! Couldn't open '%s'", fn);
}
void get_subtype(int sub, char *where)
{
int ok, which;
char fn[181], s[81], net_name[21], *ss;
FILE *fp;
where[0] = 0;
which = sub;
sprintf(fn, "%sSUBS.XTR", syscfg.datadir);
if ((fp = fsh_open(fn, "r")) == NULL)
return;
ok = 0;
while (fgets(s, 80, fp)) {
if (*s == '!') {
if (which == atoi(&s[1]))
ok = 1;
}
if (ok && (*s == '$')) {
ss = strtok(s, " ");
strcpy(net_name, &ss[1]);
ss = strtok(NULL, " ");
if (fp != NULL)
fclose(fp);
if ((stricmp(net_name, "FILENET") == 0)) {
trimstr1(ss);
strcpy(where, ss);
return;
} else
return;
}
}
if (fp != NULL)
fclose(fp);
}
unsigned find_anony(char *stype)
{
int i, found, anony, result, num_subs;
char fn[MAXPATH], subtype[12];
subboardrec sub;
FILE *fp;
result = 0;
sprintf(fn, "%sSUBS.DAT", syscfg.datadir);
if ((fp = fsh_open(fn, "rb")) == NULL) {
log_it(1, "\n ■ Unable to read %s.", fn);
return 0;
} else {
fseek(fp, 0L, SEEK_END);
num_subs = (int) (ftell(fp) / sizeof(subboardrec));
found = 0;
output(" ");
for (i = 0; (i < num_subs) && (!found); i++) {
output("\b\b\b\b%-4d", i);
fseek(fp, (long) i * sizeof(subboardrec), SEEK_SET);
fread(&sub, sizeof(subboardrec), 1, fp);
get_subtype(i, subtype);
if (stricmp(subtype, stype) == 0) {
anony = sub.anony & 0x0f;
output("\b\b\b\b%s - ", sub.name);
switch (anony) {
case anony_force_anony:
output("forced anonymous.");
result = 2;
break;
case 0:
output("aliases.");
result = 1;
break;
default:
output("real names.");
result = 0;
break;
}
found = 1;
}
}
if (!found)
output("\b\b\b\bnot found.");
}
fclose(fp);
return result;
}
int isleap(unsigned yr)
{
return yr % 400 == 0 || (yr % 4 == 0 && yr % 100 != 0);
}
static unsigned months_to_days(unsigned month)
{
return (month * 3057 - 3007) / 100;
}
int jdate(unsigned yr, unsigned mo, unsigned day)
{
int which;
which = day + months_to_days(mo);
if (mo > 2)
which -= isleap(yr) ? 1 : 2;
return which;
}
int export(char *fn)
{
char fn1[121], tagfn[121], groupname[81], outfn[121], savefn[121], _temp_buffer[256], acct_addr[80], list_addr[80];
char *ss, *buffer, *text, mytype[12], alphatype[21], hold[21], tempoutfn[21], savename[81], savesubj[81];
unsigned stype, ttype;
int infile, outfile, savefile, inloc, outloc, term, ok, a, f, i, j, ns, i6, tolist, hdr;
net_header_rec nhr;
struct msghdr mh;
struct tm *time_msg;
FILE *fp;
time_t some;
char *main_type[] =
{
"Network Update", "email by usernum", "post from sub host", "file",
"post to sub host", "external message", "email by name",
"NetEdit message", "SUBS.LST", "Extra Data", "BBSLIST from GC",
"CONNECT from GC", "Unused_1", "Info from GC", "SSM", "Sub Add Request",
"Sub Drop Request", "Sub Add Response", "Sub Drop Response", "Sub Info",
"Unused 1", "Unused 2", "Unused 3", "Unused 4", "Unused 5", "new post",
"new external"
};
if ((infile = sh_open1(fn, O_RDONLY | O_BINARY)) == -1)
return 1;
if ((buffer = (char *) malloc(32 * 1024)) == NULL) {
sh_close(infile);
log_it(1, "\n ■ Out of memory allocating input buffer!");
return 1;
}
if ((text = (char *) malloc(32 * 1024)) == NULL) {
log_it(1, "\n ■ Out of memory allocating output buffer!");
sh_close(infile);
if (buffer != NULL)
free(buffer);
return 1;
}
while (sh_read(infile, &nhr, sizeof(nhr))) {
strcpy(tagfile, deftagfile);
*alphasubtype = 0;
sh_read(infile, buffer, (int) nhr.length);
if (nhr.tosys != 32767) {
log_it(1, "\n ■ System @%hd routing through @32767... moving to DEAD.NET.",
nhr.fromsys);
move_dead(&nhr, buffer);
continue;
}
tolist = 0;
hdr = 1;
if (nhr.main_type == main_type_pre_post)
nhr.main_type = main_type_post;
if ((nhr.main_type == main_type_post) ||
(nhr.main_type == main_type_new_post) ||
(nhr.main_type == main_type_email_name) ||
(nhr.main_type == main_type_ssm)) {
inloc = 0;
sprintf(hold, "%hu", nhr.minor_type);
if ((nhr.main_type == main_type_email_name) ||
(nhr.main_type == main_type_ssm) ||
(nhr.main_type == main_type_new_post)) {
stype = nhr.minor_type;
inloc = strlen(buffer) + 1;
if ((nhr.main_type == main_type_new_post) || ((nhr.fromsys != net_sysnum) &&
(nhr.fromsys != 32767))) {
strcpy(alphasubtype, buffer);
strcpy(hold, alphasubtype);
} else
strcpy(mh.toUserName, buffer);
} else
if (nhr.main_type == main_type_post) {
stype = nhr.minor_type;
} else {
stype = atoi(&buffer[inloc]);
sprintf(_temp_buffer, "%u", stype);
inloc += strlen(_temp_buffer) + 1;
}
strncpy(mh.subject, &buffer[inloc], sizeof(mh.subject));
stripcolors(mh.subject);
inloc += strlen(&buffer[inloc]) + 1;
for (term = inloc; buffer[term] != '\r'; term++);
buffer[term] = '\0';
*acct_addr = 0;
if ((nhr.fromsys == net_sysnum) && (nhr.fromuser)) {
*acct_addr = 1;
*mytype = 0;
if (nhr.main_type == main_type_new_post)
strcpy(mytype, hold);
if (nhr.main_type == main_type_post)
sprintf(mytype, "%hu", nhr.minor_type);
if ((*mytype) && (!tolist)) {
output("\n ■ Subtype : %s - ", mytype);
a = find_anony(mytype);
} else
a = use_alias;
if (!num_to_name(acct_addr, mh.fromUserName, nhr.fromuser, a)) {
log_it(1, "\n ■ No match for user #%hd... skipping message!",
nhr.fromuser);
continue;
}
} else {
strncpy(mh.fromUserName, &buffer[inloc], sizeof(mh.fromUserName));
stripcolors(mh.fromUserName);
strtok(mh.fromUserName, "#");
trimstr1(mh.fromUserName);
if (nhr.fromsys != 32767) {
sprintf(_temp_buffer, " #%hd @%hu", nhr.fromuser, nhr.fromsys);
strcat(mh.fromUserName, _temp_buffer);
}
/* Gating code will go here */
}
inloc = term + 2;
while (buffer[inloc] != '\n')
inloc++;
inloc++;
if (strnicmp(&buffer[inloc], "RE: ", 4) == 0) {
for (term = inloc; buffer[term] != '\r'; term++);
buffer[term] = '\0';
strncpy(mh.subject, &buffer[inloc + 4], sizeof(mh.subject));
if (strnicmp(mh.subject, "RE: ", 4) != 0) {
strcpy(_temp_buffer, "Re: ");
strcat(_temp_buffer, mh.subject);
}
strcpy(mh.subject, _temp_buffer);
inloc = term + 2;
}
if ((strncmp(&buffer[inloc], "BY: ", 4) == 0) ||
(strncmp(&buffer[inloc], "TO: ", 4) == 0)) {
for (term = inloc; buffer[term] != '\r'; term++);
buffer[term] = '\0';
strncpy(mh.toUserName, &buffer[inloc + 4], sizeof(mh.toUserName));
stripcolors(mh.toUserName);
if (strcspn(mh.toUserName, "<") != strlen(mh.toUserName)) {
if ((_fstrstr(mh.toUserName, "\"") == 0) && (_fstrstr(mh.toUserName, "(") == 0)) {
ss = strtok(mh.toUserName, "<");
ss = strtok(NULL, ">");
strcpy(mh.toUserName, ss);
}
}
inloc = term + 2;
} else {
if (nhr.main_type != main_type_email_name) {
strcpy(mh.toUserName, "ALL");
}
}
outloc = 0;
do {
if (buffer[inloc] == 2) {
i = inloc + 1;
for (j = 1; j < 255; j++) {
if (buffer[i] == 'π')
buffer[i] = '\r';
if ((buffer[i] == '\r') || (i > nhr.length))
break;
i++;
}
if (j < 80) {
i = (80 - j) / 2;
for (j = 1; j <= i; j++)
text[outloc++] = ' ';
}
inloc++;
} else
if (buffer[inloc] == 3)
inloc += 2;
else
if ((buffer[inloc] == 124) && (isdigit(buffer[inloc + 1])) && (isdigit(buffer[inloc + 2])))
inloc += 3;
else
if ((buffer[inloc] == 4) && (isdigit(buffer[inloc + 1]))) {
i = inloc;
for (j = 1; j < 255; j++) {
if ((buffer[i] == '\r') || (i > nhr.length))
break;
i++;
inloc++;
}
inloc++;
if (buffer[inloc] == '\n')
inloc++;
} else
if (buffer[inloc] >= 127)
inloc++;
else
if (buffer[inloc] == 1)
inloc++;
else
text[outloc++] = buffer[inloc++];
} while (inloc < nhr.length);
text[outloc] = '\0';
if ((nhr.main_type == main_type_post) ||
(nhr.main_type == main_type_pre_post) ||
(nhr.main_type == main_type_new_post)) {
if (nhr.main_type == main_type_new_post) {
sprintf(fn1, "%sM%s.NET", net_data, alphasubtype);
if (exist(fn1)) {
tolist = 1;
nhr.main_type = main_type_email_name;
get_list_addr(list_addr, alphasubtype);
}
}
for (i = 0; (i < nlists) && (nhr.main_type != main_type_email_name); i++) {
if (nhr.main_type == main_type_new_post) {
if (strcmpi(alphasubtype, maillist[i].subtype) == 0) {
nhr.main_type = main_type_email_name;
strcpy(mh.toUserName, maillist[i].ownername);
}
} else {
ttype = atoi(maillist[i].subtype);
if (ttype == stype) {
nhr.main_type = main_type_email_name;
strcpy(mh.toUserName, maillist[i].ownername);
}
}
}
}
switch (nhr.main_type) {
case main_type_email:
case main_type_email_name:
case main_type_ssm:
i = 1;
if ((DIGEST) && (tolist)) {
sprintf(outfn, "%sMQUEUE\\DIGEST\\%s.%d", net_data, alphasubtype, jdater);
if (exist(outfn))
hdr = 0;
} else {
sprintf(outfn, "%sMQUEUE\\MSG.%d", net_data, i);
while (exist(outfn))
sprintf(outfn, "%sMQUEUE\\MSG.%d", net_data, ++i);
i = 1;
sprintf(savefn, "%sSENT\\MSG%04d.SNT", net_data, i);
while (exist(savefn))
sprintf(savefn, "%sSENT\\MSG%04d.SNT", net_data, ++i);
}
break;
case main_type_new_post:
case main_type_post:
case main_type_pre_post:
i = 1;
strcpy(tempoutfn, hold);
sprintf(outfn, "%sOUTBOUND\\%s.%d", net_data, tempoutfn, i);
while (exist(outfn))
sprintf(outfn, "%sOUTBOUND\\%s.%d", net_data, tempoutfn, ++i);
break;
default:
continue;
}
log_it(1, "\n ■ Creating: %s", outfn);
if (nhr.fromsys != net_sysnum) {
log_it(1, "\n ■ From : %s", mh.fromUserName);
} else {
if (usermail) {
if (*acct_addr)
log_it(1, "\n ■ From : \"%s\" <%s>", mh.fromUserName, acct_addr);
else
log_it(1, "\n ■ From : \"%s\" <%s@%s>", mh.fromUserName, POPNAME, DOMAIN);
} else
log_it(1, "\n ■ From : <%s@%s>", POPNAME, DOMAIN);
}
if ((nhr.main_type == main_type_post) ||
(nhr.main_type == main_type_pre_post) ||
(nhr.main_type == main_type_new_post)) {
sprintf(fn1, "%sNEWS.RC", net_data);
if ((fp = fsh_open(fn1, "rt")) == NULL) {
log_it(1, "\n ■ %s not found!", fn1);
sh_close(infile);
if (text)
free(text);
if (buffer)
free(buffer);
return 1;
} else {
ok = 0;
while ((fgets(_temp_buffer, 80, fp) != NULL) && (!ok)) {
groupname[0] = 0;
ss = strtok(_temp_buffer, " ");
if (ss) {
strcpy(groupname, ss);
ss = strtok(NULL, " ");
ss = strtok(NULL, "\r");
if (nhr.main_type == main_type_new_post) {
strcpy(alphatype, ss);
if (strncmpi(alphasubtype, alphatype, strlen(alphasubtype)) == 0)
ok = 1;
} else {
ttype = atoi(ss);
if (ttype == stype)
ok = 1;
}
}
}
*ss = NULL;
if (fp != NULL)
fclose(fp);
if (!ok) {
if (nhr.main_type != main_type_new_post)
sprintf(alphatype, "%u", stype);
log_it(1, "\n ■ Subtype %s not found in NEWS.RC!", alphatype);
sh_close(infile);
if (text)
free(text);
if (buffer)
free(buffer);
return 1;
}
}
}
if ((nhr.main_type == main_type_email) ||
(nhr.main_type == main_type_email_name) ||
(nhr.main_type == main_type_ssm)) {
if (tolist)
log_it(1, "\n ■ Sent to : %s Mailing List", alphasubtype);
else
log_it(1, "\n ■ Rcpt to : %s", mh.toUserName);
} else
log_it(1, "\n ■ Post to : %s", groupname);
strcpy(_temp_buffer, mh.subject);
j = 0;
for (i = 0; i < strlen(mh.subject); i++) {
if (_temp_buffer[i] == 3)
++i;
else
mh.subject[j++] = _temp_buffer[i];
}
mh.subject[j] = '\0';
log_it(1, "\n ■ Subject : %s", mh.subject);
if ((nhr.main_type == main_type_email) ||
(nhr.main_type == main_type_email_name) ||
(nhr.main_type == main_type_ssm)) {
if (tolist) {
sprintf(fn1, "%sM%s.NET", net_data, alphasubtype);
f = sh_open1(fn1, O_RDONLY | O_BINARY);
if (filelength(f) <= 0) {
log_it(1, "\n ■ Mailing list %s has no subscribers.", alphasubtype);
f = sh_close(f);
continue;
}
f = sh_close(f);
}
}
outfile = sh_open(outfn, O_RDWR | O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
if (outfile == -1) {
sh_close(infile);
if (buffer)
free(buffer);
if (text)
free(text);
log_it(1, "\n ■ Unable to open output file %s", outfn);
return 1;
}
if (!tolist)
savefile = sh_open(savefn, O_RDWR | O_BINARY | O_CREAT | O_APPEND, S_IWRITE);
time(&some);
time_msg = localtime(&some);
strftime(mh.dateTime, 80, "%a, %d %b %y %H:%M:%S (%Z)", time_msg);
if (!hdr) {
sprintf(_temp_buffer, "\n\n---- Next Message ----\n\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
if (nhr.fromsys == 32767) {
sprintf(_temp_buffer, "From: %s\n", mh.fromUserName);
} else
if (nhr.fromsys != net_sysnum) {
sprintf(_temp_buffer, "From: \"%s\" <%s@%s>\n", mh.fromUserName, POPNAME, DOMAIN);
} else {
if ((spam) && ((nhr.main_type == main_type_post) || (nhr.main_type == main_type_new_post))) {
if (!*acct_addr) {
if (spamname[0] == 0)
sprintf(_temp_buffer, "From: \"%s\" <%s@dont.spam.%s>\n",
mh.fromUserName, POPNAME, DOMAIN);
else
sprintf(_temp_buffer, "From: \"%s\" <%s>\n", mh.fromUserName, spamname);
} else
sprintf(_temp_buffer, "From: \"%s\" <NOSPAM%s>\n", mh.fromUserName, acct_addr);
} else {
if (usermail) {
if (*acct_addr)
sprintf(_temp_buffer, "From: \"%s\" <%s>\n",
mh.fromUserName, acct_addr);
else
sprintf(_temp_buffer, "From: \"%s\" <%s@%s>\n",
mh.fromUserName, POPNAME, DOMAIN);
} else
sprintf(_temp_buffer, "From: <%s@%s>\n", POPNAME, DOMAIN);
}
}
if ((tolist) && (DIGEST)) {
strcpy(savename, mh.fromUserName);
sprintf(_temp_buffer, "From: \"%s Mailing List\" <%s@%s>\n",
alphasubtype, POPNAME, DOMAIN);
}
++cur_daten;
if (hdr) {
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((!tolist) && (savefile != -1))
sh_write(savefile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Message-ID: <%lx-%s@wwivbbs.org>\n",
cur_daten, POPNAME);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
if ((nhr.main_type == main_type_email) ||
(nhr.main_type == main_type_email_name) ||
(nhr.main_type == main_type_ssm)) {
if (!tolist) {
sprintf(_temp_buffer, "To: %s\n", mh.toUserName);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((!tolist) && (savefile != -1))
sh_write(savefile, _temp_buffer, strlen(_temp_buffer));
} else {
i = 0;
if (hdr) {
sprintf(fn1, "%sM%s.NET", net_data, alphasubtype);
if ((fp = fsh_open(fn1, "rt")) != NULL) {
while (fgets(_temp_buffer, 80, fp) != NULL) {
if (_fstrstr(_temp_buffer, "@")) {
strcpy(mh.toUserName, _temp_buffer);
sprintf(_temp_buffer, "To: %s", mh.toUserName);
if (_temp_buffer[strlen(_temp_buffer) - 1] != '\n')
strcat(_temp_buffer, "\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
i = 1;
}
}
}
if (fp != NULL)
fclose(fp);
if (!i) {
sh_close(infile);
sh_close(outfile);
sh_close(savefile);
if (buffer)
free(buffer);
if (text)
free(text);
log_it(1, "\n ■ Error processing mailing list %s.", alphasubtype);
return 1;
} else {
if (*list_addr)
sprintf(_temp_buffer, "Reply-To: \"%s\" <%s>\n", alphasubtype,
list_addr);
else
sprintf(_temp_buffer, "Reply-To: \"%s\" <%s@%s>\n", alphasubtype,
POPNAME, DOMAIN);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
}
}
} else {
sprintf(_temp_buffer, "Newsgroups: %s\n", groupname);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
sprintf(_temp_buffer, "Subject: %s\n", mh.subject);
if ((DIGEST) && (tolist)) {
strcpy(savesubj, _temp_buffer);
sprintf(_temp_buffer, "Subject: %s Daily Digest, Day %d\n", alphasubtype, jdater);
}
if (hdr) {
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((!tolist) && (savefile != -1))
sh_write(savefile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "MIME-Version: 1.0\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Content-Type: text/plain; charset=us-ascii\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Content-Transfer-Encoding: 7bit\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
sprintf(_temp_buffer, "Date: %s\n", mh.dateTime);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((!tolist) && (savefile != -1))
sh_write(savefile, _temp_buffer, strlen(_temp_buffer));
if (nhr.main_type != main_type_email_name) {
if (hdr) {
if (a == 2)
sprintf(_temp_buffer, "Path: anonymous!wwivbbs.org\n");
else
sprintf(_temp_buffer, "Path: %s!%s\n", POPNAME, DOMAIN);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
if (a == 2)
sprintf(_temp_buffer, "Organization: WWIV BBS\n");
else
sprintf(_temp_buffer, "Organization: %s * %s\n",
syscfg.systemname, syscfg.systemphone);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
}
if (tolist) {
if (hdr) {
if (*list_addr)
sprintf(_temp_buffer, "X-Reply-To: \"%s\" <%s>\n",
alphasubtype, list_addr);
else
sprintf(_temp_buffer, "X-Reply-To: \"%s\" <%s@%s>\n",
alphasubtype, POPNAME, DOMAIN);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Source: %s Mail List\n", alphasubtype);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
}
if (((nhr.main_type == main_type_post) || (nhr.main_type == main_type_new_post)) &&
(!tolist) && (a != 2)) {
if (!*acct_addr) {
if (*REPLYTO)
sprintf(_temp_buffer, "Reply-to: \"%s\" <%s>\n", mh.fromUserName, REPLYTO);
else
sprintf(_temp_buffer, "Reply-to: \"%s\" <%s@%s>\n",
mh.fromUserName, POPNAME, DOMAIN);
} else
sprintf(_temp_buffer, "Reply-to: \"%s\" <%s>\n", mh.fromUserName, acct_addr);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
if (hdr) {
sprintf(_temp_buffer, "Version: WWIV PPP Project %s\n\n", VERSION);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
if ((DIGEST) && (tolist)) {
sprintf(_temp_buffer, "%s", savesubj);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "From: %s\n\n", savename);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
if ((nhr.main_type != main_type_email) &&
(nhr.main_type != main_type_email_name) &&
(strncmp(mh.toUserName, "ALL", 3) != 0)) {
sprintf(_temp_buffer, "Responding to: %s\n", mh.toUserName);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((!tolist) && (savefile != -1))
sh_write(savefile, _temp_buffer, strlen(_temp_buffer));
}
for (i = 0; i < strlen(text); i++)
if (text[i] == 'π')
text[i] = '\n';
sh_write(outfile, text, strlen(text));
if ((!tolist) && (savefile != -1))
sh_write(savefile, text, strlen(text));
if ((tolist) && (DIGEST)) {
sprintf(_temp_buffer, "\n\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
} else {
sprintf(tagfn, "%sI%s.TAG", syscfg.datadir, alphasubtype);
if (exist(tagfn))
strcpy(tagfile, tagfn);
tagfn[0] = 0;
ns = 0;
for (i6 = 0; i6 < 99; i6++) {
sprintf(tagfn, "%sI%s.T%d", syscfg.datadir, alphasubtype, i6);
if (exist(tagfn))
ns++;
else
break;
}
sprintf(tagfn, "%sI%s.T%d", syscfg.datadir, alphasubtype, random(ns));
if (exist(tagfn))
strcpy(tagfile, tagfn);
if (tagfile[0] == 0) {
sprintf(_temp_buffer, "\n\nOrigin: %s * %s\n\n",
syscfg.systemname, syscfg.systemphone);
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
} else {
if ((fp = fsh_open(tagfile, "rt")) == NULL)
log_it(1, "\n ■ Error reading %s.", tagfile);
else {
sprintf(_temp_buffer, "\n\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
while (fgets(_temp_buffer, 120, fp)) {
for (i = 0; ((i < strlen(_temp_buffer)) &&
(_temp_buffer[i] != '\r') && (_temp_buffer[i] != '\n')); i++)
if ((_temp_buffer[i] < 32) || (_temp_buffer[i] > 126))
_temp_buffer[i] = 32;
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
}
if (fp != NULL)
fclose(fp);
sprintf(_temp_buffer, "\n\n");
sh_write(outfile, _temp_buffer, strlen(_temp_buffer));
}
}
sh_close(outfile);
sh_close(savefile);
} else {
if ((nhr.main_type >= 0x01) && (nhr.main_type <= 0x1b))
log_it(1, "\n ■ %s message skipped",
main_type[nhr.main_type - 1]);
else
log_it(1, "\n ■ Unknown Main_type %hd skipped", nhr.main_type);
}
}
sh_close(infile);
unlink(fn);
if (text)
free(text);
if (buffer)
free(buffer);
return (0);
}
void get_dir(char *s, int be)
{
strcpy(s, "X:\\");
s[0] = 'A' + getdisk();
getcurdir(0, s + 3);
if (be) {
if (s[strlen(s) - 1] != '\\')
strcat(s, "\\");
}
}
void ssm(char *s)
{
int f, i, i1;
char s1[161];
shortmsgrec sm;
sprintf(s1, "%sSMW.DAT", syscfg.datadir);
f = sh_open(s1, O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
if (f < 0)
return;
i = (int) (filelength(f) / sizeof(shortmsgrec));
i1 = i - 1;
if (i1 >= 0) {
sh_lseek(f, ((long) (i1)) * sizeof(shortmsgrec), SEEK_SET);
sh_read(f, (void *) &sm, sizeof(shortmsgrec));
while ((sm.tosys == 0) && (sm.touser == 0) && (i1 > 0)) {
--i1;
sh_lseek(f, ((long) (i1)) * sizeof(shortmsgrec), SEEK_SET);
sh_read(f, (void *) &sm, sizeof(shortmsgrec));
}
if ((sm.tosys) || (sm.touser))
++i1;
} else
i1 = 0;
sm.tosys = 0;
sm.touser = 1;
strncpy(sm.message, s, 80);
sm.message[80] = 0;
sh_lseek(f, ((long) (i1)) * sizeof(shortmsgrec), SEEK_SET);
sh_write(f, (void *) &sm, sizeof(shortmsgrec));
sh_close(f);
}
/*
action: 1 = unsubscribed,
2 = subscribed,
3 = already subscribed,
4 = not subscribed
5 = invalid list
6 = sending MAILLIST.TXT
*/
void send_note(int action, char *mailname, char *listname)
{
char s[81], fn[MAXPATH];
int i;
FILE *fp, *rlz;
i = 1;
sprintf(fn, "%sMQUEUE\\MSG.%d", net_data, i);
while (exist(fn))
sprintf(fn, "%sMQUEUE\\MSG.%d", net_data, ++i);
if ((fp = fsh_open(fn, "wt+")) == NULL) {
log_it(1, "\n ! Unable to create %s.", fn);
return;
}
if (action != 5)
fprintf(fp, "From: \"%s\" <%s@%s>\n", listname, POPNAME, DOMAIN);
else
fprintf(fp, "From: <%s@%s>\n", POPNAME, DOMAIN);
fprintf(fp, "To: %s\n", mailname);
fprintf(fp, "Subject: %s Mailing List\n\n", listname);
switch (action) {
case 1:
sprintf(s, "%s removed from mailing list: %s", mailname, listname);
fprintf(fp, "\n%s\n\n", s);
log_it(1, "\n ■ %s", s);
ssm(s);
break;
case 2:
sprintf(fn, "%sR%s.RLZ", net_data, listname);
if (!(exist(fn)))
sprintf(fn, "%sGLOBAL.RLZ", net_data);
if ((rlz = fsh_open(fn, "rt")) != NULL) {
while (fgets(s, 80, rlz))
fprintf(fp, s);
fprintf(fp, "\n\n");
fclose(rlz);
sprintf(s, "%s added to mailing list: %s", mailname, listname);
log_it(1, "\n%s", s);
ssm(s);
} else {
sprintf(s, "%s added to mailing list: %s", mailname, listname);
fprintf(fp, "\n%s\n\n", s);
log_it(1, "\n ■ %s", s);
ssm(s);
}
break;
case 3:
sprintf(fn, "%sR%s.RLZ", net_data, listname);
if (!(exist(fn)))
sprintf(fn, "%sGLOBAL.RLZ", net_data);
if ((rlz = fsh_open(fn, "rt")) != NULL) {
while (fgets(s, 80, rlz))
fprintf(fp, s);
fprintf(fp, "\n\n");
fclose(rlz);
} else
fprintf(fp, "\n%s was already subscribed to mailing list:\n\n %s\n\n",
mailname, listname);
break;
case 4:
fprintf(fp, "\n%s not subscribed to mailing list:\n\n %s\n\n",
mailname, listname);
break;
case 5:
sprintf(s, "%s requested an invalid mailing list: %s", mailname, listname);
fprintf(fp, "\n%s\n\n", s);
log_it(1, "\n ■ %s", s);
ssm(s);
break;
case 6:
sprintf(fn, "%sMAILLIST.TXT", syscfg.gfilesdir);
if ((rlz = fsh_open(fn, "rt")) != NULL) {
while (fgets(s, 80, rlz))
fprintf(fp, s);
fprintf(fp, "\n\n");
fclose(rlz);
sprintf(s, "Sent MAILLIST.TXT to %s.", mailname);
} else
sprintf(s, "No mailing list file found. Notify system operator.");
fprintf(fp, "\n%s\n\n", s);
log_it(1, "\n ■ %s", s);
ssm(s);
break;
}
if (fp != NULL)
fclose(fp);
}
int copyfile(char *input, char *output)
{
int f1, f2, i;
char *b;
struct ftime ft;
if ((strcmp(input, output) != 0) && (exist(input)) && (!exist(output))) {
if ((b = (char *) malloc(16400)) == NULL)
return 0;
f1 = sh_open1(input, O_RDONLY | O_BINARY);
if (!f1) {
free(b);
b = NULL;
return 0;
}
getftime(f1, &ft);
f2 = sh_open(output, O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
if (!f2) {
free(b);
b = NULL;
f1 = sh_close(f1);
return 0;
}
i = read(f1, (void *) b, 16384);
while (i > 0) {
sh_write(f2, (void *) b, i);
i = read(f1, (void *) b, 16384);
}
f1 = sh_close(f1);
setftime(f2, &ft);
f2 = sh_close(f2);
free(b);
b = NULL;
}
return 1;
}
char (*devices)[9];
int num_devices;
void finddevs(char (*devs)[9], int *count)
{
char s[9];
int i;
char far *ss;
long far *l;
union REGS regs;
struct SREGS sregs;
*count = 0;
regs.x.ax = 0x5200;
int86x(INT_REAL_DOS, ®s, ®s, &sregs);
ss = (char *) MK_FP(sregs.es, regs.x.bx);
ss += 34;
l = (long far *) ss;
while (((unsigned short) l) != 0xffff) {
ss = (char far *) l;
ss += 10;
if (*ss > 32) {
strncpy(s, ss, 8);
s[8] = 0;
for (i = 7; i; i--)
if (s[i] == ' ')
s[i] = 0;
else
break;
if (devs) {
strcpy(devs[*count], s);
}
++(*count);
}
l = (long far *) *l;
}
}
void find_devices(void)
{
finddevs(NULL, &num_devices);
devices = (char (*)[9]) farmalloc((num_devices + 2) * 9);
finddevs(devices, &num_devices);
}
int okfn(char *s)
{
int i, l;
unsigned char ch;
find_devices();
l = strlen(s);
if ((s[0] == '-') || (s[0] == ' ') || (s[0] == '.') || (s[0] == '@'))
return (0);
for (i = 0; i < l; i++) {
ch = s[i];
if ((ch == ' ') || (ch == '/') || (ch == '\\') || (ch == ':') ||
(ch == '>') || (ch == '<') || (ch == '|') || (ch == '+') ||
(ch == ',') || (ch == ';') || (ch == '^') || (ch == '\"') ||
(ch == '\'') || (ch > 126))
return (0);
}
for (i = 0; i < num_devices; i++) {
l = strlen(devices[i]);
if (strncmp(devices[i], s, l) == 0) {
if ((s[l] == 0) || (s[l] == '.') || (l == 8))
return (0);
}
}
if (devices != NULL)
farfree(devices);
return (1);
}
int subscribe(char *fn)
{
char *ss, s[81], s1[81], mailname[81], subtype[81];
int done, found, unsubscribe;
FILE *fp, *oldfp, *newfp;
if ((fp = fsh_open(fn, "rt")) == NULL) {
log_it(1, "\n ! Unable to open %s.", fn);
return 1;
}
done = unsubscribe = 0;
while ((fgets(s1, 80, fp)) && (!done)) {
strcpy(s, &(s1[3]));
if (strnicmp(s, "from:", 5) == 0) {
ss = strtok(s, ":");
if (ss) {
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strcpy(mailname, ss);
}
}
if (strnicmp(s, "subject:", 8) == 0) {
done = 1;
ss = strtok(s, ":");
if (ss) {
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strcpy(s1, ss);
if (strnicmp(s1, "subscribe", 9) == 0) {
ss = strtok(s1, " ");
if (ss) {
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strcpy(subtype, ss);
}
}
if (strnicmp(s1, "unsubscribe", 11) == 0) {
unsubscribe = 1;
ss = strtok(s1, " ");
if (ss) {
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strcpy(subtype, ss);
}
}
}
ss = NULL;
}
}
if (fp != NULL)
fclose(fp);
if ((!*mailname) || (!*subtype)) {
log_it(1, "\n ! Invalid subscription request %s.", fn);
return 1;
}
if ((strlen(subtype) == 1) || (strlen(subtype) > 7)) {
log_it(1, "\n ! %s attempted to write to M%s.NET!", mailname, subtype);
return 1;
}
if (strnicmp(subtype, "LISTS", 5) == 0) {
send_note(6, mailname, subtype);
return 0;
}
sprintf(s1, "M%s.NET", subtype);
if (!okfn(s1)) {
log_it(1, "\n ! %s attempted to create invalid filename %s!", mailname, s1);
return 1;
}
sprintf(s, "%sM%s.NET", net_data, subtype);
if (!exist(s)) {
log_it(1, "\n ! %s subscriber list not found.", s);
send_note(5, mailname, subtype);
return 1;
}
if ((oldfp = fsh_open(s, "rt")) == NULL) {
log_it(1, "\n ! Unable to open input file %s.", s);
return 1;
}
sprintf(s1, "%sM%s.TMP", net_data, subtype);
if (exist(s1))
unlink(s1);
if ((newfp = fsh_open(s1, "wt+")) == NULL) {
log_it(1, "\n ! Unable to open output file %s.", s1);
return 1;
}
found = 0;
while (fgets(s, 80, oldfp)) {
trimstr1(s);
if (unsubscribe) {
if (stricmp(s, mailname) == 0) {
log_it(1, "\n ■ Removing %s from %s mailing list.", mailname, subtype);
send_note(1, mailname, subtype);
found = 1;
} else
fprintf(newfp, "%s\n", s);
} else {
if (stricmp(s, mailname) == 0) {
log_it(1, "\n ■ %s already in %s mailing list.", mailname, subtype);
send_note(3, mailname, subtype);
found = 1;
}
fprintf(newfp, "%s\n", s);
}
}
if (!found) {
if (unsubscribe) {
log_it(1, "\n ■ %s was not a member of %s mailing list.", mailname, subtype);
send_note(4, mailname, subtype);
} else {
log_it(1, "\n ■ Adding %s to %s mailing list.", mailname, subtype);
fprintf(newfp, "%s\n", mailname);
send_note(2, mailname, subtype);
}
}
if (oldfp != NULL)
fclose(oldfp);
if (newfp != NULL)
fclose(newfp);
sprintf(s, "%sM%s.TMP", net_data, subtype);
sprintf(s1, "%sM%s.NET", net_data, subtype);
if (exist(s1))
unlink(s1);
copyfile(s, s1);
if (exist(s))
unlink(s);
return 0;
}
int main(int argc, char *argv[])
{
char fn[MAXPATH], newfn[MAXPATH], ext[5], *ss;
int f, f1, i;
struct ffblk ff;
struct date dt;
struct time tm;
output("\n ■ PPP Import/Export %s", VERSION);
if (argc != 7) {
log_it(1, "\n ■ EXP <filename> <net_data> <net_sysnum> <POPNAME> <DOMAIN> <net_name>\n\n");
if (argc > 1) {
log_it(1, "Command line was: ");
for (i = 0; i < argc; i++)
log_it(1, "%s ", argv[i]);
log_it(1, "\n\n");
}
return (1);
}
strcpy(net_data, argv[2]);
f = sh_open1("CONFIG.DAT", O_RDONLY | O_BINARY);
if (f < 0) {
log_it(1, "Could not open CONFIG.DAT!\n\n");
return 1;
}
sh_read(f, (void *) &syscfg, sizeof(configrec));
sh_close(f);
detect_multitask();
get_dir(maindir, 1);
sprintf(fn, "%s%s", net_data, argv[1]);
strcpy(net_name, argv[6]);
strcpy(POPNAME, argv[4]);
strcpy(DOMAIN, argv[5]);
net_sysnum = atoi(argv[3]);
DIGEST = 0;
tagfile[0] = 0;
spam = 0;
ss = getenv("WWIV_INSTANCE");
if (ss) {
instance = atoi(ss);
if (instance >= 1000) {
log_it(1, "\n ■ WWIV_INSTANCE set to %hd. Can only be 1..999!",
instance);
instance = 1;
}
} else
instance = 1;
parse_net_ini();
gettime(&tm);
getdate(&dt);
cur_daten = dostounix(&dt, &tm);
jdater = jdate(dt.da_year, dt.da_mon, dt.da_day);
strupr(postmaster);
export(fn);
sprintf(fn, "%sSPOOL\\UNK*.*", net_data);
f1 = findfirst(fn, &ff, 0);
while (f1 == 0) {
sprintf(fn, "%sSPOOL\\%s", net_data, ff.ff_name);
if (!import(fn)) {
unlink(fn);
}
f1 = findnext(&ff);
}
sprintf(fn, "%sINBOUND\\SUB*.*", net_data);
f1 = findfirst(fn, &ff, 0);
while (f1 == 0) {
sprintf(fn, "%sINBOUND\\%s", net_data, ff.ff_name);
fnsplit(fn, NULL, NULL, NULL, ext);
if (strnicmp(ext, ".BAD", 4) == 0)
log_it(1, "\n ■ Unprocessed subscriber request %s...", ff.ff_name);
else {
log_it(1, "\n ■ Processing subscriber request %s...", ff.ff_name);
if (!subscribe(fn))
unlink(fn);
else {
name_bad(newfn);
rename(fn, newfn);
}
}
f1 = findnext(&ff);
}
if (maillist != NULL)
free(maillist);
return 0;
}