Category : BBS Programs+Doors
Archive   : QWKMOD80.ZIP
Filename : QWKGLUE.C

 
Output of file : QWKGLUE.C contained in archive : QWKMOD80.ZIP

/*
* Abiogenetic WWIV QWK Door for WWIV 4.21a Copyright 1991, 1992 - Barry Watson, Abiogenetic Software, all rights reserved.
*
* For support, call Abiogenetic BBS 612-774-8454 HST/V.32 FidoNet 1:282/113 WWIVnet 6261 WWIVlink 16257
*
*/

/*
* Functions in this file are used to pass your userrec data to/from qwk_reader().
*
* Under most circumstances, this file should not require modification. In the rare cases where it does, I trust that you will have little difficulty following this simplistic code.
*
* !NEVER! Change the qwkuserrec structure! This would cause failure.
*
*/

#include "vardec.h" /* Your BBS's vardec.h */
#include "vars.h"

extern userrec thisuser; /* BBS's (maybe modified?) userrec */
extern qwkuserrec qwkuser; /* User data needed for QWK reader */

void qwk_load_urec(void)
/* Copies contents of BBS's userrec to QWK's userrec */
{
int i;

strcpy(qwkuser.name, thisuser.name);
strcpy(qwkuser.laston, thisuser.laston);

qwkuser.sl = thisuser.sl;
qwkuser.waiting = thisuser.waiting;
qwkuser.daten = thisuser.daten;
qwkuser.msgread = thisuser.msgread;
qwkuser.sysstatus = thisuser.sysstatus;
}

void qwk_save_urec(void)
{
/* Update BBS's userrec with qwk's userrec */
int i;

thisuser.sysstatus = qwkuser.sysstatus;
thisuser.msgread = qwkuser.msgread;
}

void qwkdlfn(void)
{
/* Executed before a QWK download happens */
/* Sky's excellent New-Files mod! */
remove_from_temp("NEWFILES.DAT", syscfg.gfilesdir, 0);
prt(2, "Gather a list of new files for your QWK packet? ");
if (yn())
{
nl();
pl("Please Wait...");
set_x_only(1, "NEWFILES.DAT", 1);
nscanall();
set_x_only(0, NULL, 0);
}
else
{
remove_from_temp("NEWFILES.DAT", syscfg.gfilesdir, 0);
}
}

void qwkulfn(void)
{
/* Executed before each REP upload begins */
}

/*
Functions below are used by QWK interface
Do NOT change parameters or return values!
*/

void copy_files(void)
{
char s[81], s1[81];
sprintf(s, "%sWELCOME.ANS", syscfg.gfilesdir);
sprintf(s1, "%sWELCOME.ANS", syscfg.tempdir);
if (exist(s))
{
file_copy(s, s1);
}
sprintf(s, "%sNEWS.MSG", syscfg.gfilesdir);
sprintf(s1, "%sNEWS.MSG", syscfg.tempdir);
if (exist(s))
{
file_copy(s, s1);
}
sprintf(s, "%sLOGOFF.ANS", syscfg.gfilesdir);
sprintf(s1, "%sLOGOFF.ANS", syscfg.tempdir);
if (exist(s))
{
file_copy(s, s1);
}

sprintf(s, "%sNEWFILES.DAT", syscfg.gfilesdir);
sprintf(s1, "%sNEWFILES.DAT", syscfg.tempdir);
if (exist(s))
{
file_copy(s, s1);
}
}

void file_copy(char *input, char *output)
{
int d1, d2, i;
char *b;

if ((strcmp(input, output) != 0) && (exist(input)))
{
if ((b = malloca(16400)) == NULL)
return;
d1 = open(input, O_RDONLY | O_BINARY);
d2 = open(output, O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
i = read(d1, (void *) b, 16384);
while (i > 0)
{
write(d2, (void *) b, i);
i = read(d1, (void *) b, 16384);
}
close(d1);
close(d2);
farfree(b);
}
}

void del_all_mail(void)
{
int i, i1, i2, i3, f, mw, mloc[256], mfl, abort, next;
char s[81], s1[81], s2[81], fn[81], *b;
mailrec m;
char ch;

sprintf(fn, "%sEMAIL.DAT", syscfg.datadir);
f = open(fn, O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
if (f < 0)
{
nl();
pl("No mail file exists!");
nl();
return;
}
mfl = filelength(f) / sizeof(mailrec);
mw = 0;
for (i = 0; (i < mfl) && (mw < 255); i++)
{
lseek(f, ((long) (i)) * (sizeof(mailrec)), SEEK_SET);
read(f, (void *) (&m), sizeof(mailrec));
if ((m.tosys == 0) && (m.touser == usernum))
mloc[mw++] = i;
}
qwkuser.waiting = mw;
if (usernum == 1)
fwaiting = mw;
if (mw == 0)
{
nl();
pl("No mail to delete.");
return;
}
for (i = 0; i < mw; i++)
{
delmail(f, mloc[i]);
}
nl();
pl("Mail deleted.");
helpl = 10;
close(f);
}