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.....Misc low-level routines */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
- extern word lastlevel[10];
-
-
- extern void pascal CLEAROVERLAY (void);
- extern void pascal _REINITOVERLAYS (void);
-
-
-
- void pascal readconfig (void) {
-
- int fp;
- char s[14];
- word temp;
-
- if (nodenumber!=1) sprintf(s,"config%hu.bbs",nodenumber);
- else strcpy(s,"config.bbs");
- if ((fp=oopen(s,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- Fatal:
- printm(addtolog("\nFatal Configuration Error...sorry.\n"));
- gprintf(LOCALONLY,"\04Error #%d\n",errno);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- exit(253);
- }
- if ((temp=(_read(fp,&conf,sizeof(struct _config))))<1) goto Fatal;
- if(temp<sizeof(struct _config)) {
- lprint("\n\04Suspicious config file.\n");
- fputs("\07",stdout);
- sleep(1);
- }
- if(conf.version<VERSION) {
- lprint("\n\04Not current config version.\n");
- fputs("\07",stdout);
- sleep(1);
- }
- cclose(fp);
- }
-
-
- void pascal prepare (void) {
-
- int fp;
- char s[90];
- char numnode[4]="";
-
- if (nodenumber!=1) sprintf(numnode,"%hu",nodenumber);
- sprintf(s,"%sonline%s.xbs",conf.homepath,numnode);
- if ((fp=oopen(s,O_RDWR | O_BINARY | O_DENYNONE))==-1) {
- if ((fp=ccreat(s,S_IWRITE))==-1) {
- gprintf(LOCALONLY | LOGONLY,"\n\04Can't create ONLINE.XBS--%d\n",errno);
- }
- }
- else {
- _write(fp,&user,sizeof(struct _user));
- _write(fp,&userno,sizeof(userno));
- _write(fp,&timelimit,sizeof(timelimit));
- _write(fp,&timeon,sizeof(timeon));
- _write(fp,&starter,sizeof(starter));
- _write(fp,&baud,sizeof(baud));
- _write(fp,&pages,sizeof(pages));
- _write(fp,&age,sizeof(age));
- _write(fp,&timer_off,sizeof(timer_off));
- _write(fp,&hold_time,sizeof(hold_time));
- _write(fp,variable,(sizeof(variable[0])*10));
- _write(fp,&mboard,sizeof(struct _mboard));
- _write(fp,&fboard,sizeof(struct _fboard));
- _write(fp,event,(sizeof(struct _events)*10));
- cclose(fp);
- }
- save_lastread();
- }
-
-
-
- char pascal spawnit (char *a,char type,char errorlevel) {
-
- int fp;
- int register x;
- char noelevelflag=0;
- char *e[26];
- char str[81];
- char c[134];
- int drive;
- char dir[MAXDIR];
- ulong temptimer;
-
- if(type!=10 && type!=5) fossil(FLUSHOUT,0);
- temptimer=getxbbstime();
- switch (type) {
- case 5: break;
- case 1:
- case 2:
- case 8:
- case 9:
- case 4: prepare();
- saveconfig();
- default: textattr(WHITE | BLACK * 16);
- }
-
- if (type==4) {
- update();
- blank_stat();
- gprintf(LOGONLY,"ERRORLEVEL Exit %hu",errorlevel);
- fossil(DEINIT,0);
- exit(errorlevel);
- }
-
- for (x=0;x<26;x++) e[x]=NULL;
- a=convertstring(a);
- strncpy(c,a,133);
- c[132]=0;
- for (x=0;x<26;x++) e[x]=NULL;
- e[0]=strtok(c," ");
- for (x=1;(e[x]=strtok(0," "));x++) if (x==25) break;
-
- if (type==5) {
- a=strtok(a," ");
- if ((fp=oopen(e[0],O_RDWR | O_APPEND | O_BINARY | O_DENYNONE))==-1)
- if ((fp=ccreat(e[0],S_IWRITE))==-1) {
- gprintf(LOCALONLY," Error in write to %s\n",e[0]);
- return(level=255);
- }
- a=strtok(0,"\n");
- lseek(fp,0L,SEEK_END);
- if(!*a || a==NULL) ffprintf(fp,"\r\n");
- else if (a[strlen(a)-1]!=';') {
- ffprintf(fp,"%s\r\n",a);
- }
- else {
- a[strlen(a)-1]=0;
- _write(fp,a,strlen(a));
- }
- cclose (fp);
- return(level=0);
- }
-
- r.x.ax=0x4400; /* Set console in (std) cooked mode */
- r.x.bx=1;
- int86(33,&r,&r);
- r.h.dh=0;
- r.h.dl=r.h.dl&(~0x20);
- r.x.ax=0x4401;
- int86(33,&r,&r);
-
- fputs("\x1b[25;1H\n",stderr);
- if (conf.debug) addtolog(a);
- if (type!=6) fossil(DEINIT,0);
-
- if (type==2) {
- gprintf(LOGONLY,"BATch ERRORLEVEL %hu",errorlevel);
- if (nodenumber!=1) sprintf(str,"xbbs%hu.bat",nodenumber);
- else strcpy(str,"xbbs.bat");
- if ((fp=ccreat(str,S_IWRITE))==-1) {
- printm("Error creating BAT file");
- return(level=255);
- }
- ffprintf(fp,"%s\r\n",a);
- cclose(fp);
- exit(errorlevel);
- }
-
- CLEAROVERLAY();
-
- if (type==3 || type==9) {
- ffprintf(LOGONLY,"DOS exit-> %s",a);
- timer_off++;
- noelevelflag++;
- system (a);
- }
-
- strtok(a," ");
-
- if (!type || type==7 || type==6 || type==8) {
- drive=getdisk();
- getcurdir(++drive,dir);
- if (!strnicmp(a,"COMMAND.COM",11)) noelevelflag++;
- gprintf(LOGONLY,"Spawning: %s",a);
- timer_off++;
- if ((type==7 && !conf.swap) || ((!type || type==6 || type==8) && conf.swap)) {
-
- int templevel;
- char *p;
- char *pp;
-
- if (conf.debug) addtolog("Swapping...");
- if (!strchr(a,':') && !strchr(a,'\\')) {
- p=searchpath(a);
- if(!p) {
- gprintf(LOCALONLY | LOGONLY,"Can't find `%s'",a);
- goto SkipSpawn;
- }
- }
- else p=a;
- pp=strtok(0,"\n");
- if (!pp) pp="";
- templevel=doswap(p,pp);
- if (templevel!=(-1)) {
- level=(word)templevel;
- goto SkipSpawn;
- }
- }
- SpawnAnyway:
- level=(word)spawnvp(P_WAIT,a,e);
- SkipSpawn:
- setdisk (--drive);
- strcpy(str,"\\");
- strcat(str,dir);
- chdir(str);
- goto getelevel;
- }
- if (type==1 || type==6) {
- gprintf(LOGONLY,"Executing: %s",a);
- execvp(a,e);
- }
- level=256;
-
- getelevel:
-
- _REINITOVERLAYS();
- fossil(INIT,0);
- fputs("\x1b[2J",stderr);
- redraw_stat(NULL);
- fossil(WATCHDOG,0);
- if (!level) {
- r.h.ah=77;
- int86(33,&r,&r);
- level=(word)r.h.al;
- }
- Skiplevel:
-
- if (type==8 || type==9) {
- getonline();
- readconfig();
- }
- r.x.ax=0x4400; /* Set console in raw mode */
- r.x.bx=1;
- int86(33,&r,&r);
- r.h.dh=0;
- r.h.dl=r.h.dl|0x20;
- r.x.ax=0x4401;
- int86(33,&r,&r);
-
- lastexittime=(getxbbstime()-temptimer)/60L;
- timer_off=0;
- if(noelevelflag) level=0; /* Nulify erroneous elevels */
- if (conf.debug){
- gprintf(LOCALONLY,"\n\x4 Watchdog off--Exit status: %u\n",level);
- gprintf(LOGONLY,"Returned %u",level);
- }
- return((char)level);
- }
-
-
-
- void pascal assignvar (char *a,char x) {
-
- strncpy(variable[x],a,80);
- variable[x][81]=0;
- }
-
-
-
- int cdecl break_handler (void) {
-
- return 1;
- }
-
-
- char * pascal stripcr (char *a) {
-
- register int x;
-
- x=strlen(a);
- while (x && (a[x-1]=='\n' || a[x-1]=='\r')) a[--x]=0;
- return a;
-
- }
-
-
- char * pascal addtolog (char *text) { /* WRITE LOGFILE ENTRIES */
-
- int handle;
- char p[127];
- char nn[5];
-
- if ((handle=_open(conf.logfile,O_RDWR | O_APPEND | O_BINARY | O_DENYWRITE))==-1)
- if ((handle=creat(conf.logfile,S_IWRITE))==-1) return text;
- lseek(handle,0L,SEEK_END);
- if (*text!='*') {
- strcpy(p,fidodate());
- p[16]=0;
- if (nodenumber!=1) {
- sprintf(nn," %-2hu",nodenumber);
- strcat(p,nn);
- }
- else strcat(p," ");
- strncat(p,text,126-strlen(p));
- p[126]=0;
- }
- else {
- strncpy(p,&text[1],79);
- p[79]=0;
- }
- _write(handle,p,strlen(p));
- _write(handle,"\r\n",2);
- _close(handle);
- return text;
- }
-
-
-
- char pascal carrchk (void) { /* Checks for carrier */
-
- if (baud) {
- r.x.dx=conf.commport;
- r.h.ah=GETSTAT;
- int86(20,&r,&r);
- if (!(r.h.al & 128)) {
- if (!userno) goto NoUser;
- sleep(1);
- r.x.dx=conf.commport;
- r.h.ah=GETSTAT;
- int86(20,&r,&r);
- if (!(r.h.al & 128)) {
- NoUser:
- baud=0;
- if (leaving) exit(254);
- user.violations++;
- say_prompt(193);
- logoff();
- userno=0;
- leaving++;
- exit(254);
- }
- }
- return r.h.ah;
- }
- return 0;
- }
-
-
- word pascal find_msgarea (char *filename,char *areaname,int which) {
-
- int handle,x;
- char s[256],descr[83];
- char *p;
- char *pp;
- struct _mboard temp;
- word areano;
- char tempause;
- char eeof=0;
- word zone,net,node;
- char temp_domain[37];
-
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(393);
- return 0;
- }
- if(which==1)areano=atoi(areaname);
- else if (which==2) {
- tempause=pauser;
- pauser=1;
- }
- memcpy(&temp,&mboard,sizeof(struct _mboard));
- zone=conf.alt_zone;
- net=conf.alt_net;
- node=conf.alt_node;
- strcpy(temp_domain,conf.alt_domain);
- while (!eof(handle)) {
- BreakIn:
- if (!fgetsx(s,256,handle)) {
- eeof=1;
- break;
- }
- if (*s=='\r' || *s=='\n' || *s==';') continue;
- stripcr(s);
- strtok(s,",");
- strncpy(mboard.name,s,48);
- mboard.name[47]=0;
- if (!which) if (stricmp(s,areaname)) continue;
- mboard.attr=(word)atol(strtok(0," ,"));
- mboard.max=(word)atol(strtok(0," ,"));
- mboard.number=(word)atol(strtok(0," ,"));
- if (which==1) {
- if(mboard.number!=areano) continue;
- }
- mboard.substat1=(word)atol(strtok(0," ,"));
- mboard.substat2=(word)atol(strtok(0," ,"));
- if(mboard.substat1>user.stat[0]) continue;
- p=NULL;
- pp=strtok(0,"\n");
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if (p!=NULL) strncpy(mboard.forceto,p,36);
- else *mboard.forceto=0;
- mboard.forceto[35]=0;
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
-
- if(which==2) {
- if(!p)*descr=0;
- else {
- strcpy(descr,"...");
- strncat(descr,p,79);
- descr[82]=0;
- }
- }
-
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(p!=NULL) {
- mboard.age=(signed char)atoi(p);
- }
- else mboard.age=0;
- if(mboard.age) {
- if(mboard.age>0) {
- if(age<(char)mboard.age) {
- mboard.substat1=mboard.substat2=65535;
- continue;
- }
- }
- else {
- if(age>(char)abs(mboard.age)) {
- mboard.substat1=mboard.substat2=65535;
- continue;
- }
- }
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(p!=NULL) {
- mboard.flags=(word)atol(p);
- }
- else mboard.flags=0;
- if(mboard.flags) {
- for(x=0;x<16;x++) {
- if(mboard.flags & (1<<x)) {
- if(!(user.attr2 & (1<<x))) {
- mboard.substat1=mboard.substat2=65535;
- goto BreakIn;
- }
- }
- }
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
-
-
- if(which!=2) {
- if(p!=NULL) {
- conf.alt_zone=(word)atol(p);
- while(*p && *p!=':')p++;
- if(*p)p++;
- conf.alt_net=(word)atol(p);
- while(*p && *p!='/')p++;
- if(*p)p++;
- conf.alt_node=(word)atol(p);
- while(*p && *p!='@')p++;
- if(*p)p++;
- if(p) {
- strncpy(conf.alt_domain,p,37);
- conf.alt_domain[36]=0;
- }
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(p)mboard.minwrite=(word)atol(p);
- else mboard.minwrite=0;
- }
- else {
- if(gprintf(0,"%-4u %s%s\n",mboard.number,mboard.name,descr)) break;
- continue;
- }
- break;
- }
- if (eeof || eof(handle) || mboard.substat1>user.stat[0] || which==2 || !*mboard.name) {
- memcpy(&mboard,&temp,sizeof(struct _mboard));
- conf.alt_zone=zone;
- conf.alt_net=net;
- conf.alt_node=node;
- strcpy(conf.alt_domain,temp_domain);
- cclose(handle);
- if(which==2)pauser=tempause;
- return 0;
- }
- cclose(handle);
- return (mboard.number);
- }
-
-
- word pascal find_filearea (char *filename,char *areaname,word seclvl) {
-
- int handle;
- char s[256];
- char *p,*adescr;
- struct _fboard temp;
- word security=0;
- char tempause;
- word which=0;
- word x=0;
- char eeof=0;
-
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(392);
- return 0;
- }
- if(!strcmp(areaname,"___")) {
- tempause=pauser;
- pauser=tempause;
- }
- if(*areaname=='#') which=(word)atol(&areaname[1]);
- memcpy(&temp,&fboard,sizeof(struct _fboard));
- while (!eof(handle)) {
- BreakIn:
- if (!fgetsx(s,256,handle)) break;
- if (*s=='\n' || *s=='\r' || *s==';') continue;
- stripcr(s);
- strncpy(fboard.dpath,strtok(s," "),79);
- fboard.dpath[78]=0;
- if (fboard.dpath[strlen(fboard.dpath)-1]!='\\') strcat(fboard.dpath,"\\");
- security=(word)atol(strtok(0," "));
- if(seclvl<security) continue;
- x++;
- strncpy(fboard.name,strtok(0," "),47);
- fboard.name[46]=0;
- while((p=strchr(fboard.name,'_'))!=NULL) *p=' ';
- fboard.flags=(char)atoi(strtok(0," "));
- p=strtok(0," ");
- if (p) {
- strncpy(fboard.upath,p,79);
- fboard.upath[78]=0;
- if (fboard.upath[strlen(fboard.upath)-1]!='\\') strcat(fboard.upath,"\\");
- }
- else strcpy(fboard.upath,"NUL");
- adescr=strtok(0,",");
- p=strtok(0,",");
- if(p) fboard.age=(signed char)atoi(p);
- else fboard.age=0;
- if(fboard.age) {
- if(fboard.age>0) {
- if(age<(char)fboard.age) {
- security=65535;
- continue;
- }
- }
- else {
- if(age>(char)abs(fboard.age)) {
- security=65535;
- continue;
- }
- }
- }
- p=strtok(0,",");
- if(p) fboard.userflags=(word)atol(p);
- else fboard.userflags=0;
- if(fboard.userflags) {
- for(x=0;x<16;x++) {
- if(fboard.userflags & (1<<x)) {
- if(!(user.attr2 & (1<<x))) {
- security=65535;
- goto BreakIn;
- }
- }
- }
- }
- p=strtok(0,",");
- if(p) fboard.leechpercent=(char)atol(p);
- else fboard.leechpercent=0;
- if(!strcmp(areaname,"___")) {
- if(!adescr) adescr="";
- else {
- strcpy(s,"...");
- strncat(s,adescr,79);
- s[81]=0;
- adescr=s;
- }
- if(gprintf(0,"%-5u %s%s\n",x,fboard.name,adescr)) break;
- continue;
- }
- if (!stricmp(fboard.name,areaname)) break;
- if(which) {
- if(which==x) break;
- }
- }
- if (eeof || eof(handle) || seclvl<security || !strcmp(areaname,"___")) {
- memcpy(&fboard,&temp,sizeof(struct _fboard));
- if(!strcmp(areaname,"___")) pauser=tempause;
- cclose(handle);
- return 0;
- }
- cclose(handle);
- return 1;
- }
-
-
-
- void * pascal mmalloc (unsigned int size) {
-
- register int x;
-
- for(x=0;x<MAXALLOCHANDLES;x++) {
- if(allochandles[x]==NULL) {
- allochandles[x]=(void *)malloc(size);
- if(conf.whichstat==2) redraw_stat(NULL);
- return allochandles[x];
- }
- }
- addtolog("\nOut of memory handles!\n");
- strcpy(startfile,"MAIN.XBS");
- longjmp(envbuf,99);
- }
-
-
- void pascal ffree (void *ptr) {
-
- register int x;
-
- if (ptr==NULL) return;
- for(x=0;x<MAXALLOCHANDLES;x++) {
- if(ptr==allochandles[x]) {
- free(ptr);
- ptr=NULL;
- allochandles[x]=NULL;
- if(conf.whichstat==2) redraw_stat(NULL);
- break;
- }
- }
- }
-
-
- int pascal oopen (char *filename,int access) {
-
- register int x;
-
- for(x=0;x<MAXFPHANDLES;x++) {
- if(fphandles[x] == -1) {
- fphandles[x] = _open(filename,access);
-
- /* This lets you allow a user to enter a filename to open without
- having to worry about things like "CON.TXT" being entered and
- effectively crashing the system */
-
- if (fphandles[x] != -1) { /* it aint there */
- r.h.ah=0x44;
- r.h.al=0x00;
- r.x.bx=fphandles[x];
- int86(33,&r,&r); /* see if device */
- cclose(x); /* close handle */
- if ((int)r.h.al == -1) { /* some error */
- _close(fphandles[x]);
- fphandles[x] = -1;
- return -1;
- }
- if(r.h.al & 0x80) { /* 0x80 is the device bit */
- _close(fphandles[x]);
- fphandles[x]=-1;
- say_prompt(198);
- return -1;
- }
- }
-
- if(conf.whichstat==2 && fphandles[x] != -1) redraw_stat(NULL);
- /*
- gprintf(LOCALONLY,"\nOpened handle %d (%d)\n",fphandles[x],x);
- */
- return fphandles[x];
- }
- }
- gprintf(LOCALONLY | LOGONLY,"\nOut of file handles!\n");
- strcpy(startfile,"MAIN.XBS");
- if(envbuf)longjmp(envbuf,99);
- return -1;
- }
-
-
- void pascal cclose (int handle) {
-
- register int x;
-
- if(handle==-1) return;
- for(x=0;x<MAXFPHANDLES;x++) {
- if(fphandles[x]==handle) {
- /*
- gprintf(LOCALONLY,"\nClosing %d (%d)\n",fphandles[x],x);
- */
- _close(handle);
- fphandles[x]=(-1);
- if(conf.whichstat==2) redraw_stat(NULL);
- break;
- }
- }
- }
-
-
- int pascal ccreat (char *filename,int mode) {
-
- register int x;
-
- for(x=0;x<MAXFPHANDLES;x++) {
- if(fphandles[x]==-1) {
- fphandles[x]=creat(filename,mode);
- if(conf.whichstat==2) redraw_stat(NULL);
- return fphandles[x];
- }
- }
- gprintf(LOCALONLY | LOGONLY,"\nOut of file handles!\n");
- strcpy(startfile,"MAIN.XBS");
- if(envbuf)longjmp(envbuf,99);
- return -1;
- }
-
-
- void pascal ccloseall (void) {
-
- register int x;
-
- for(x=0;x<MAXFPHANDLES;x++) {
- if(fphandles[x]!=-1) {
- _close(fphandles[x]);
- fphandles[x]=(-1);
- }
- }
- if(conf.whichstat==2) redraw_stat(NULL);
- }
-
-
-
- void pascal ffreeall (void) {
-
- register int x;
-
- for(x=0;x<MAXALLOCHANDLES;x++) {
- if(allochandles[x]!=NULL) {
- free(allochandles[x]);
- allochandles[x]=NULL;
- }
- }
- if(conf.whichstat==2) redraw_stat(NULL);
- }
-
-
- word pascal next_filearea (char *filename,word seclvl) {
-
- word register x;
- static long next_pos=0L;
- char s[256];
- char *p;
- word security=0;
- int handle;
- char name[48];
- word flags;
- signed char fage;
-
- if(filename==NULL) {
- next_pos=0L;
- return 0;
- }
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(392);
- return 0;
- }
- lseek(handle,next_pos,SEEK_SET);
- level=0;
- Loop:
- if (!fgetsx(s,256,handle)) {
- next_pos=0L;
- level=1;
- cclose(handle);
- return 0;
- }
- next_pos=tell(handle);
- if (*s=='\n' || *s=='\r' || *s==';') goto Loop;
- stripcr(s);
- strtok(s," ");
- security=(word)atol(strtok(0," "));
- if (eof(handle)) {
- level=1;
- next_pos=0L;
- }
- if(seclvl>=security) {
- p=strtok(0," ");
- if(p) {
- strncpy(name,p,46);
- name[46]=0;
- while((p=strchr(name,'_'))!=NULL) *p=' ';
- strtok(0," ");
- strtok(0," ");
- strtok(0,",");
- p=strtok(0,",");
- if(p) fage=(signed char)atoi(p);
- else fage=0;
- if(fage) {
- if(fage>0) {
- if(age<(char)fage) {
- goto Loop;
- }
- }
- else {
- if(age>(char)abs(fage)) {
- goto Loop;
- }
- }
- }
- p=strtok(0,",");
- if(p) flags=(word)atol(p);
- else flags=0;
- if(flags) {
- for(x=0;x<16;x++) {
- if(flags & (1<<x)) {
- if(!(user.attr2 & (1<<x))) {
- goto Loop;
- }
- }
- }
- }
- }
- find_filearea(filename,name,seclvl);
- }
- else if (next_pos) goto Loop;
- else {
- cclose(handle);
- level=1;
- return 0;
- }
- cclose(handle);
- return 1;
- }
-
-
- word pascal next_msgarea (char *filename) {
-
- word register x;
- static long next_pos=0L;
- char s[256];
- char *p,*pp;
- int handle;
- word number;
- word substat1;
- word flags;
- signed char mage;
-
- if(filename==NULL) {
- next_pos=0L;
- return 0;
- }
- if ((handle=oopen(filename,O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(392);
- return 0;
- }
- lseek(handle,next_pos,SEEK_SET);
- level=0;
- Loop:
- if (!fgetsx(s,256,handle)) {
- next_pos=0L;
- level=1;
- cclose(handle);
- return 0;
- }
- next_pos=tell(handle);
- if (*s=='\n' || *s=='\r' || *s==';') goto Loop;
- stripcr(s);
- if(!strtok(s,",")) goto Loop;
- strtok(0," ,");
- strtok(0," ,");
- number=(word)atol(strtok(0," ,"));
- substat1=(word)atol(strtok(0," ,"));
- if(substat1>user.stat[0]) goto Loop;
- p=NULL;
- pp=strtok(0,"\n");
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(p!=NULL) {
- mage=(signed char)atoi(p);
- }
- else mage=0;
- if(mage) {
- if(mage>0) {
- if(age<(char)mage) {
- goto Loop;
- }
- }
- else {
- if(age>(char)abs(mage)) {
- goto Loop;
- }
- }
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(p!=NULL) {
- flags=(word)atol(p);
- }
- else flags=0;
- if(flags) {
- for(x=0;x<16;x++) {
- if(flags & (1<<x)) {
- if(!(user.attr2 & (1<<x))) {
- goto Loop;
- }
- }
- }
- }
- cclose(handle);
- if(find_msgarea(filename,s,0)) return number;
- return 0;
- }
-
-
- char pascal printg (char *text) {
-
- char temppause;
- char returnval;
-
- if (user.graphics) {
- temppause=pauser;
- pauser=2;
- returnval=(printm(text));
- pauser=temppause;
- return returnval;
- }
- return 0;
-
- }
-
-
- void pascal backup (char *p) {
-
- while(*p++) printm(BACKSPACE);
- }
-
-
- void pascal backupnum (int p) {
-
- while(p--) printm(BACKSPACE);
- }
-
-
- char * pascal mystrdup (char *str) { /* Replaces strdup() */
-
- char *s;
-
- s=(char *)mmalloc(strlen(str));
- if(!s) return NULL;
- strcpy(s,str);
- return s;
- }
-
-
- char * pascal var_trans (char *str) {
-
- static char s[34];
-
- if(str==NULL) return "";
- if(*str=='@') {
- if(isdigit(str[1])) {
- return variable[str[1]-'0'];
- }
- }
- if(*str=='e') {
- if(isdigit(str[1])) {
- sprintf(s,"%u",lastlevel[str[1]]);
- return s;
- }
- }
- return str;
- }
-
-
- int pascal isleech (char percent) {
-
- if(!user.ignorerat && (user.downno>(word)conf.startat) && percent) {
- if(((long)fboard.leechpercent<(long)(user.downk/user.upk))) {
- if(((long)fboard.leechpercent<(long)(user.downno/user.upno))) {
- return 1;
- }
- }
- }
- return 0;
- }
-