home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
PPPBCKP
/
SRC15B17.ZIP
/
EXP.C
next >
Wrap
Text File
|
1997-03-02
|
24KB
|
837 lines
#include <stdio.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 <malloc.h>
#include <process.h>
#include <direct.h>
#include "vardec.h"
#include "net.h"
#include "version.h"
#define WAIT_TIME 10
#define TRIES 100
struct msghdr {
char fromUserName[205];
char toUserName[81];
char subject[81];
char dateTime[81];
};
configrec syscfg;
char *net_name, postmaster[31], net_data[MAXPATH], POPNAME[21], DOMAIN[81];
unsigned short net_sysnum, defuser, num_users, use_alias, instance, curuser;
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);
}
int sh_open(char *path, int file_access, unsigned mode)
{
int handle, count, share;
char drive[MAXDRIVE], dir[MAXDIR], file[MAXFILE], ext[MAXEXT];
if ((file_access & O_RDWR) || (file_access & O_WRONLY) || (mode & S_IWRITE))
share=SH_DENYRW;
else
share=SH_DENYWR;
handle=open(path,file_access|share,mode);
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,mode);
while (((handle<0) && (errno==EACCES)) && (count<TRIES)) {
delay(WAIT_TIME);
count++;
handle=open(path,file_access|share,mode);
}
}
}
return(handle);
}
int sh_open1(char *path, int access)
{
unsigned mode;
mode=0;
if ((access & O_RDWR) || (access & O_WRONLY))
mode |= S_IWRITE;
if ((access & O_RDWR) || (access & O_RDONLY))
mode |= S_IREAD;
return(sh_open(path, access, mode));
}
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 ((_fstrchr(fmode, 'w')) != NULL) {
share = SH_DENYRD;
md = O_RDWR | O_CREAT | O_TRUNC;
} else
if ((_fstrchr(fmode, 'a')) != NULL) {
share = SH_DENYRD;
md = O_RDWR | O_CREAT;
} else {
md = O_RDONLY;
}
if ((_fstrchr(fmode, 'b')) != NULL) {
md |= O_BINARY;
}
if ((_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 ((_fstrchr(fmode, 'a')) != NULL)
lseek(fd, 0L, SEEK_END);
f = fdopen(fd, fmode);
if (!f) {
close(fd);
}
} else
f = 0;
return(f);
}
int num_to_name(char *where, int whichuser, int alias);
void parse_net_ini(void)
{
char line[121], *ss;
FILE *fp;
defuser=1;
use_alias = 1;
fp = fsh_open("NET.INI", "rt");
if (!fp)
return;
while (fgets(line, 80, fp)) {
ss = NULL;
stripspace(line);
/* fprintf(stderr, "\nCurrent : %s\n", line); */
if ((line[0] == ';') || (line[0] == '\n') || (line[0] == '['))
continue;
if (strlen(line) == 0)
continue;
if (strnicmp(line, "POSTMASTER", 10) == 0) {
ss = strtok(line, "=");
if (ss) {
ss = strtok(NULL, "\n");
if (ss)
defuser = atoi(ss);
}
}
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(postmaster, defuser, 1);
fclose(fp);
return;
}
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);
}
int num_to_name(char *where, int whichuser, int alias)
{
int userfile, num_users, found;
userrec ur;
long pos;
char fn[MAXPATH];
found = 0;
sprintf(fn, "%sUSER.LST", syscfg.datadir);
userfile = sh_open1(fn, O_RDONLY | O_BINARY);
if (userfile < 0) {
fprintf(stderr, "\n ■ Cannot open %s.", fn);
return(found);
}
num_users = ((int) (filelength(userfile) / sizeof(userrec)));
if (whichuser > num_users) {
fprintf(stderr, "\n ■ User #%d out of range.", whichuser);
return(found);
}
pos = ((long) sizeof(userrec) * ((long) whichuser));
lseek(userfile, pos, SEEK_SET);
read(userfile, &ur, sizeof(userrec));
if (ur.realname[0] == 0)
fprintf(stderr, "\n ■ User #%d has blank real name field!", whichuser);
else {
if (ur.inact == inact_deleted)
fprintf(stderr, "\n ■ User #%d is marked as deleted!", whichuser);
else {
if (!alias)
strcpy(where, ur.realname);
else {
strlwr(ur.name);
strcpy(where, ur.name);
}
found = 1;
}
}
close(userfile);
return(found);
}
int name_to_num(char *name)
{
int userfile, usernum;
userrec ur;
long pos;
char fn[MAXPATH];
fprintf(stderr, "\n ■ Searching for user %s", strupr(name));
stripspace(name);
sprintf(fn, "%sUSER.LST", syscfg.datadir);
userfile = sh_open1(fn, O_RDONLY | O_BINARY);
if (userfile < 0) {
printf("\n ■ Cannot open %s", fn);
return(0);
}
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);
read(userfile, &ur, sizeof(userrec));
stripspace(ur.realname);
stripspace(ur.name);
if ((strcmpi(ur.realname, name) == 0) || (strcmpi(ur.name, name) == 0)) {
if (ur.inact == inact_deleted) {
fprintf(stderr, "... user #%d is deleted account.", usernum);
usernum = 0;
break;
} else {
fprintf(stderr, "... matched user #%d.", usernum);
break;
}
}
}
userfile = close(userfile);
if (usernum >= num_users) {
fprintf(stderr, "... no match found.");
return(0);
}
return(usernum);
}
char *find_name(char *name)
{
char *ss;
curuser = 0;
if (strcspn(name, "(") != strlen(name)) {
ss = strtok(name, "(");
ss = strtok(NULL, ")");
strcpy(name, ss);
curuser = name_to_num(name);
} else
if (strcspn(name, "\"") != strlen(name)) {
ss = strtok(name, "\"");
ss = strtok(NULL, "\"");
strcpy(name, ss);
curuser = name_to_num(name);
} else
if (strcspn(name, "<") != strlen(name)) {
if ((strcspn(name, " ")) < (strcspn(name, "<"))) {
ss = strtok(name, "<");
trimstr1(ss);
strcpy(name, ss);
curuser = name_to_num(name);
} else {
fprintf(stderr, "\nName is *after* host in \"%s\"", name);
}
}
if (curuser == 0)
return('\0');
else
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;
}
}
int import(char *fn)
{
char s[513], pktname[MAXPATH], msgdate[31], *ss, *p;
int f, from, subj, intext, done;
long textlen;
struct msghdr mh;
net_header_rec nh;
struct date dt;
struct time tm;
FILE *fp;
intext = 0;
f = sh_open1(fn, O_RDONLY | O_BINARY);
if (f < 0)
return(1);
textlen = filelength(f);
if (textlen > 32767L) {
fprintf(stderr, "\n ■ Skipping %s - greater than 32K.", fn);
return(1);
}
p = (char *) malloc(textlen + 1);
if (p==NULL) {
fprintf(stderr, "\n ■ Unable to allocate %ld bytes.", textlen);
return(1);
}
read(f, (void *) p, textlen);
close(f);
nh.tosys = net_sysnum;
nh.fromsys = 32767L;
nh.fromuser = 0;
nh.touser = defuser;
nh.main_type = main_type_email;
nh.minor_type = 0;
nh.list_len = 0;
gettime(&tm);
getdate(&dt);
nh.daten = dostounix(&dt, &tm);
nh.method = 0;
fp = fsh_open(fn, "rb");
if (!fp) {
free(p);
return(1);
}
from = subj = done = 0;
while ((fgets(s, 254, fp)) && !done) {
if ((s[0] == '\r') || (s[0] == '\n') || (s[0] == 0))
intext = 1;
if (!intext) {
if ((strncmpi(s, "reply-to:", 9) == 0)) {
from = 1;
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
trimstr1(ss);
/* strncpy(mh.fromUserName, ss, 46); */
strcpy(mh.fromUserName, ss);
if (strlen(mh.fromUserName) > 190)
mh.fromUserName[190] = '\0';
strcat(mh.fromUserName, "\r\n");
} else if ((strncmpi(s, "from:", 5) == 0) && (!from)) {
from = 1;
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
trimstr1(ss);
/* strncpy(mh.fromUserName, ss, 46); */
strcpy(mh.fromUserName, ss);
if (strlen(mh.fromUserName) > 190);
mh.fromUserName[190] = '\0';
strcat(mh.fromUserName, "\r\n");
} else if ((strncmpi(s, "return-path:", 12) == 0) && (!from)) {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
trimstr1(ss);
/* strncpy(mh.fromUserName, ss, 46); */
strcpy(mh.fromUserName, ss);
if (strlen(mh.fromUserName) > 190)
mh.fromUserName[190] = '\0';
strcat(mh.fromUserName, "\r\n");
} else if ((strncmpi(s, "subject:", 8) == 0) && (!subj)) {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
trimstr1(ss);
strcpy(mh.subject, ss);
if (strlen(mh.subject) > 72)
mh.subject[72] = '\0';
else
mh.subject[strlen(mh.subject)] = '\0';
} else if ((strncmpi(s, "to:", 3) == 0) || (strncmpi(s, "cc:", 3) == 0)) {
ss = strtok(s, ": ");
ss = strtok(NULL, "\r\n");
strcpy(mh.toUserName, ss);
trimstr1(mh.toUserName);
if (_fstrstr(mh.toUserName, " "))
find_name(mh.toUserName);
else
mh.toUserName[0] = '\0';
if ((mh.toUserName[0] == 0) || (curuser == 0)) {
nh.touser = defuser;
strcpy(mh.toUserName, postmaster);
} else
nh.touser = curuser;
}
} else
done = 1;
}
fclose(fp);
fprintf(stderr, "\n ■ From : %s", mh.fromUserName);
fprintf(stderr, " ■ Sent to : %s #%hd", mh.toUserName, nh.touser);
fprintf(stderr, "\n ■ Subject : %s", mh.subject);
name_packet(pktname);
fp = fsh_open(pktname, "wb");
if (fp < 0) {
fprintf(stderr, "\n ■ Unable to create packet %s", pktname);
free(p);
return(1);
}
strncpy(msgdate, ctime(&(time_t) nh.daten), 24);
msgdate[24] = '\0';
strcat(msgdate, "\r\n");
nh.length = textlen + strlen(mh.fromUserName) + strlen(mh.subject) + strlen(msgdate) + 1;
fwrite(&nh, sizeof(net_header_rec), 1, fp);
fwrite(mh.subject, sizeof(char), strlen(mh.subject) +1, fp);
fwrite(mh.fromUserName, sizeof(char), strlen(mh.fromUserName), fp);
fwrite(msgdate, sizeof(char), strlen(msgdate), fp);
fwrite(p, sizeof(char), textlen, fp);
fclose(fp);
free(p);
return(0);
}
int export(char *fn)
{
char fn1[121], groupname[81], outfn[121], _temp_buffer[256];
char *ss, *buffer, *text;
unsigned stype, ttype;
int infile, outfile, inloc, outloc, term, ok, i, j;
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"
};
if ((infile = sh_open1(fn, O_RDONLY | O_BINARY)) == -1)
return(1);
else
fprintf(stderr, "\n ■ Parsing %s (%ld bytes)", fn, filelength(infile));
if ((buffer = (char *) malloc(32 * 1024)) == NULL) {
fprintf(stderr, "\n ■ Out of memory allocating input buffer!");
return(1);
}
if ((text = (char *) malloc(32 * 1024)) == NULL) {
fprintf(stderr, "\n ■ Out of memory allocating output buffer!");
if (buffer)
free(buffer);
buffer = NULL;
return(1);
}
while (read(infile, &nhr, sizeof(nhr))) {
read(infile, buffer, nhr.length);
if (nhr.tosys != 32767) {
fprintf(stderr, "\n ■ Non-Internet system routing via @32767... aborting export.");
return(1);
}
if ((nhr.main_type == main_type_post) ||
(nhr.main_type == main_type_new_post) ||
(nhr.main_type == main_type_email_name)) {
inloc = 0;
if (nhr.main_type == main_type_email_name) {
stype = nhr.minor_type;
inloc = strlen(buffer) + 1;
strcpy(mh.toUserName, buffer);
if (nhr.fromsys != net_sysnum) {
fprintf(stderr, "\n ■ Gate from #%hd@%hd to %s not yet supported",
nhr.fromuser, nhr.fromsys, mh.toUserName);
continue;
}
} 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));
inloc += strlen(&buffer[inloc]) + 1;
for (term = inloc; buffer[term] != '\r'; term++);
buffer[term] = '\0';
if ((nhr.fromsys == net_sysnum) && (nhr.fromuser)) {
if (nhr.main_type != main_type_post) {
if (!num_to_name(mh.fromUserName, nhr.fromuser, use_alias)) {
fprintf(stderr, "\n ■ No match for user #%hd... skipping message!",
nhr.fromuser);
continue;
}
} else {
if (!num_to_name(mh.fromUserName, nhr.fromuser, 1)) {
fprintf(stderr, "\n ■ No match for user #%hd... skipping message!",
nhr.fromuser);
continue;
}
}
} else {
strncpy(mh.fromUserName, &buffer[inloc], sizeof(mh.fromUserName));
strtok(mh.fromUserName, "#");
if ((nhr.main_type == main_type_post) &&
(nhr.fromsys != net_sysnum)) {
sprintf(_temp_buffer, " #%hd @%hu", nhr.fromuser, nhr.fromsys);
strcat(mh.fromUserName, _temp_buffer);
}
}
inloc = term + 2;
while (buffer[inloc] != '\n')
inloc++;
inloc++;
if (strncmp(&buffer[inloc], "0R", 3) == 0) {
while (buffer[inloc] != '\n')
++inloc;
inloc++;
}
if (strnicmp(&buffer[inloc], "re:", 3) == 0) {
for (term = inloc; buffer[term] != '\r'; term++);
buffer[term] = '\0';
strncpy(mh.subject, &buffer[inloc], sizeof(mh.subject));
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));
inloc = term + 2;
} else {
if (nhr.main_type != main_type_email_name) {
strcpy(mh.toUserName, "ALL\n");
}
}
outloc = 0;
do {
if (buffer[inloc] == 2) {
i = inloc + 1;
for (j = 1; j < 80; j++) {
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] == 4) && (buffer[inloc + 1] == '0')) {
i = inloc;
for (j = 1; j < 80; j++) {
if ((buffer[i] == '\r') ||
(i > nhr.length))
break;
i++;
inloc++;
}
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';
switch (nhr.main_type) {
case main_type_email:
case main_type_email_name:
i = 1;
sprintf(outfn, "%sMQUEUE\\MSG.%d", net_data, i);
while (exist(outfn))
sprintf(outfn, "%sMQUEUE\\MSG.%d", net_data, ++i);
break;
case main_type_post:
case main_type_pre_post:
i = 1;
sprintf(outfn, "%sOUTBOUND\\%d.%d", net_data, stype, i);
while (exist(outfn))
sprintf(outfn, "%sOUTBOUND\\%d.%d", net_data, stype, ++i);
break;
default:
continue;
}
fprintf(stderr, "\n ■ Creating: %s", outfn);
fprintf(stderr, "\n ■ From : %s", mh.fromUserName);
if ((nhr.main_type == main_type_post) ||
(nhr.main_type == main_type_pre_post)) {
sprintf(fn1, "%sNEWS.RC", net_data);
fp = fsh_open(fn1, "rt");
if (!fp)
fprintf(stderr, "\n ■ %s not found!", fn1);
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");
ttype = atoi(ss);
if (ttype == stype)
ok = 1;
}
}
*ss = NULL;
fclose(fp);
}
}
if ((nhr.main_type == main_type_email) ||
(nhr.main_type == main_type_email_name)) {
fprintf(stderr, "\n ■ To : %s", strlwr(mh.toUserName));
} else {
if (groupname[0] == 0)
fprintf(stderr, "\n ■ No match for subtype %u in NEWS.RC", stype);
else
fprintf(stderr, "\n ■ Post to : %s", groupname);
}
fprintf(stderr, "\n ■ Subject : %s", mh.subject);
outfile = sh_open(outfn, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC | O_EXCL, S_IWRITE);
if (outfile == -1) {
if (buffer)
free(buffer);
if (text)
free(text);
fprintf(stderr, "\n ■ Unable to open output file %s", outfn);
return(1);
}
time(&some);
time_msg = localtime(&some);
strftime(mh.dateTime, 80, "%a, %d %b %y %H:%M:%S (%Z)", time_msg);
sprintf(_temp_buffer, "From: %s@%s (%s)\n",
POPNAME, DOMAIN, mh.fromUserName);
write(outfile, _temp_buffer, strlen(_temp_buffer));
/* delay(2000); */
sprintf(_temp_buffer, "Message-ID: <%lx-%s@%s>\n",
time(NULL), POPNAME, DOMAIN);
write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((nhr.main_type == main_type_email) ||
(nhr.main_type == main_type_email_name)) {
sprintf(_temp_buffer, "To: %s\n",
mh.toUserName);
write(outfile, _temp_buffer, strlen(_temp_buffer));
} else {
sprintf(_temp_buffer, "Newsgroups: %s\n", groupname);
write(outfile, _temp_buffer, strlen(_temp_buffer));
}
sprintf(_temp_buffer, "Subject: %s\n", mh.subject);
write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Date: %s\n", mh.dateTime);
write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Organization: %s * @%hu.%s * %s\n",
syscfg.systemname, net_sysnum, net_name, syscfg.systemphone);
write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Reply-To: %s@%s (%s)\n",
POPNAME, DOMAIN, mh.fromUserName);
write(outfile, _temp_buffer, strlen(_temp_buffer));
sprintf(_temp_buffer, "Version: WWIV PPP Project %s\n\n",VERSION);
write(outfile, _temp_buffer, strlen(_temp_buffer));
if ((nhr.main_type != main_type_email) &&
(nhr.main_type != main_type_email_name)) {
sprintf(_temp_buffer, "Responding to: %s\n", mh.toUserName);
write(outfile, _temp_buffer, strlen(_temp_buffer));
}
write(outfile, text, strlen(text));
sprintf(_temp_buffer, "\n\nOrigin: %s * %s * @%hu.FILEnet\n\n",
syscfg.systemname, syscfg.systemphone, net_sysnum);
write(outfile, _temp_buffer, strlen(_temp_buffer));
close(outfile);
} else {
if ((nhr.main_type >= 0x01) && (nhr.main_type <= 0x14))
fprintf(stderr, "\n ■ %s message skipped",
main_type[nhr.main_type - 1]);
else
fprintf(stderr, "\n ■ Unknown Main_type %hd skipped", nhr.main_type);
}
}
close(infile);
unlink(fn);
if (text)
free(text);
if (buffer)
free(buffer);
return(0);
}
int main(int argc, char *argv[])
{
char s[MAXPATH], fn[MAXPATH], *ss;
int f, f1, maxmail,i;
struct ffblk ff;
/* 0 1 2 3 4 5 6 */
/* exp s32767.net, net_data, net_sysnum, popname, domain, net_name */
/* exp netlog/contact, net_data, sysnum, sent recd totaltime */
if (argc != 7) {
fprintf(stderr, "Version: WWIV PPP Project %s\n\n",VERSION);
fprintf(stderr, "\n ■ EXP <filename> <net_data> <net_sysnum> <POPNAME> <DOMAIN> <net_name>\n\n");
if (argc > 1) {
fprintf(stderr, "Command line was: ");
for (i=0; i<argc; i++)
fprintf(stderr, "%s ",argv[i]);
fprintf(stderr, "\n\n");
}
return(1);
}
strcpy(net_data, argv[2]);
sprintf(fn, "%s%s", net_data, argv[1]);
net_name = argv[6];
strcpy(POPNAME, argv[4]);
strcpy(DOMAIN, argv[5]);
net_sysnum = atoi(argv[3]);
f=sh_open1("CONFIG.DAT",O_RDONLY | O_BINARY);
if (f < 0) {
fprintf(stderr, "Could not open CONFIG.DAT!\n\n");
return(1);
}
read(f, (void *) &syscfg, sizeof(configrec));
close(f);
parse_net_ini();
export(fn);
ss = getenv("WWIV_INSTANCE");
if (ss) {
instance = atoi(ss);
if (instance >= 1000) {
fprintf(stderr, "\n ■ WWIV_INSTANCE set to %hd. Can only be 1..999!",
instance);
instance = 1;
}
} else
instance = 1;
sprintf(fn, "%sSPOOL\\UNK*.*", net_data);
f1 = findfirst(fn, &ff, 0);
if (f1 == 0) {
fprintf(stderr, "\n ■ Importing mail from %sSPOOL.", net_data);
fprintf(stderr, "\n ■ Postmaster set to %s #%hd.",
postmaster, defuser);
fprintf(stderr, "\n ■ Using %s on outbound Internet email.",
use_alias ? "aliases" : "real names");
}
maxmail = 14;
while ((f1 == 0) && maxmail) {
sprintf(fn, "%sSPOOL\\%s", net_data, ff.ff_name);
if (!import(fn)) {
unlink(fn);
--maxmail;
}
f1 = findnext(&ff);
}
return 0;
}