home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /*======================================================================*/
- /* XBBS Bulletin Board System.....U/D routines */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
-
- void pascal pauseit (void) {
-
- char a;
- ulong start;
- int register x;
-
- start=getxbbstime();
- a=pauser;
- pauser=0;
- fossil(FLUSHOUT,0);
- fossil (PURGEIN,0);
- lprint ("[Paused]");
- while (!inkey() && (getxbbstime()-start)<45L);
- for (x=0;x<8;x++) lprint (BACKSPACE);
- pauser=a;
-
- }
-
-
- char pascal filesbbs (fname,type,sdate,searchstring)
- /* READS FILES.BBS TO MODEM & SCREEN
- !(type & 1) = from d/l path
- type & 1 = from u/l path
- type & 2 = newlist
- type & 4 = use searchstring
- type & 8 = recognize 'D'
- type & 16 = recognize 'M'
- */
- char *fname;
- char type;
- char *sdate;
- char *searchstring;
-
- {
-
- int register x;
- int handle;
- char path[81];
- char mask[26];
- char dupe[81];
- char str[256];
- char a;
- char *b;
- char *bb;
- char filename[94];
- char p;
- char new[14]="";
- char saidone=0;
- struct ffblk f;
- word dls;
- char limitarea=0;
- char asktodl=0;
- char asktomark=0;
-
- ulong temppos;
- ulong pos[77];
- signed char page;
-
- struct fdate {
- bit day: 5;
- bit month: 4;
- bit year: 7;
- };
- union df {
- struct fdate fd;
- int x;
- } fdf,fdu;
- struct ftime {
- bit sec: 5;
- bit min: 6;
- bit hour: 5;
- };
- union tf {
- struct ftime ft;
- int x;
- } fdt;
- char should=0;
- static char comstring[26]="";
- char showcomments=0;
-
- #ifdef UDDEBUG
- gprintf(LOCALONLY,"\n\04Before: %s\n",sdate);
- #endif
-
- pauser=0;
- if(type & 128) {
- type=(type &(~128));
- limitarea=1;
- }
- if(type & 8) {
- type = type &(~8);
- asktodl=1;
- }
- if(type & 16) {
- type = type &(~16);
- asktomark=1;
- }
- if (!(type & 1))strcpy(path,fboard.dpath);
- else strcpy(path,fboard.upath);
- sprintf(filename,"%s%s",path,fname);
-
- if(!*comstring)strncpy(comstring,say_prompt(268),26);
- if ((handle=oopen(filename,O_RDONLY | O_TEXT | O_DENYNONE))==-1) return 4;
-
- fdu.fd.month=(unsigned)atoi(strtok(sdate,"/"));
- fdu.fd.day=(unsigned)atoi(strtok(0,"/"));
- fdu.fd.year=(unsigned)(atoi(strtok(0,"\n"))-1980);
-
- #ifdef UDDEBUG
- gprintf(LOCALONLY,"\n\04After: Month: %u Day: %u Year: %u\n",fdu.fd.month,fdu.fd.day,fdu.fd.year);
- #endif
-
- *mask=0;
- if (type<2) {
- say_prompt(274);
- helpnum=524;
- strcpy(mask,genin(25,0,1,0,ALLL));
- helpnum=0;
- if (!*mask && type<2) {
- cls();
- if ((!baud || baud>=1200) && (user.graphics)) {
- gprintf(0,say_prompt(339),fboard.name);
- lines++;
- }
- }
- else {
- if(wherex()!=1) {
- printm("\n");
- lines++;
- }
- }
- }
- else {
- if(wherex()!=1) {
- printm("\n");
- lines++;
- }
- }
- if(type&4) {
- if(searchstring) {
- strncpy(mask,searchstring,26);
- mask[25]=0;
- }
- }
-
- if(type & 2) strcpy(str,"New-");
- else *str=0;
- if (conf.logfiles) gprintf(LOGONLY,"%sListed %s (%s)",str,filename,mask);
-
- page=0;
- pos[0]=0;
-
- while (!eof(handle)) {
- DoItAgain:
-
- if ((!(b=fgetsx(str, 81, handle)))) goto nomore;
- if(!showcomments) if(first_non_white(b)==';') continue;
-
- DoItOver:
- pauser=2;
- getxbbstime();
- if (*mask) {
- strcpy(dupe,str);
- if (!stristr(dupe,mask)) {
- p=0;
- goto Loop;
- }
- }
- if(*b==';') b++;
- if (*b && *b!=' ' && *b!='\n') if (strcspn(b," ")<13 || strlen(b)<13) {
- if(!eof(handle) && limitarea) {
- AgainAndAgain:
- temppos=tell(handle);
- if(fgetsx(dupe,81,handle)) {
- dupe[80]=0;
- if(!strncmp(dupe," ;Area: ",7)) {
- bb=&dupe[6];
- stripcr(bb);
- lstrip(bb);
- rstrip(bb);
- if(stricmp(bb,fboard.name)) { /* Not current area */
- while(!eof(handle)) {
- if(!fgetsx(str,81,handle)) break;
- if((!showcomments && first_non_white(str)==';') || strncmp(b," ",30)) break;
- }
- continue;
- }
- }
- if(!showcomments && first_non_white(dupe)==';') goto AgainAndAgain;
- }
- lseek(handle,temppos,SEEK_SET);
- }
- b=strtok(b," \n");
- b=strtok(0,"\0");
- b=lstrip(b);
- if (*b && b[strlen(b)-1]!='\n') strcat(b,"\n");
- if (!*str) goto nomore;
- bb=str;
- if(*bb==';') bb++;
- if (type & 2) {
- sprintf(filename,"%s%s",path,bb);
- if(findfirst(filename,&f,0)) goto nomore;
- fdf.x=f.ff_fdate;
- if (fdf.x<fdu.x) {
- b=NULL;
- goto nomore;
- }
- }
- saidone=1;
- printg("\x1b[0;1;33m");
- gprintf(0,"%-12s",str);
- sprintf(filename,"%s%s",path,bb);
- if(findfirst(filename,&f,0)!=0) {
- printg("\x1b[37m");
- printm(" MISSING ");
- if (b==NULL || !*b) {
- printm("\n");
- lines++;
- }
- goto nomore;
- }
- fdf.x=f.ff_fdate;
- fdt.x=f.ff_ftime;
- dls=(word)fdt.x;
- if (fdf.x>=fdu.x) {
- (user.graphics) ? strcpy(new,"\x1b[0;1;5;31m*") : strcpy(new,"*");
- }
- else strcpy(new," ");
- if (user.graphics) gprintf(0,"\x1b[34m %-6lu \x1b[0;2;31m%02u/%02u/%02u%s",f.ff_fsize,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,new);
- else gprintf(0," %-6lu %02u/%02u/%02u%s",f.ff_fsize,fdf.fd.month,fdf.fd.day,(fdf.fd.year+80)%100,new);
- if (dls && (fboard.flags & COUNTDLS) && (strcmp(f.ff_name,"FILES.BBS"))) {
- if (dls>1) strcpy(new,"s");
- else *new=0;
- printg("\x1b[0;1;31m");
- if (user.graphics) gprintf(0,"(%u Download%s)\n\x1b[30C",((word)(dls)),new);
- else gprintf(0,"(%u Download%s)\n ",((word)(dls)),new);
- lines++;
- }
- if (lines>=(user.length-3)) should++;
- printg("\x1b[0;1;32m");
- if ((b!=NULL) && *b) {
- if(p=check4more()) goto Abort;
- if (strlen(b)+30>=user.width) lines+=2;
- else lines++;
- p=printm(b);
- }
- else {
- if (user.width>=47) lines++;
- say_prompt(151);
- }
- a=toupper(inkey());
- if ((a=='A') || (a == ' ') || (a == 'S') or (p)) goto Abort;
- if (a=='P' || a == 19) {
- pauseit();
- lines=0;
- }
- b=NULL;
- getxbbstime();
- temppos=tell(handle);
- if ((eof(handle)) || (!(b=fgetsx(str,80,handle)))) goto nomore;
- while ((!showcomments && first_non_white(b)==';') || !strncmp(b," ",30)) {
- if(!showcomments)if(first_non_white(b)==';') goto SkipComments;
- if (lines>=(user.length-3)) should++;
- if(p=check4more()) goto Abort;
- if (user.graphics) {
- b+=30;
- printg("\x1b[30C");
- }
- if(p=printm(b)) goto Abort;
- lines++;
- SkipComments:
- temppos=tell(handle);
- if ((!(b=fgetsx(str, 81, handle)))) break;
- }
- lseek(handle,temppos,SEEK_SET);
- b=NULL;
- }
-
- nomore:
-
- p=0;
- if (lines>=(user.length-2)) should++;
- if ((!(type & 2)) && b!=NULL && *b) {
- printg("\x1b[0;1;37m");
- lines++;
- p=printm(b);
- b=NULL;
- }
- Loop:
- if (eof(handle)==-1) lprint("\n\04ARGH!\n");
- a=toupper(inkey());
- Abort:
- if ((a == 'S') || (a == ' ') || (p) || (a=='A')) {
- fossil (PURGEOUT,0);
- fossil (PURGEIN,0);
- cclose(handle);
- if(a=='A') return 5;
- return 1;
- }
- if (a=='P' || a == 19) pauseit();
- if (user.graphics) if (saidone) if (!user.more) if (!baud || baud>300) if (lines>=(user.length-1) || (eof(handle)) || (should)) {
- Doitallagain:
- lines=should=0;
- lprint("\x1b[23;1H");
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- if (eof(handle)) {
- printg("\x1b[0;1;31m");
- say_prompt(438);
- }
- say_prompt(340);
- fossil(FLUSHOUT,0);
- fossil(PURGEIN,0);
- pos[page+1]=tell(handle);
- Getitagain:
- helpnum=525;
- a=*genin(1,0,1,1,ALPHA +128);
- helpnum=0;
- if(a) {
- for(x=0;x<27;x++) {
- if(!comstring[x])break;
- if(a==comstring[x]) {
- a=(char)x+1;
- break;
- }
- }
- }
- switch (a) {
- case 1: fputs("\r",stdout);
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- cclose(handle);
- return 1;
- case 2:
- case 0: if (eof(handle)) goto StopIt;
- a=0;
- if (++page>75) page=1;
- pos[page]=tell(handle);
- break;
- case 3:
- PageOver:
- lseek(handle,pos[page],SEEK_SET);
- break;
- case 4:
- case 5: if (!page) {
- printm(BACKSPACE);
- printm("\x7");
- goto Getitagain;
- }
- lseek(handle,pos[--page],SEEK_SET);
- break;
- case 6: if(asktodl) {
- fputs("\r",stdout);
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- cclose(handle);
- return 3;
- }
- goto Default;
- case 7: if(asktomark) {
- fputs("\r",stdout);
- if(baud)while(!fossil(TRANSMIT,'\r')) carrchk();
- readfile("MARKFILE.XBS",1,1,1);
- goto Doitallagain;
- }
- goto Default;
- case 8: if(!stricmp(user.name,conf.sysop) || !stricmp(user.handle,conf.sysop)) {
- showcomments=1-showcomments;
- goto PageOver;
- }
- goto Default;
- case 9: fputs("\r",stdout);
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- cclose(handle);
- return 5;
- default: {
- char s[13];
-
- sprintf(s,"FLBBS%03hu.XBS",a);
- if(readfile(s,1,1,1)==2) printm(BACKSPACE);
- else {
- printm("\n");
- goto Doitallagain;
- }
- goto Getitagain;
- }
-
- Default:
- printm(BACKSPACE);
- goto Getitagain;
- }
- fputs("\r",stdout);
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- printm("\x1b[K\x1b[0;1;35m");
- gprintf(0,say_prompt(341),fboard.name,page+1);
- lines++;
- }
- if(p=check4more()) goto Abort;
- }
-
- StopIt:
- cclose(handle);
- if (!saidone) return 2;
- return 0;
- }
-
-
- char pascal check4more (void) {
-
- char p=0;
-
- if (lines>=(user.length-1) && !user.more) {
- say_prompt(18);
- fossil(FLUSHOUT,0);
- fossil(PURGEIN,0);
- p = *genin(1,0,1,1,YESNOM);
- say_prompt(276);
- if (p == 'N') printm ("\n");
- else p=0;
- lines=0;
- }
- return p;
- }
-
-
-
- word pascal download (fname,proto,type)
-
- char *fname;
- struct protocol *proto;
- char type;
-
- {
- char s[133];
- ulong total;
- word nofiles=0;
- ulong transtime;
- char uselist=0;
- char tempsafe;
-
- tempsafe=safe;
- safe=0;
- printm("\n");
- if (*fname=='@') uselist=1;
- strcpy(s,fname);
- total=check_dls(s,&nofiles,1);
- if (total==0 || nofiles==0) {
- safe=tempsafe;
- return 0;
- }
- say_prompt(279);
- gprintf(0,say_prompt(280),total,nofiles);
- transtime=transfer_time(total,proto->adj);
- if (!(type & 128)) {
- if (transtime>=(ulong)((ulong)timelimit-(getxbbstime()/60))) {
- say_prompt(281);
- safe=tempsafe;
- level=1;
- return 0;
- }
- }
- gprintf(0,say_prompt(286),proto->name,proto->abort);
- strcpy(s,proto->spawndn);
- replace(s,fname);
- fossil(FLUSHOUT,0);
- if (!strchr(fname,'\\') && !uselist) {
- gothere(conf.downtime,s,0,proto);
- }
- else spawnit(s,0,0);
- if (!level || proto->dszlog) {
- if(!proto->dszlog) {
- strcpy(s,fname);
- total=check_dls(fname,&nofiles,2);
- gprintf(LOGONLY,"%c-D/L %s%s (%lu bytes)",proto->key,fboard.dpath,s,total);
- }
- else {
- do_dszlog(proto,0);
- }
- carrchk();
- sleep(1);
- say_prompt(283);
- timer_off=0;
- safe=tempsafe;
- return ((word)total/1024);
- }
- else {
- mprint(STOPDL);
- gprintf(LOGONLY,"Bad %c-D/L %s%s",proto->key,fboard.dpath,fname);
- carrchk();
- sleep(1);
- say_prompt(284);
- timer_off=0;
- safe=tempsafe;
- return 0;
- }
- }
-
-
-
-
- ulong pascal transfer_time (ulong total,int adj) {
-
- word tempbaud;
- ulong transtime;
-
- tempbaud=baud;
- if (!tempbaud) tempbaud=1200;
- transtime=(long)(((((long)total)/(long)tempbaud)*1000L)/(long)adj);
- gprintf(0,say_prompt(285),(word)(transtime/60L),(word)((transtime%60L)+((transtime%60L)==0)),tempbaud);
- return (transtime/60L);
- }
-
-
-
-
- ulong pascal check_dls (char *namestring, word *nofiles,char sayit) {
-
- char *fname;
- char filename[133];
- char temp[133];
- ulong total=0;
- char uselist=0;
- int x;
-
- if (*namestring=='@') uselist=1;
- if (!uselist) {
- strcpy(temp,namestring);
- *namestring=0;
- fname=strtok(temp," ");
- }
- else fname=readfromlist(namestring,1);
- while (fname!=NULL) {
- if (*fname == '.') return 0; /* directory */
- x= oopen(fname,O_RDONLY); /* if we can't open it */
- if (x!= -1) { /* it aint there, s'ok */
- r.h.ah=0x44;
- r.h.al=0x00;
- r.x.bx=x;
- int86(33,&r,&r); /* see if device */
- cclose(x); /* close handle */
- if ((int)r.h.al == -1) return 0;/* some error */
- if(r.h.al & 0x80) return 0; /* 0x80 is the 'device' bit */
- }
- if (!strchr(fname,':') && !strchr(fname,'\\')) sprintf(filename,"%s%s",fboard.dpath,fname);
- else strcpy(filename,fname);
- x=findfirst(filename,&filestat,0);
- if (x) {
- if (sayit & 1) {
- gprintf(0,"%s%s\n",say_prompt(152),fname);
- }
- goto ReLoop;
- }
- else {
- strcat(namestring,fname);
- strcat(namestring," ");
- }
- while (!x) {
- (*nofiles)++;
- total+=(ulong)filestat.ff_fsize;
- if(sayit & 1) gprintf(0,"%-13s -- %lu bytes\n",filestat.ff_name,filestat.ff_fsize);
- if(sayit & 2) do_dls(filestat.ff_name,filestat.ff_fsize);
- x=findnext(&filestat);
- }
- ReLoop:
- if (!uselist) fname=strtok(0," ");
- else fname=readfromlist(namestring,0);
- }
- rstrip(namestring);
- return total;
- }
-
-
- void pascal gothere (char adjust,char *s, char which,struct protocol *proto)
-
- {
-
- char str[133];
- int drive;
- char dir[MAXDIR];
- int x;
- struct ffblk f;
-
- level=0;
- drive=getdisk();
- getcurdir(++drive,dir);
- if (!which) {
- setdisk(toupper(*fboard.dpath)-'A');
- strcpy(str,fboard.dpath);
- while(*str && str[strlen(str)-1]=='\\')str[strlen(str)-1]=0;
- if(chdir(str)) {
- say_prompt(443);
- level=1;
- return;
- }
- }
- else {
- setdisk(toupper(*fboard.upath)-'A');
- if(proto->noname) {
- sprintf(str,"%s%03hu",fboard.upath,nodenumber);
- mkdir(str);
- }
- else {
- strcpy(str,fboard.upath);
- while(*str && str[strlen(str)-1]=='\\')str[strlen(str)-1]=0;
- }
- if(chdir(str)) {
- say_prompt(443);
- level=1;
- return;
- }
- if(proto->noname) {
- sprintf(str,"%s%03hu\\*.*",fboard.upath,nodenumber);
- x=findfirst(str,&f,0);
- while(!x) {
- unlink(f.ff_name);
- x=findnext(&f);
- }
- }
- }
- fossil(FLUSHOUT,0);
- if (adjust) adjust_time(0);
- if(baud)spawnit(s,0,0);
- if (adjust) adjust_time(1);
- timer_off++;
- setdisk (--drive);
- strcpy(str,"\\");
- strcat(str,dir);
- chdir(str);
- }
-
-
- void pascal add_one (char *filename) {
- /* INCREMENT TIME STAMP (#Downloads) BY 1 */
- word x;
- char fname[133];
- char far *ptr;
- struct SREGS sregs;
- int temp;
-
- x=findfirst(filename,&filestat,0);
- while (!x) {
- sprintf(fname,"%s%s",fboard.dpath,filestat.ff_name);
- ptr=fname;
- r.x.dx=FP_OFF(ptr);
- sregs.ds=FP_SEG(ptr);
- r.h.ah=61;
- r.h.al=64;
- int86x(33,&r,&r,&sregs); /* Open file */
- temp=r.x.ax; /* Save handle */
- r.x.bx=temp;
- r.h.ah=87;
- r.h.al=0;
- int86(33,&r,&r); /* Get time/date */
- r.x.bx=temp;
- r.h.ah=87;
- r.h.al=1;
- r.x.cx++;
- int86(33,&r,&r); /* Set time/date */
- r.x.bx=temp;
- r.h.ah=62;
- int86(33,&r,&r); /* Close file */
- x=findnext(&filestat);
- }
- }
-
-
- word pascal askdl (filename,type,flsearch,key)
-
- char *filename;
- char type;
- char *flsearch;
- char key;
-
- {
-
- int handle;
- char s[133];
- struct protocol proto;
- char *p;
- struct ffblk f;
- char fname[133]="";
- char temp[256]="";
- word temptotal=0;
- char logem=0;
- char uselist=0;
- struct _fboard tempboard;
-
- if(*filename=='@') uselist=1;
- memcpy(&tempboard,&fboard,sizeof(struct _fboard));
- if(conf.debug) {
- gprintf(LOCALONLY,"\n\x4 %s \x4 %hu \x4 %s \x4 %c\n\x4 %s\n\x4 %s\n\x4 %s %hu",filename,type,flsearch,key,fboard.dpath,fboard.upath,fboard.name,fboard.flags);
- }
- if(!flsearch || !stricmp(flsearch,"NULL") || !*flsearch) {
- if(!stricmp(fboard.dpath,"NUL") || !stricmp(fboard.dpath,"NUL\\")) {
- say_prompt(106);
- return 0;
- }
- }
- if(filename) strcpy(fname,filename);
- if(!strcmp(fname,"NULL")) {
- filename=NULL;
- *fname=0;
- }
- if(key && *fname){
- if(!find_protocol(&proto,key)) return 0;
- }
- else strcpy(temp,getstuff(&proto,1+(*fname==0)+(type & 128)+(64*(*filename=='@'))));
- if (!proto.key) return 0;
- if (!*fname && !*temp) return 0;
- else if (!*fname) strcpy(fname,temp);
- if(proto.dszlog) if(getenv("DSZLOG")) unlink(getenv("DSZLOG"));
-
- say_prompt(153);
- helpnum=526;
- logem=(*genin(1,0,1,1,YESNO)=='Y');
- helpnum=0;
- printm("\n");
-
- if (!flsearch || !*flsearch || !strcmp(flsearch,"NULL")) {
- temptotal=download(fname,&proto,(0 + (uselist*2)));
- goto DoLog;
- }
- type = type & 15;
- if (type>9 || type<0) type=0;
- if ((handle=oopen(flsearch,O_RDONLY | O_TEXT | O_DENYNONE))!=-1) {
- say_prompt(155);
- while (!eof(handle)) {
- if (!fgetsx(s,127,handle)) break;
- if (*s=='\n' || *s=='\r' || *s==';') continue;
- stripcr(s);
- strncpy(fboard.dpath,strtok(s," "),78);
- fboard.dpath[78]=0;
- if (fboard.dpath[strlen(fboard.dpath)-1]!='\\') strcat(fboard.dpath,"\\");
- if ((word)atoi(strtok(0," "))>user.stat[type]) continue;
- printm(".");
- strncpy(fboard.name,strtok(0," "),48);
- fboard.name[47]=0;
- while((p=strchr(fboard.name,'_'))!=NULL) *p=' ';
- fboard.flags=(char)atoi(strtok(0," "));
- p=strchr(fname,' ');
- if (p!=NULL) {
- *p=0;
- sprintf(temp,"%s%s",fboard.dpath,fname);
- *p=' ';
- }
- else sprintf(temp,"%s%s",fboard.dpath,fname);
- if (!findfirst(temp,&f,0)) {
- gprintf(0,"%s '%s':\n",say_prompt(154),fboard.name);
- temptotal=download(fname,&proto,0);
- cclose(handle);
- goto DoLog;
- }
- }
- gprintf(0,"%s%s\n",say_prompt(156),strtok(fname," "));
- cclose(handle);
- return 0;
- }
- say_prompt(342);
- return 0;
-
- DoLog:
- if (logem) autolog();
- memcpy(&fboard,&tempboard,sizeof(struct _fboard));
- return temptotal;
- }
-
-
-
- void pascal autolog (void) {
-
- char logem=30;
- char keyin;
-
- pauser=0;
- say_prompt(157);
- fossil(PURGEOUT,0);
- fossil(PURGEIN,0);
- while (--logem) {
- keyin=inkey();
- gprintf(0,"%s%s%02u",BACKSPACE,BACKSPACE,logem);
- if(!keyin) keyin=inkey();
- if (keyin==13) {
- say_prompt(347);
- return;
- }
- if (keyin==27 || keyin==11) break;
- if (!(logem % 5)) printm("\x7");
- sleep(1);
- }
- say_prompt(346);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- baud=0;
- leaving++;
- logoff();
- exit(254);
- }
-
-
-
- word pascal upload (char *uname,char key) {
-
- char s[133];
- char *fname;
- char temporary[256];
- struct protocol proto;
- char filename[133]="";
- char str[256];
- char logem=0;
- char uselist=0;
- word temptotal=0;
- int handle;
- char tempsafe;
-
- if(!stricmp(fboard.upath,"NUL") || !stricmp(fboard.upath,"NUL\\")) {
- say_prompt(338);
- return 0;
- }
-
- if ((stristr(uname,"00000000.") || stristr(uname,".RPK")) && (stristr(fboard.upath,"\\MPORT"))) handle=128;
- else handle=0;
- if(key && (uname && *uname)) {
- if(!find_protocol(&proto,key)) return 0;
- }
- else strcpy(str,getstuff(&proto,(handle+(32 * (*uname!=0))+(64 * (*uname=='@')))));
- if ((!*str && (!*uname || !uname)) || !proto.key) return 0;
- if (stristr(uname,".RPK") && (stristr(fboard.upath,"\\MPORT"))) {
- proto.dszlog=0;
- proto.noname=0;
- }
- if(proto.dszlog) if(getenv("DSZLOG")) unlink(getenv("DSZLOG"));
- if (*uname=='@' && uname) uselist=1;
-
- say_prompt(158);
-
- if (!uselist) {
- strcpy(temporary,str);
- if (*uname && uname) {
- strcpy(temporary,uname);
- strcpy(str,uname);
- }
- fname=strtok(temporary," ");
- }
- else fname=readfromlist(uname,1);
- if (stristr(fname,".BBS") && baud) {
- say_prompt(159);
- user.violations++;
- fossil(DTR,DOWN);
- baud=0;
- leaving++;
- logoff();
- exit(253);
- }
- while (fname!=NULL) {
- sprintf(filename,"%s%s",fboard.upath,fname);
-
- if (baud) {
- if (!findfirst(filename,&filestat,0)) {
- say_prompt(160);
- return 0;
- }
- sprintf(filename,"%s%s",fboard.upath,str);
- if (!findfirst(filename,&filestat,0)) {
- say_prompt(160);
- return 0;
- }
- sprintf(s,"%s%s",fboard.upath,"FILES.BBS");
- if ((handle=oopen(s,O_RDONLY | O_TEXT | O_DENYNONE))==-1);
- else {
- while((!eof(handle)) && (strcmp(s,str))) {
- if(fgetsx(s,81,handle)==NULL) break;
- s[12]=0;
- rstrip(s);
- if (!strcmp(s,fname)) {
- cclose(handle);
- gprintf(0,"%s%s",fname,say_prompt(161));
- return 0;
- }
- }
- cclose(handle);
- }
- }
- if (*filename == '.') { /* Directory */
- say_prompt(160);
- return 0;
- }
- handle = oopen(filename,O_RDONLY | O_DENYNONE);
- if (handle!= -1) { /* it aint there, s'ok */
- r.h.ah=0x44;
- r.h.al=0x00;
- r.x.bx=handle;
- int86(33,&r,&r); /* see if device */
- cclose(handle); /* close handle */
- if ((int)r.h.al == -1 || (r.h.al & 0x80)) {
- say_prompt(160);
- return 0;
- }
- }
- if (!uselist) fname=strtok(0," ");
- else fname=readfromlist(uname,0);
- }
- logem=0;
- gprintf(0,say_prompt(287),proto.name,proto.abort);
- if (*uname && uname && !uselist) {
- gprintf(0,say_prompt(447),uname);
- }
- if(baud) {
- tempsafe=safe;
- safe=0;
- strcpy(s,proto.spawnup);
- replace(s,str);
- gothere(conf.uptime,s,1,&proto);
- }
- if (!level || proto.dszlog) {
- if (stristr(str,".RPK") && (stristr(fboard.upath,"\\MPORT"))) goto SkipEntry;
- if(proto.dszlog) {
- do_dszlog(&proto,1);
- goto SkipEntry;
- }
- if(!proto.noname)temptotal=getentry(str,&proto);
- else temptotal=getentry("*.*",&proto);
- if (!temptotal) {
- say_prompt(163);
- goto NoSuccess;
- }
- SkipEntry:
- say_prompt(164);
- }
- else {
- NoSuccess:
- mprint(STOPDL);
- sprintf(s,"Bad %c-U/L %s",proto.key,filename);
- addtolog(s);
- say_prompt(165);
- timer_off=0;
- safe=tempsafe;
- return 0;
- }
- DoLog:
- if (!logem) return temptotal;
- else autolog();
- safe=tempsafe;
- return temptotal;
- }
-
-
-
- char * pascal getstuff (struct protocol *proto, char type) {
-
- int handle;
- char s[133];
- char choices[129];
- char choice;
- int register x;
- struct ffblk f;
- int flag;
-
- strset(choices,0);
- *dlstr=0;
- proto->key=0;
-
- if (findfirst("protocol.ctl",&filestat,0)) {
- return dlstr;
- }
- if ((handle=oopen(searchpath("protocol.ctl"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- return dlstr;
- }
- sprintf(s,"%sPROTOCOL.XBS",conf.menupath);
- flag=findfirst(s,&f,0);
-
- ListAgain:
-
- if (flag) say_prompt(166);
- for (x=0;x<(filestat.ff_fsize/sizeof(struct protocol));x++) {
- if (eof(handle)==-1) break;
- if (x==129) break;
- if (_read(handle,proto,sizeof(struct protocol))<1) return dlstr;
- if (type & 64) {
- if (!proto->list) continue;
- }
- if (!type) strcpy(s,proto->spawnup);
- else strcpy(s,proto->spawndn);
- if (!*s) choices[x]=8;
- else {
- if(flag) {
- if(!(x%2)) sprintf(s,"[%c]...%-28s",proto->key,proto->name);
- else sprintf(s,"[%c]...%s\n",proto->key,proto->name);
- }
- choices[x]=proto->key;
- if (flag)printm(s);
- }
- }
- if(flag)printm("\n -> ");
- else readfile("PROTOCOL.XBS",0,0,1);
- helpnum=527;
- choice=*genin(1,0,1,1,ALLL);
- helpnum=0;
- if (!choice) {
- proto->key=0;
- return dlstr;
- }
- if (choice=='?') {
- if (!type || (type & 32)) say_prompt(431);
- else say_prompt(432);
- hitreturn();
- lseek(handle,0L,SEEK_SET);
- goto ListAgain;
- }
- if (strchr(choices,choice)==NULL) {
- lseek(handle,0L,SEEK_SET);
- goto ListAgain;
- }
- for (x=0;x<strlen(choices);x++) if (choice==choices[x]) break;
- lseek(handle,(long)x*sizeof(struct protocol),SEEK_SET);
- if (_read(handle,proto,sizeof(struct protocol))<1) return dlstr;
- cclose(handle);
- gprintf(0,"\n%s%s",proto->name,say_prompt(167));
- if (type==1 || (type & 128) || (type & 32) || (type & 64)) return dlstr;
- if (proto->noname && !type) return " ";
- if (proto->wild) say_prompt(168);
- if (proto->multi && !(type & 4)) say_prompt(282);
- if (proto->simul) say_prompt(444);
- say_prompt(169);
- if (!type) printm("send?\n-> ");
- else printm("receive?\n-> ");
- if (!proto->multi || (type & 4)) {
- helpnum=528;
- strcpy(dlstr,genin(13,0,1,0,FLE+(proto->wild*2)));
- helpnum=0;
- }
- else {
- helpnum=529;
- strcpy(dlstr,genin(76,0,1,0,FBATCH+(proto->wild)));
- helpnum=0;
- }
- if(*dlstr) {
- readfile("CHEKFILE.XBS",0,0,1);
- }
- return (dlstr);
- }
-
-
-
- word pascal getentry (char *namestring,struct protocol *proto) {
-
- char s[133];
- char filename[133];
- char tempath[133];
- char temporary[256];
- char *descriplines[255];
- char *fname;
- int register x;
- int register y;
- ulong total=0;
- char str[81];
- char postedmsg=0;
- struct date dos_date;
- struct fdate {
- bit day: 5;
- bit month: 4;
- bit year: 7;
- };
- union df {
- struct fdate fd;
- int x;
- } fdf;
- struct ffblk f;
- char far *ptr;
- char uselist=0;
- int temp;
- int handle;
- struct SREGS sregs;
-
- safe=0;
- if (*namestring=='@') uselist=1;
- strcpy(temporary,namestring);
- *namestring=0;
- if (!uselist) fname=strtok(temporary," ");
- else fname=readfromlist(temporary,1);
- while (fname!=NULL) {
- if(strchr(fname,':') || strchr(fname,'\\')) strcpy(filename,fname);
- else if(proto->noname)sprintf(filename,"%s%03hu\\%s",fboard.upath,nodenumber,fname);
- else sprintf(filename,"%s%s",fboard.upath,fname);
- x=findfirst(filename,&f,0);
- while (!x) {
- if (!(fboard.flags & FREEUP)) {
- user.upno++;
- user.upk+=(ulong)(f.ff_fsize/1024L);
- user.uktoday+=(word)(f.ff_fsize/1024L);
- }
- total+=(ulong)f.ff_fsize;
- if (conf.touchup) { /* TOUCH-UP FILE DATE */
- if(strchr(fname,':') || strchr(fname,'\\')) {
- strcpy(filename,fname);
- ptr=strrchr(filename,'\\');
- if(ptr!=NULL) {
- *ptr=0;
- strcat(filename,"\\");
- strcat(filename,f.ff_name);
- }
- }
- else if(proto->noname)sprintf(filename,"%s%03hu\\%s",fboard.upath,nodenumber,f.ff_name);
- else sprintf(filename,"%s%s",fboard.upath,fname);
- getdate(&dos_date);
- fdf.fd.day=dos_date.da_day;
- fdf.fd.month=dos_date.da_mon;
- fdf.fd.year=dos_date.da_year-1980;
- ptr=filename;
- r.x.dx=FP_OFF(ptr);
- sregs.ds=FP_SEG(ptr);
- r.h.ah=61;
- r.h.al=64;
- int86x(33,&r,&r,&sregs); /* Open file */
- temp=r.x.ax; /* Save handle */
- r.x.bx=temp;
- r.h.ah=87;
- r.h.al=1;
- r.x.cx=(word)0;
- r.x.dx=fdf.x;
- int86(33,&r,&r); /* Set time/date */
- r.x.bx=temp;
- r.h.ah=62;
- int86(33,&r,&r); /* Close file */
- }
- gprintf(LOGONLY,"%c-U/L %s (%lu bytes)",proto->key,filename,f.ff_fsize);
- if(proto->noname) {
- sprintf(tempath,"%s%03hu\\%s",fboard.upath,nodenumber,f.ff_name);
- sprintf(filename,"%s%s",fboard.upath,f.ff_name);
- r.h.ah=0x56;
- r.x.dx=FP_OFF(tempath);
- sregs.ds=FP_SEG(tempath);
- r.x.di=FP_OFF(filename);
- sregs.es=FP_SEG(filename);
- int86x(33,&r,&r,&sregs); /* Move file to real
- upload directory */
- }
- x=0;
- carrchk();
- if (!conf.comments) goto SkipComments;
- gprintf(0,"%s%s (%lu bytes):\n",say_prompt(170),f.ff_name,f.ff_fsize);
- gprintf(0,say_prompt(171),conf.comments);
- say_prompt(270);
- DoComment:
- say_prompt(269);
- helpnum=530;
- strcpy(str,genin(46,0,0,0,ALLL));
- helpnum=0;
- if ((x==0) && (strlen(str)<3)) {
- timer_off=0;
- goto DoComment;
- }
- if (*str) {
- gprintf(LOGONLY,"Descr: %s",str);
- descriplines[x]=(char *)mmalloc((word)82 * (word)sizeof(char));
- descriplines[x+1]=NULL;
- if (descriplines[x]==NULL) goto SkipComments;
- sprintf(descriplines[x],"%s%s",say_prompt(348),str);
- x++;
- if (x<(int)conf.comments) goto DoComment;
- }
- SkipComments:
- if ((mboard.attr & ASSOC) && (fboard.flags & FILEASSOC)) {
- if(!conf.comments) goto ForceComment;
- say_prompt(442);
- helpnum=531;
- if (*genin(1,0,1,1,YESNO)=='Y') {
- ForceComment:
- helpnum=0;
- strcpy(assocfile,f.ff_name);
- if (!(level=(word)askwrite(0))) {
- if (!(level=(word)writemessage(0))) {
- level=(word)makemessage(0);
- }
- }
- if (level && (!conf.comments || conf.forcefilemsg)) goto ForceComment;
- if(!level) postedmsg=1;
- else postedmsg=0;
- *assocfile=0;
- goto DoneNow;
- }
- helpnum=0;
- }
- DoneNow:
- sprintf(s,"%s%s",fboard.upath,"FILES.BBS");
- if ((handle=oopen(s,O_RDWR | O_APPEND | O_TEXT | O_DENYWRITE))==-1) {
- if((handle=ccreat(s,S_IWRITE))==-1) continue;
- }
- *s=0;
- if(conf.comments) {
- if(*descriplines[0]==';') *s=';';
- }
- strcat(s,say_prompt(440));
- ffprintf(handle,s,f.ff_name,user.handle,'\r','\n');
- ffprintf(handle," ;Area: %s\r\n",fboard.name);
- if(postedmsg) ffprintf(handle," ;MSGID: %08lx\r\n",lastfilemsgid);
- if(!conf.comments) goto BadFile;
- for (y=0;y<x;y++) {
- if (descriplines[y]) {
- ffprintf(handle,"%s\r\n",descriplines[y]);
- ffree(descriplines[y]);
- }
- }
- cclose(handle);
- BadFile:
- x=findnext(&f);
- }
- if (!uselist) fname=strtok(0," ");
- else fname=readfromlist(temporary,0);
- }
- if(proto->noname){
- sprintf(filename,"%s%03hu",fboard.upath,nodenumber);
- rmdir(filename);
- }
- if (total) say_prompt(172);
- timer_off=0;
- safe=1;
- if((word)(total/1024L)<1) return 1;
- return (word)(total/1024L);
- }
-
-
-
- char * pascal replace (s,fname) /* Replaces *F w/ filename(s) */
-
- char *s;
- char *fname;
-
- {
-
- static char str[256];
- char *p;
-
- if (!strstr(s,"*F")) return s;
- p=strstr(s,"*F");
- *p=0;
- strcpy(str,s);
- p+=2;
- strcat(str,fname);
- strcat(str,p);
- str[132]=0;
- strcpy(s,str);
- return s;
- }
-
- char uploadordownload=0;
-
- char * pascal readfromlist (char *filename, char type) { /* Reads files one at
- a time from file
- list for protocol
- use (@list.ext)
- Translates entries
- from DSZLOG into
- filenames if there
- was no error */
-
- static char str[255];
- char *p;
- int handle;
- register word x;
- static long markedplace=0;
-
- ReStart:
-
- if ((handle=oopen(&filename[1],O_RDONLY | O_TEXT | O_DENYNONE))==-1) return NULL;
- if (!type) lseek(handle,markedplace,SEEK_SET);
- else lseek(handle,0,SEEK_SET);
- if (fgetsx(str,255,handle)==NULL) {
- cclose(handle);
- if(stristr(&filename[1],"DSZLOG"))unlink(&filename[1]);
- markedplace=0;
- return NULL;
- }
- markedplace=tell(handle);
- cclose(handle);
- stripcr(str);
-
- #ifdef UDDEBUG
- gprintf(LOCALONLY,"\n\04%s: %s\n",&filename[1],str);
- #endif
-
- if(stristr(&filename[1],"DSZLOG")) {
- p=strtok(str," ");
- if(!stricmp(str,"E") || !stricmp(str,"L") || !atol(strtok(0," "))) {
- type=0;
- goto ReStart;
- }
- for(x=0;x<8;x++) strtok(0," ");
- if(isupper(*str))uploadordownload=1;
- else uploadordownload=0;
- p=strtok(0," ");
- return p;
- }
- return str;
- }
-
-
-
- void pascal do_dls (char *uname,long filesize) {
-
- char s[133];
-
- if (!(fboard.flags & FREEFILES)) {
- user.downno++;
- user.downk+=(ulong)(filesize/1024L);
- user.dktoday+=(word)(filesize/1024L);
- }
- if (fboard.flags & COUNTDLS) { /* TOUCH-UP FILE TIME */
- if(!strchr(uname,':') && !strchr(uname,'\\')) sprintf(s,"%s%s",fboard.dpath,uname);
- else strcpy(s,uname);
- add_one(s);
- }
- }
-
-
- void pascal do_dszlog (struct protocol *proto,char type) {
-
- int handle;
- int temp=0;
- char str[133];
- char file[133];
- char *p;
- char *ud;
- struct ffblk f;
-
- if(!getenv("DSZLOG")) return;
- sprintf(str,"DSZTEMP.%03hu",nodenumber);
- handle=ccreat(str,S_IWRITE);
- if(handle==-1) return;
- sprintf(str,"@%s",getenv("DSZLOG"));
- p=readfromlist(str,1);
- while(p!=NULL) {
- if(conf.debug) {
- if (proto->simul) {
- if(!uploadordownload) ud="Downloaded";
- else ud="Uploaded";
- }
- else if(!type) {
- ud="Downloaded";
- uploadordownload=0;
- }
- else if(type){
- uploadordownload++;
- ud="Uploaded";
- }
- gprintf(LOCALONLY,"\04DSZLog: %s %s\n",ud,p);
- }
- if(uploadordownload) {
- temp++;
- ffprintf(handle,"%s\r\n",p);
- }
- else {
- if(!strchr(p,':') && !strchr(p,'\\'))sprintf(file,"%s%s",fboard.dpath,p);
- else strcpy(file,p);
- if(!findfirst(file,&f,0)) {
- if(!strchr(p,':') && !strchr(p,'\\'))sprintf(file,"%s%s",fboard.dpath,f.ff_name);
- else strcpy(file,f.ff_name);
- do_dls(file,f.ff_fsize);
- gprintf(LOGONLY,"%c-D/L %s (%lu bytes)",proto->key,file,f.ff_fsize);
- }
- }
- p=readfromlist(str,0);
- }
- if(getenv("DSZLOG")) unlink(getenv("DSZLOG"));
- cclose(handle);
- proto->dszlog=0;
- sprintf(str,"@DSZTEMP.%03hu",nodenumber);
- if(temp) getentry(str,proto);
- unlink(&str[1]);
- }
-
-
-
- char pascal find_protocol (struct protocol *proto,char key) {
-
- register word x;
- int handle;
-
- proto->key=0;
- if (findfirst("protocol.ctl",&filestat,0)) {
- return 0;
- }
- if ((handle=oopen(searchpath("protocol.ctl"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- return 0;
- }
- for (x=0;x<(filestat.ff_fsize/sizeof(struct protocol));x++) {
- if (eof(handle)==-1) break;
- if (_read(handle,proto,sizeof(struct protocol))<1) break;
- if(proto->key==key) break;
- }
- cclose(handle);
- if(proto->key==key)return 1;
- return 0;
- }
-
-
- char pascal first_non_white (char *a) {
-
- char *b;
-
- b=a;
- while(*b && (*b==' ' || *b=='\t')) b++;
- if(*b) return *b;
- return 0;
- }
-