home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
MAXMAILP.ZIP
/
FILE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-03
|
29KB
|
868 lines
/****************************************************************************/
/* */
/* File.c File i/o routines for MaxMail */
/* Version 1.0 */
/* */
/****************************************************************************/
#include "MaxMail.h"
struct msgupd_st *msgupd;
struct msgupd_st *next;
struct proto_st *proto1;
struct packer_st *packer1;
struct stat fbuf;
char fname[_MAX_PATH];
char exec_ret;
#if defined OS2
extern hfComHandle;
#endif
/* Load up user message areas data into linked list */
int build_areas()
{
int keys,mask,x,anum;
int index,count;
long lerr;
word *bitp;
struct _aidx IDX;
count = 0;
if (PackDone)
return(count);
msgupd = MSGUPD_1;
while (msgupd) {
next = msgupd->next;
free(msgupd);
msgupd = next;
}
MSGUPD_1 = NULL; /* Set up linked list */
index = sopen(PRM(aidx_name),O_BINARY | O_RDONLY,SH_DENYNO,S_IREAD);
if (index == -1)
aborterror(FILEOPEN,"Error opening Area index file");
keys = read(index,(char *)&IDX,sizeof(struct _aidx));
fseek(afile,IDX.offset,SEEK_SET);
fread(&AREA,astrlen,1,afile);
anum = atoi(AREA.name);
while (keys) {
bitp = &USERCFG.msgarea1[anum / 16];
mask = 1;
for (x=0; x < (anum % 16); x++)
mask = mask << 1;
keys = AREA.msglock;
if (!keys) /* No locks for this area */
keys = TRUE;
else { /* User must have same locks */
keys = AREA.msglock & LastUser.key;
if (keys != AREA.msglock)
keys = FALSE;
}
if (isskiparea(anum))
keys = FALSE; /* If Sysop set skip, don't build this area */
if (AREA.msgpath[0] && (LastUser.priv >= AREA.msgpriv) && keys) {
count++; /* Possible areas count */
if (*bitp & mask) { /* User has selected this area */
msgupd = (struct msgupd_st *) malloc(sizeof(struct msgupd_st));
if (msgupd == NULL)
aborterror(BADALLOC,NULL);
if (MSGUPD_1 == NULL)
MSGUPD_1 = msgupd; /* Link in top of pointer */
else MSGUPD_cur->next = msgupd;
msgupd->areano = atoi(AREA.name);
strcpy(msgupd->msgpath,AREA.msgpath);
msgupd->update = FALSE;
switch (AREA.area_type) {
case 0: /* Fido 1.msg style */
msgupd->himsg = find_fidohigh(AREA.msgpath);
break;
default:
msgupd->himsg = find_fidohigh(AREA.msgpath);
break;
}
if (msgupd->himsg == 0xffff )
msgupd->himsg = 0;
msgupd->areaindex = ftell(afile) - (long) astrlen; /* Position */
msgupd->next = NULL;
msgupd->startmsg = 1;
msgupd->readmsgs = 0;
MSGUPD_cur = msgupd;
if (msgupd->himsg) {
if (LastUser.lastread_ptr)
sprintf(temp1,"%slastread.bbs",AREA.msgpath);
else sprintf(temp1,"%slastread",AREA.msgpath);
x = sopen(temp1,O_RDONLY | O_BINARY,SH_DENYNO,S_IREAD); /* Poke into the lastread file */
if (x != -1) {
lerr = lseek(x,(long)(LastUser.lastread_ptr * sizeof(int)),SEEK_SET);
if (lerr != -1L) {
read(x,(char *) &msgupd->startmsg,sizeof(int)); /* Get last message read */
if (msgupd->startmsg > msgupd->himsg)
msgupd->startmsg = msgupd->himsg;
if (msgupd->startmsg < 1)
msgupd->startmsg = 1;
msgupd->msgcount = msgupd->himsg - msgupd->startmsg;
if (msgupd->msgcount < 0)
msgupd->msgcount = 0;
}
close(x);
}
}
else {
msgupd->startmsg = 0;
msgupd->msgcount = 0;
}
}
}
keys = read(index,(char *)&IDX,sizeof(struct _aidx));
fseek(afile,IDX.offset,SEEK_SET);
fread(&AREA,astrlen,1,afile);
anum = atoi(AREA.name);
while ( anum > MaxScan && keys) { /* Stop Scan */
keys = read(index,(char *)&IDX,sizeof(struct _aidx));
fseek(afile,IDX.offset,SEEK_SET);
fread(&AREA,astrlen,1,afile);
anum = atoi(AREA.name);
}
}
close(index);
return(count);
}
/* Scan message areas,build capture file */
int scan_msgs()
{
int x,y,firsttime;
FILE *headfile;
FILE *statfile;
FILE *sfile;
struct msghead *MSGHD;
if (MSGUPD_1 == NULL) {
logit("User has no message areas selected",'!');
strout("\r\nYou have no valid message areas selected.");
strout("\r\nSelect [C] at menu prompt and change your configuration\r\n");
return(FALSE);
}
if (PackDone){
return(FALSE);
}
if (Task) { /* Rename TxtFile to have tasknumber */
_splitpath(TxtFile,hdrive,hdir,temp,temp1);
temp[6] = 0; /* Trim out 2 chars */
sprintf(TxtFile,"%s%02d%s",temp,Task,temp1);
}
outfile = _fsopen(TxtFile,"w+",SH_DENYNO);
if (outfile == NULL) {
sprintf(temp1,"Error creating %s",TxtFile);
aborterror(FILECREATE,temp1);
}
totmsgs = 0;
firsttime = TRUE;
MSGHD = (struct msghead *) malloc(sizeof(struct msghead));
if (MSGHD == NULL)
aborterror(BADALLOC,NULL);
MSGHD->answers = NULL;
strcpy(MSGHD->ourname,LastUser.name);
msgupd = MSGUPD_1;
while (msgupd) {
fseek(afile,msgupd->areaindex,SEEK_SET);
fread(&AREA,astrlen,1,afile);
if (firsttime) {
fprintf(outfile,"\n MaxMail Version %.2f Custom message archive for %s\n",Version,USERCFG.name);
fprintf(outfile," ---> Messages were captured on %s\n",timestring());
if (MsgHdrFile[0]) { /* Sysop wants to put in a message header file */
headfile = _fsopen(MsgHdrFile,"rt",SH_DENYNO);
if (headfile == NULL)
logit("Message Header file could not be opened.",'!');
else {
fgets(temp,80,headfile);
while (!feof(headfile)) {
fputs(temp,outfile);
fgets(temp,80,headfile);
}
fclose(headfile);
}
}
if (StatName[0]) {
if (Task) {
sprintf(temp,".%d",Task);
strcat(StatName,temp);
}
statfile = _fsopen(StatName,"wt",SH_DENYNO);
}
else statfile = NULL;
if (SumFile[0])
unlink(SumFile);
strout("\r\n\r\n--------[ Grinding the sysop's disk now ]-----------------");
strout("\r\n Start High New Your");
strout("\r\nMessage Area Msg Msg Msgs Msgs");
strout("\r\n----------------------------------------------------------\r\n");
if (statfile != NULL) {
fprintf(statfile,"\n----------------[ MaxMaxil Statistics ]-------------------");
fprintf(statfile,"\n Start High New Your");
fprintf(statfile,"\nMessage Area Msg Msg Msgs Msgs");
fprintf(statfile,"\n----------------------------------------------------------\n");
}
firsttime = FALSE;
}
msgupd->readmsgs = 0;
if (msgupd->msgcount > 0) { /* If there are messages in this area */
MSGHD->ourmail = 0;
if (MSGHD->answers != NULL)
free(MSGHD->answers);
MSGHD->answers = NULL;
x = load_area(msgupd,statfile,MSGHD); /* Return lastread msgnum */
if (msg_update) {
msgupd->update = TRUE;
msgupd->readmsgs = x - msgupd->startmsg; /* Establish last message read */
}
if (statfile != NULL && MSGHD->ourmail) {
sprintf(temp," You have %d personal messages in this area.\r\n",MSGHD->ourmail);
strout(temp);
fprintf(statfile," You have %d personal messages in this area. See messages: \n",MSGHD->ourmail);
y = 0;
fprintf(statfile," ");
for (x = 0; x < MSGHD->ourmail; x++) {
if (x < (MSGHD->ourmail - 1))
fprintf(statfile,"%d,",MSGHD->answers[x]);
else fprintf(statfile,"%d",MSGHD->answers[x]);
if(++y > 20) {
fprintf(statfile,"\n ");
y = 0;
}
}
fprintf(statfile,"\n");
}
}
if (totmsgs >= MaxMsgs) {
sprintf(temp1,"\r\nPoof! You've gobbled up the maximum # of messages (%d) for this run\r\n",totmsgs);
strout(temp1);
if (LogMode == VERBOSE)
logit("User has used up maximum messages for this run",'#');
break;
}
msgupd = msgupd->next;
}
fprintf(outfile," \n\n ---> %d Total messages were captured <---\n",totmsgs);
fclose(outfile);
if (statfile != NULL) {
sfile = _fsopen(SumFile,"rt",SH_DENYNO);
if (SumFile[0] && sfile != NULL) {
while (!feof(sfile)) {
if(fgets(temp1,80,sfile) != NULL)
fputs(temp1,statfile);
}
fclose(sfile);
}
fclose(statfile);
}
if (SumFile[0])
unlink(SumFile);
if (MSGHD->answers != NULL)
free(MSGHD->answers);
free(MSGHD);
return(TRUE);
}
/* Scan individual message area,called from Scan_msgs(), get
message text and write to capture file, stats file */
int load_area(struct msgupd_st *msgupd,FILE *statfile,struct msghead *MSGHD)
{
int x,y,msgcount,divisor;
int forward,fidoflags;
FILE *sumfile;
if (msgupd->himsg > 0) {
fprintf(outfile,"\n\n\n *************************************************************\n");
if (AREA.attrib[UserClass] & ECHOMAIL)
sprintf(temp," ** Echomail Area %s - %s ",AREA.name,AREA.msginfo);
else sprintf(temp," ** Local/Public Area %s - %s ",AREA.name,AREA.msginfo);
while (strlen(temp) < 60)
strcat(temp," ");
strcat(temp,"**");
fprintf(outfile,"%s\n",temp);
fprintf(outfile," *************************************************************\n");
strncpy(temp1,AREA.msginfo,24);
temp1[24] = 0;
while (strlen(temp1) < 24)
strcat(temp1," ");
sprintf(temp,"[%03d] %s %04d %04d %04d ",atoi(AREA.name),temp1,msgupd->startmsg,msgupd->himsg,msgupd->msgcount);
if (statfile != NULL)
fprintf(statfile,"[%03d] %s %04d %04d %04d ",atoi(AREA.name),temp1,msgupd->startmsg,msgupd->himsg,msgupd->msgcount);
if (SumFile[0]) {
sumfile = _fsopen(SumFile,"at",SH_DENYNO);
if (statfile != NULL) {
fprintf(sumfile,"\n\n************ Message Subject Summary ************************\n");
if (AREA.attrib[UserClass] & ECHOMAIL)
sprintf(temp1,"** Echomail Area %s - %s ",AREA.name,AREA.msginfo);
else sprintf(temp1,"** Local/Public Area %s - %s ",AREA.name,AREA.msginfo);
while (strlen(temp1) < 59)
strcat(temp1," ");
strcat(temp1,"**");
fprintf(sumfile,"%s\n",temp1);
fprintf(sumfile,"*************************************************************\n");
fprintf(sumfile,"Msg# From Subject\n");
fprintf(sumfile,"-------------------------------------------------------------\n");
}
}
strout(temp);
msgcount = 0;
forward = 1; /* Activity flag */
fidoflags = 0;
if (LastUser.priv < SYSOP && !(AREA.attrib[UserClass] & ECHOMAIL))
fidoflags |= PRIVATE;
if (msgupd->msgcount > 40) /* Total messages in this area */
divisor = 3;
else divisor = 2; /* Flip activity flag a little more */
for (x=msgupd->startmsg+1; x <= msgupd->himsg && (totmsgs < MaxMsgs); x++) {
memset(MSGHD->subject,0,72);
switch (AREA.area_type) {
case 0: /* Fido 1.msg style */
y = file_fidomsg(x,fidoflags,outfile,msgupd,MSGHD);
break;
default:
y = file_fidomsg(x,fidoflags,outfile,msgupd,MSGHD);
break;
}
if (y < 0) { /* Some kind of error */
if (y == PVTMSG_ERR) /* No real error, just a private msg */
msgcount++;
else if ( y !=FILE_SRCH_ERR) { /* No messages to strip */
strout(" No new msgs!\r\n"); /* This really should be impossible */
break;
}
}
else { /* A message was read */
if (sumfile != NULL) { /* Muck with the summary file */
sprintf(temp1,"%d",y);
while (strlen(temp1) < 8 )
strcat(temp1," ");
fprintf(sumfile,"%s",temp1);
sprintf(temp1,"%s",MSGHD->from);
while (strlen(temp1) < 36 )
strcat(temp1," ");
fprintf(sumfile,"%s ",temp1);
strncpy(temp1,MSGHD->subject,34);
temp1[34] = 0;
fprintf(sumfile,"%s\n",temp1);
}
msgcount++;
totmsgs++;
}
if (!(msgcount % divisor)) { /* A little activity display logic */
switch (forward) {
case 1:
strout("\b/");
forward++;
break;
case 2:
strout("\b-");
forward++;
break;
case 3:
strout("\b\\");
forward = 1;
break;
}
}
}
if (!msgcount) /* No messages in this area */
strout(" No new msgs!\r\n"); /* Again, really impossible */
else {
if (msgcount >= 3)
strout("\b ");
sprintf(temp,"\b%04d\r\n",msgcount);
strout(temp);
if (statfile != NULL)
fprintf(statfile,"%04d\n",msgcount);
}
}
if (sumfile != NULL)
fclose(sumfile);
return y;
}
/* Pack user capture file & summary file into designated packer */
int packit(void)
{
int x,old;
char *p,*p1,*p2;
char fext[5];
char command[81]; /* New Var to get around swap() */
FILE *new;
PackDone = FALSE;
x = USERCFG.packer;
if (!x) /* Must ask */
get_packer(FALSE);
packer1 = get_curpacklnk();
USERCFG.packer = x;
_splitpath(packer1->packpname,temp,temp,fname,fext);
x = strlen(fname);
x = x <= 6 ? x : 6;
strncpy(ArcFile,fname,x);
ArcFile[x] = '\0';
old = USERCFG.packcount;
while (old > 99) {
old -= 100;
}
sprintf(temp,"%02d",old);
strcat(ArcFile,temp);
strcat(ArcFile,fext);
while(stat(ArcFile,&fbuf) == 0 ) { /* Uh oh. File exists! try next one */
strncpy(ArcFile,fname,x);
ArcFile[x] = '\0';
sprintf(temp,"%02d",++old);
strcat(ArcFile,temp);
strcat(ArcFile,fext);
}
#if defined OS2
_searchenv("Cmd.exe","PATH",fname);
#else
_searchenv("Command.com","PATH",fname);
#endif
if (*fname == '\0') {
aborterror(BADEXEC,NULL);
}
sprintf(temp," /c %s",packer1->packexe);
/* All this junk to parse packer command line and build execute string */
strcpy(temp1,packer1->packstring);
p = strtok(temp1,"%"); /* Up to 1st token */
strcat(temp,p);
strcat(temp," ");
p1 = strtok(NULL,"%"); /* Up to 2nd token */
if (tolower(p1[0]) == 'a') /* Arcfile */
strcat(temp,ArcFile);
else strcat(temp,TxtFile); /* Txtfile */
strcat(temp,p1+2);
strcat(temp," ");
p2 = strtok(NULL,"\0");
p1 = strtok(NULL,"\0"); /* Get rest of line */
if (tolower(p2[0]) == 'a') /* Arcfile */
strcat(temp,ArcFile);
else strcat(temp,TxtFile); /* Txtfile */
sprintf(temp1,"\r\n\r\nNow packing up %d messages using %s \r\n",totmsgs,packer1->packname);
strout(temp1);
strout("Please wait while I call the packer program.....\r\n");
printf("Command line: %s %s\n",fname,temp);
sprintf(temp1,"Maxmal%02d.swp",Task);
/* Execute the packer */
#if defined OS2
strcpy(command,"");
strcat(command,fname);
strcat(command,temp);
x = system(command);
if (x == -1) {
#else
x = swap(fname,temp,&exec_ret,temp1);
if (x || exec_ret) {
#endif
strout("\r\nOh Oh! Packer had some kind of error\r\n");
strout("Shipping you back to Maximus!\r\n\r\n");
sprintf(temp,"Packer program error code: %d",exec_ret);
logit(temp,'!');
aborterror(BADEXEC,"Error executing packer program");
}
if (StatName[0]) {
/* We need to build command string again to add summary file */
sprintf(temp," /c %s",packer1->packexe);
strcpy(temp1,packer1->packstring);
p = strtok(temp1,"%"); /* Up to 1st token */
strcat(temp,p);
strcat(temp," ");
p1 = strtok(NULL,"%"); /* Up to 2nd token */
if (tolower(p1[0]) == 'a') /* Arcfile */
strcat(temp,ArcFile);
else strcat(temp,StatName); /* StatName */
strcat(temp,p1+2);
strcat(temp," ");
p2 = strtok(NULL,"\0");
p1 = strtok(NULL,"\0"); /* Get rest of line */
if (tolower(p2[0]) == 'a') /* Arcfile */
strcat(temp,ArcFile);
else strcat(temp,StatName); /* StatName */
printf("Command line: %s %s\n",fname,temp);
sprintf(temp1,"Maxmal%02d.swp",Task);
/* Execute the packer again */
#if defined OS2
strcpy(command,"");
strcat(command,fname);
strcat(command,temp);
x = system(command);
if (x == -1) {
#else
x = swap(fname,temp,&exec_ret,temp1);
if (x || exec_ret) {
#endif
strout("\r\nOh Oh! Packer had some kind of error\r\n");
strout("Shipping you back to Maximus!\r\n\r\n");
sprintf(temp,"Packer program error code: %d",exec_ret);
logit(temp,'!');
aborterror(BADEXEC,"Error executing packer program");
}
}
if (packer1->viewstring) { /* Call up packer again, showing viewline */
sprintf(temp," /c %s",packer1->packexe);
strcpy(temp1,packer1->viewstring);
p = strtok(temp1,"%"); /* Up to 1st token */
strcat(temp,p);
strcat(temp," ");
p1 = strtok(NULL,"%"); /* Up to 2nd token */
if (tolower(p1[0]) == 'a') /* Arcfile */
strcat(temp,ArcFile);
strcat(temp," ");
p1 = strtok(NULL,"\0"); /* Get rest of line */
if (p1) strcat(temp,p1);
printf("Command line: %s %s\n",fname,temp);
if (!IsLocal) {
old = dup(1); /* old now refers to stdout */
ReDirect = TRUE;
}
sprintf(temp1,"tmpmax%02d",Task);
new = _fsopen(temp1,"w+",SH_DENYNO);
if (new != NULL) {
if (!IsLocal)
dup2(fileno(new),1); /* Reroute stdout to file */
sprintf(temp1,"Maxmal%02d.swp",Task);
/* Execute the ARCHIVE viewing command */
#if defined OS2
strcpy(command,"");
strcat(command,fname);
strcat(command,temp);
x = system(command);
#else
x = swap(fname,temp,&exec_ret,temp1);
#endif
/* Now display tmp file to user */
fclose(new);
sprintf(temp1,"tmpmax%02d",Task);
if (!IsLocal) {
show_file(temp1);
dup2(old,1); /* Restore stdout */
ReDirect = FALSE;
}
unlink(temp1);
}
}
stat(ArcFile,&fbuf);
sprintf(temp,"Packing up %d messages using %s",totmsgs,packer1->packexe);
logit(temp,'#');
sprintf(temp,"Packed filesize is %lu bytes",fbuf.st_size);
logit(temp,'#');
PackDone = TRUE; /* Say yes, it's accepted */
return(TRUE);
}
/* Transmit user archive file, with designated protocol engine */
int sendit(void)
{
int x;
long calc;
char *p,*p1,*p2;
char portstr[3];
char command[81]; /* New Var for call to system() */
x = USERCFG.protocol; /* Save current protocol type */
if (!x)
get_proto(FALSE);
proto1 = get_curprotolnk();
USERCFG.protocol = x;
_searchenv(proto1->protoexe,"PATH",fname);
strcpy(temp1,proto1->protostring);
p = strtok(temp1,"%"); /* Up to 1st token */
strcpy(temp,p);
p1 = strtok(NULL,"%"); /* Up to 2nd token */
/* Parse protocol string and build command line */
while (*p1) {
switch (tolower(p1[0])) {
case 'a':
strcat(temp,ArcFile);
break;
case 'p':
#if defined OS2
sprintf(portstr,"%d",hfComHandle); /* Com1 or com2 */
#else
sprintf(portstr,"%d",prm.com_port + 1); /* Com1 or com2 */
#endif
strcat(temp,portstr);
break;
case 'b':
sprintf(portstr,"%d",LastUser.flag); /* Baudrate */
strcat(temp,portstr);
break;
default:
strcat(temp,p1);
break;
}
p1++;
if (*p1)
strcat(temp,p1);
strcat(temp," ");
if (*p1) /* Only if (*p1) */
p1 = strtok(NULL,"%"); /* Up to 2nd token */
}
stat(ArcFile,&fbuf);
sprintf(temp1,"\r\nPacked message file (%s) is %lu bytes\r\n",ArcFile,fbuf.st_size);
strout(temp1);
calc = (long) get_kminute();
if (calc) {
calc = fbuf.st_size / calc;
if (calc <= 0)
calc = 1;
}
else calc = 1;
sprintf(temp1,"It will take about %ld minute(s) to download\r\n",calc);
strout(temp1);
strout("Are you sure you want to download it? [y,N] -> ");
strin(temp1);
strout("\r\n");
p1 = strtok(temp1," \r\n\;");
if (!p1)
return FALSE;
if (toupper(*p1) == 'Y' || toupper(*p1) == 'H') {
if (IsLocal) {
USERCFG.packcount++;
return TRUE;
}
if (toupper(*p1) == 'H')
Hangup = TRUE;
sprintf(temp1,"Transmit %s using %s",ArcFile,proto1->protoname);
logit(temp1,'=');
sprintf(temp1,"Prepare to download %s using %s \r\n",ArcFile,proto1->protoname);
strout(temp1);
printf("Command line: %s %s\n",fname,temp);
sprintf(temp1,"Maxmal%02d.swp",Task);
/* Execute the protocol engine */
#if defined OS2
strcpy(command,"");
strcat(command,fname);
strcat(command,temp);
x = system(command);
if (x == -1) {
#else
fos_deinit(prm.com_port); /* Turn off port from us */
x = swap(fname,temp,&exec_ret,temp1);
fos_init(prm.com_port,TRUE,(char _far *) &break_flag); /* Restart port */
if (x || exec_ret) {
#endif
strout("\r\nOh Oh! Xfer program had some kind of error\r\n");
sprintf(temp,"Error code from xfer program: %d",exec_ret);
logit(temp,'!');
strout("Popping you back to Maximus!\r\n\r\n");
aborterror(BADEXEC,"Error executing xfer program");
}
strout("\r\nNo errors occured during transfer.\r\n");
USERCFG.packcount++;
return(TRUE);
}
else return FALSE;
}
unsigned get_msgcount(void)
{
unsigned x;
x = 0;
msgupd = MSGUPD_1;
while (msgupd) {
x += msgupd->msgcount;
msgupd = msgupd->next;
}
return x;
}
void newuser_help(void)
{
if(show_file(NewHelpFil) >= 0) {
#if defined OS2
pause();
nl();
#else
strout("\r\n\r\nPress any key to get the heck outa here!");
chrin();
strout("\r\n");
#endif
}
}
int show_file(char *strng)
{
FILE *newfile;
int linecount;
char ltemp[81];
if (strng[0] == '\0')
return(-1); /* No help file */
newfile = _fsopen(strng,"r",SH_DENYNO); /* Open in read only, text mode */
if (newfile == NULL) {
sprintf(ltemp,"Error opening %s file for user.",strng);
logit(ltemp,'!');
return(-1); /* Just skip it */
}
#if defined OS2
fclose(newfile);
printfile(strng);
#else
linecount = 0;
while (!feof(newfile)) {
fgets(ltemp,80,newfile);
strout(ltemp);
strout("\r");
if (++linecount > 20) { /* Turn on more for paging */
strout("\r\n\r\nPress any key for more");
chrin();
strout("\r\n");
linecount = 0;
}
}
fclose(newfile);
#endif
return(0);
}
struct msgupd_st *build1_area(int msgnum)
{
int keys,mask,x;
long lerr;
struct msgupd_st *this;
rewind(afile); /* Start at top again */
fread(&AREA,astrlen,1,afile);
while (!feof(afile) && msgnum != atoi(AREA.name))
fread(&AREA,astrlen,1,afile);
if (feof(afile))
return NULL;
mask = 1;
for (x=0; x < (msgnum % 16); x++)
mask = mask << 1;
keys = AREA.msglock;
if (!keys) /* No locks for this area */
keys = TRUE;
else { /* User must have same locks */
keys = AREA.msglock & LastUser.key;
if (keys != AREA.msglock)
keys = FALSE;
}
if (AREA.msgpath[0] && (LastUser.priv >= AREA.msgpriv) && keys) {
this = (struct msgupd_st *) malloc(sizeof(struct msgupd_st));
if (this == NULL)
aborterror(BADALLOC,NULL);
this->areano = atoi(AREA.name);
strcpy(this->msgpath,AREA.msgpath);
this->update = FALSE;
switch (AREA.area_type) {
case 0: /* Fido 1.msg style */
this->himsg = find_fidohigh(AREA.msgpath);
break;
default:
this->himsg = find_fidohigh(AREA.msgpath);
break;
}
this->areaindex = ftell(afile) - (long) astrlen; /* Position */
this->next = NULL;
this->startmsg = 0;
this->readmsgs = 0;
if (LastUser.lastread_ptr)
sprintf(temp1,"%slastread.bbs",AREA.msgpath);
else sprintf(temp1,"%slastread",AREA.msgpath);
x = sopen(temp1,O_RDONLY | O_BINARY,SH_DENYNO,S_IREAD); /* Poke into the lastread file */
if (x != -1) {
lerr = lseek(x,(long)(LastUser.lastread_ptr * sizeof(int)),SEEK_SET);
if (lerr != -1L) {
read(x,(char *) &this->startmsg,sizeof(int)); /* Get last message read */
if (this->startmsg > this->himsg)
this->startmsg = this->himsg;
this->msgcount = this->himsg - this->startmsg;
if (this->msgcount < 0)
this->msgcount = 0;
}
close(x);
}
}
return this;
}
void show_opts(void)
{
printf("\nMaxmail Version: %2.2f by Craig Derouen\n",Version);
printf("Last compiled: %s\n",__TIMESTAMP__);
printf("Command line options:\n");
printf("\t /A: Adjust for time user is online\n");
printf("\t /C: Specify alt Maxmail USER config file\n");
printf("\t /L: Turns on local mode. No fossil handling\n");
printf("\t /N: Don't delete archive pack on exit (Use with local mode)\n");
printf("\t /P: Specify alt Max.prm file\n");
printf("\t /T: Specify Task number. Tells Maxmail we are running multiuser\n");
printf("\t /U: Don't update LASTREAD message pointers\n");
#if defined OS2
printf("\t /G: Turns on Ansi Graphics.\n");
printf("\t /C: Passes the OS/2 Port Handle from a Spawn port\n");
printf("\t /V: Passes a Number (7=mono,15=Color) for Monitor Type\n");
printf("\t /S: Passes a Number (1) for High Speed Modems\n");
printf("\t /W: Passes a Number (1) for Locked High Speed Modems\n");
#endif
printf("\t {Filename} use this file as alt Maxmail.cfg file\n");
exit(0);
}