home *** CD-ROM | disk | FTP | other *** search
- /* MSETUP -- a program for setting up customized MSGAREAS.XBS files
- copyright (c) 1990 by M. Kimes.
- It's free-for-the-asking. Created from DOORSKEL.C */
-
- /********************** Miscellaneous notes: *****************************
-
- This program creates a MSGAREAS.### (where the ### is the node number
- of the calling XBBS) containing only the areas the user has requested
- to have access to. It creates a datafile called MSETUP.USR which
- contains struct _msetup entries, one per user. There are no provisions
- for deleting entries from the file; someone needs to add to this program
- to do that, or write a separate utility (possibly something that compares
- the names in MSETUP.USR with those in USERS.BBS and deletes any not found
- in USERS.BBS).
-
- *************************************************************************/
-
-
- #include "msgg.h" /* XBBS include file */
-
- #define PROGRAM_NAME "XBBS user message area setup"
- #define COPY_RIGHT "Copyright (c) 1990 by M. Kimes -- All Rights Reserved"
-
- #define XBBS "UseIt"
-
- /* Function declarations */
-
- #ifdef XBBS
- void pascal getonline(void);
- void pascal readconfig(void);
- void pascal prepare(void);
- void pascal saveconfig(void);
- #endif
-
- #ifndef NOREADFILE
- char pascal readtext(char *,char);
- char * pascal write_line (char **text,word linelen);
- void pascal strip_blanklines (char *hold);
- #endif
-
- void pascal hitreturn(void);
- void pascal do_fboard (void);
- void pascal cls (void);
- void cdecl debug_print(char *,...);
- char * pascal addtolog(char *);
- char pascal inkey (void);
- char pascal carrchk (void);
- char pascal fossil (char function, char arg);
- char pascal printm (char *text);
- void pascal checkpos(void);
- void cdecl deinitialize (void);
- char * pascal genin (char length,char password,char caps,char hot,char type);
- void pascal print_stat();
- char * pascal fidodate (void);
- ulong pascal getxbbstime(void);
- char pascal specialkey(char);
- int cdecl break_handler(void);
- char pascal printg(char *);
- char pascal skip_blanks(FILE *fp);
- void pascal chat(void);
- void pascal printinfo(void);
- void pascal printhelp(void);
- char * pascal lstrip(char *);
- char * pascal rstrip(char *);
- int cdecl printfm(char *,...);
- char * pascal stripcr(char *);
- void pascal load_msgareas (char *file);
- void pascal display_current (char enable,int lorange, int hirange);
- word pascal load_user (void);
- void pascal save_user (word numuser);
- int pascal edit_areas (void);
- int pascal do_bits (int x,char what);
-
- int pascal mainloop(void); /* Change as required */
-
-
- /* Global variables */
-
-
- #ifdef XBBS
- struct _config conf;
- struct _user user;
- word userno;
- struct time timeon;
- char timer_off;
- word hold_time;
- char age;
- char pages;
- struct _mboard mboard;
- struct _fboard fboard;
- struct _events event[10];
- char variable[10][82];
- #endif
-
- /* NOTE DEFAULTS! */
-
- char debug_mode=0;
- char graphics=0;
- word timelimit=30;
- word baud=0;
- char numlines=24;
- word seclvl=5;
- ulong startt=0;
- char sysopin=0;
- char fastANSI=0;
- char commport=0;
- struct time starter;
- union REGS rg;
- char logfile[133]="XBBS.LOG";
- char username[36]="A. Ghost";
- char width=80;
- char fast=0;
- char chatting=0;
- char chatted=0;
- char nodenumber=1;
- char system_name[64]="";
- char sysop[36]="";
-
- struct _msetup {
- unsigned long userid;
- char node;
- unsigned char areas[512];
- } mset;
-
- #define MAXNUMAREA 1024
-
- struct _ffboard {
- char name[47];
- char flags;
- word security;
- char dpath[79];
- char upath[79];
- char descr[79];
- signed char age;
- word userflags;
- char leechpercent;
- };
-
- struct _mmboard {
- char name[48];
- char forceto[36];
- word attr;
- word max;
- word number;
- word substat1;
- word substat2;
- char descr[79];
- signed char age;
- word flags;
- word zone;
- word net;
- word node;
- word point;
- char yourname[36];
- word minwrite;
- };
-
- char pathfile[133]="";
- char msgareasfile[133]="";
- char filetocreate[133]="";
- char fileareasfile[133]="";
- char filefiletocreate[133]="";
- struct _mmboard huge *marea=NULL;
- struct _mmboard huge *currarea=NULL;
- word higharea;
- word maxareas=0;
- char create=0;
- char fseclvl=0;
- char dofiles=0;
-
-
-
- int cdecl main (int argc,char **argv) {
-
- register word x;
- char *p;
-
- /* Please leave this next line in...thanks */
- fputs("\x1b[2J\x1b[0;2;37m\x1b[1;1H\04 Made using M. Kimes' DOORSKEL.C -- MSetup H for help\n",stdout);
-
- directvideo=0;
- gettime(&starter);
- ctrlbrk(break_handler);
-
- if (argc==2 && !strcmp(strupr(argv[1]),"H")) {
- printinfo();
- printhelp();
- exit(0);
- }
- atexit(deinitialize);
-
- #ifdef XBBS
- readconfig();
- getonline();
- #endif
-
- #ifdef DORINFO
- readinfo();
- #endif
-
- for (x=1;x<argc;x++) {
- strupr(argv[x]);
- switch (*argv[x]) {
- case 'F': fastANSI=1;
- break;
- case 'N': nodenumber=(char)atoi(&argv[x][1]);
- break;
- case 'L': numlines=(char)atoi(&argv[x][1]);
- break;
- case 'W': width=(char)atoi(&argv[x][1]);
- break;
- case 'B': baud=(word)atoi(&argv[x][1]);
- break;
- case 'G': if(atoi(&argv[x][1])) graphics=1;
- break;
- case 'C': commport=(char)atoi(&argv[x][1]);
- break;
- case 'T': timelimit=atoi(&argv[x][1]);
- break;
- case 'M': directvideo=atoi(&argv[x][1]);
- break;
- case '!': debug_mode=1;
- break;
- case 'X': strcpy(logfile,&argv[x][1]);
- break;
- case 'A': strcpy(msgareasfile,&argv[x][1]);
- break;
- case 'J': create=1;
- baud=0;
- break;
- case '&': fseclvl=(char)atoi(&argv[x][1]);
- dofiles=1;
- break;
- case 'P': strcpy(pathfile,&argv[x][1]);
- break;
- case 'S': strcpy(fileareasfile,&argv[x][1]);
- break;
- default: fputs("\nUnknown argument `",stdout);
- fputs(argv[x],stdout);
- fputs("'\n",stdout);
- sleep(1);
- }
- }
- fossil(INIT,0);
- cls();
-
- printg("\x1b[0;1;37m");
- p=PROGRAM_NAME;
- if(baud) while (*p++) while(!fossil(TRANSMIT,*p)) carrchk();
- printinfo();
- printm("\n");
-
- mset.userid=user.id;
- mset.node=user.node;
- for(x=0;x<512;x++) mset.areas[x]=255;
-
- if(!*msgareasfile) sprintf(msgareasfile,"%sMSGAREAS.XBS",conf.messpath);
- if(!*filetocreate) sprintf(filetocreate,"MSGAREAS.%03hu",nodenumber);
-
- return (mainloop());
- }
-
-
-
- int pascal mainloop (void) {
-
- int register x;
- FILE *fp;
- word numuser;
-
- if(!*msgareasfile) return 1;
- marea=(struct _mmboard huge*)farmalloc((MAXNUMAREA*sizeof(struct _mmboard))+sizeof(struct _mmboard));
- if (marea==NULL) {
- printm("\nCan't allocate enough memory for areas...\n");
- maxareas=0;
- if(dofiles) do_fboard();
- return 1;
- }
- load_msgareas(msgareasfile);
-
- numuser=load_user();
-
- if(!create) {
- if(!edit_areas()) return 2;
- printm("\nSaving...\n");
- }
-
- if(!((fp=fopen(filetocreate,"wb")))) {
- printm("\nUnable to create new file\n");
- hitreturn();
- }
- else {
- for(x=0;x<maxareas;x++) {
- if(do_bits(marea[x].number-1,0)) {
- fprintf(fp,"%s,%u,%u,%u,%u,%u",marea[x].name,marea[x].attr,marea[x].max,marea[x].number,marea[x].substat1,marea[x].substat2);
- fprintf(fp,",%s",marea[x].forceto);
- fprintf(fp,",%s",marea[x].descr);
- fprintf(fp,",%hd",marea[x].age);
- fprintf(fp,",%u",marea[x].flags);
- if(marea[x].zone && marea[x].net) {
- fprintf(fp,",%u:%u/%01u.%01u",marea[x].zone,marea[x].net,marea[x].node,marea[x].point);
- }
- else fprintf(fp,",");
- fprintf(fp,",%s",marea[x].yourname);
- fprintf(fp,",%u",marea[x].minwrite);
- fprintf(fp,"\r\n");
- }
- }
- fprintf(fp,"\r\n");
- fclose(fp);
- baud=0;
- printfm("\n\04Created %s...\n",filetocreate);
- }
-
- if(!create)save_user(numuser);
-
- farfree((struct _mmboard far *)marea);
-
- if(dofiles) do_fboard();
- marea=NULL;
- return 0;
- }
-
-
-
- void pascal printhelp (void) { /* Print help screen */
-
- fputs("L<screen lines>\n",stdout);
- fputs("N<nodenumber>\n",stdout);
- fputs("W<screen width>\n",stdout);
- fputs("T<time in minutes>\n",stdout);
- fputs("B<baudrate>\n",stdout);
- fputs("G<1 for graphics>\n",stdout);
- fputs("C<commport (0=COM1)>\n",stdout);
- fputs("X<filename> (Log File)\n",stdout);
- fputs(" Above normally taken from ONLINE.XBS\n",stdout);
- fputs("M<mode (0=direct video, 1=BIOS, 2=DOS)>\n",stdout);
- fputs("F (Fast ANSI writes)\n",stdout);
- fputs("! (Debug mode on)\n",stdout);
- fputs("J (just create MSGAREAS.### in default directory)\n",stdout);
- fputs("A<msgareas file to read> (defaults to messpath\\MSGAREAS.XBS)\n",stdout);
- fputs("&<#> (also create FLSEARCH.### in default directory using sec lvl <#>)\n",stdout);
- fputs(" If the &<#> argument is processed, these are valid:\n",stdout);
- fputs("S<fileareas file to read> (defaults to FLSEARCH.CTL)\n",stdout);
- fputs("P<pathfilename> (D/L Path list file (for Bimodem, etc.) to create\n",stdout);
- fputs(" Note that three files are created: the FLSEARCH.### file, the path file,\n"
- " and a 'plain' PLSEARCH.### file (without extra XBBS info in it).\n",stdout);
- }
-
-
-
-
- int cdecl break_handler (void) { /* Diables ctrl-break */
-
- return 1;
-
- }
-
- void pascal chat (void) { /* Cheap chat-mode */
-
- char a[3];
-
- printg("\x1b[0;1;33m");
- printm("\n\nChat mode engaged\n\n");
- while (chatting) {
- *a=inkey();
- a[1]=0;
- if (chatting) {
- _AH=3;
- _BH=0;
- geninterrupt(16);
- if (*a==13) printm("\n");
- if ((*a==13) || (*a==' ' && _DL>70)) printm("\n");
- else printm(a);
- }
- }
- printm("\n\nChat mode ended\n\n");
- chatted++;
- }
-
-
-
- #ifndef NOREADFILE
-
- char pascal readtext (char *s,char paged) { /* Displays a text file
- This thing's got all
- sorts of fancy stuff
- in it if you set paged=1
- Otherwise it does a pretty
- dumb dump (ok for ANSI
- files) */
-
- long place2;
- long place;
- struct ffblk filestat;
- char dostring[181];
- char eof=0;
- word page;
- char a;
- long *pos;
- word scratch;
- FILE *fp;
- register int x;
- char prev=0;
- char *here;
- char *p;
- char *tempo;
- char temp='N';
- char lastpage=0;
- char searchstring[41];
- char holdstring[41];
- char teststring[81];
- char findend=0;
- char printanyway=0;
- char linelen;
- word lines=1;
-
- *searchstring=0;
- *holdstring=0;
-
- if (findfirst(s,&filestat,0)) return 1;
- if (!filestat.ff_fsize) return 1;
- if (!(fp=fopen(s,"rt"))) return 1;
- cls();
- printg("\x1b[0;1;33m");
- page=0;
- place2=ftell(fp);
- if (!paged) {
- printm("\n");
- while (!feof(fp) && !ferror(fp)) {
- if (!fgets(dostring,181,fp)) break;
- if(ftell(fp)<=place2) {
- while(fgetc(fp)=='\n'); /* Guard against Unix files & TC bug */
- continue;
- }
- place2=ftell(fp);
- printm(dostring);
- if(numlines) {
- lines++;
- if(lines>numlines+1) {
- lines=1;
- printm("More? (Y/n) ");
- fossil(FLUSHOUT,0);
- fossil(PURGEIN,0);
- linelen=*genin(1,0,1,1,YESNOM);
- for (x=0;x<12;x++) printm(BACKSPACE);
- if (linelen == 'N') break;
- }
- }
- a=toupper(inkey());
- if (a=='S' || a==' ') break;
- if (a=='P') sleep(5);
- }
- fclose(fp);
- if (numlines) if (lines>numlines-11) hitreturn();
- return 0;
- }
-
- /*
- if (!baud && *reader) {
- fclose(fp);
- sprintf(dostring,"%s %s",reader,s);
- system(dostring);
- return 0;
- }
- */
-
- p=strchr(s,':'); /* Strip path off filename for display */
- here=strrchr(s,'\\');
- if(!p && !here) here=s;
- else if (!here) here=&p[1];
- else if (p) here= (p<here) ? &here[1] : &p[1];
- else here++;
-
- pos=(long *)malloc((word)(sizeof(long)*1024));
- if(!pos) {
- fclose(fp);
- printm("\nOut of memory\n");
- exit(4);
- }
-
- printfm(" -=-=Reading: %s=-=- Page #%u\n",here,page+1);
-
- printg("\x1b[0;1;32m");
- if(skip_blanks(fp)) goto Abort;
- place2=pos[0]=ftell(fp);
- lines=1;
- while (!feof(fp) && !ferror(fp)) {
- if ((*searchstring && !printanyway) || findend) goto Searcher;
- Domore:
- if (!fgets(dostring,181,fp)) {
- eof++;
- goto EEOF;
- }
- if(ftell(fp)<=place2) {
- while(fgetc(fp)=='\n'); /* Guard against Unix files & TC bug */
- continue;
- }
- place2=ftell(fp);
- stripcr(dostring);
- while (p=strchr(dostring,'\xc')) memmove(p,&p[1],strlen(&p[1])+1);
- while (p=strchr(dostring,'\x1b')) memmove(p,&p[1],strlen(&p[1])+1);
- if (!*dostring) {
- if (prev) {
- prev=0;
- eof=skip_blanks(fp);
- if (eof) goto EEOF;
- else goto Domore;
- }
- else prev++;
- }
- else prev=0;
- if (*searchstring) {
- strcpy(teststring,dostring);
- strupr(teststring);
- if (strstr(teststring,searchstring)) {
- printg("\x1b[0;1;37m");
- fast=2;
- printm(dostring);
- printg("\x1b[0;1;32m");
- lines++;
- }
- else {
- fast=1;
- printm(dostring);
- lines++;
- }
- }
- else {
- fast=1;
- printm(dostring);
- lines++;
- }
- scratch=strlen(dostring);
- p=dostring;
- while(tempo=strchr(p,'\t')) {
- p=tempo+1;
- scratch+=3;
- }
- if (scratch<79) {
- printm("\n");
- scratch++;
- }
- if (scratch>width) {
- lines++;
- }
- a=toupper(inkey());
- if (a=='S' || a==' ') break;
- if (a=='P' || a=='-') if (page) goto SkipThis;
- if (a=='M') goto Direct;
- Searcher:
- if (lastpage) goto EEOF;
- if ((a=='N') || (*searchstring) || (findend)) {
- if (findend) {
- if (++page>1024) page=1;
- pos[page]=ftell(fp);
- }
- place2=place=ftell(fp);
- Domore1:
- while (!feof(fp) && !ferror(fp)) {
- Domore2:
- if (!fgets(dostring,181,fp)) {
- eof++;
- break;
- }
- if(ftell(fp)<=place2) {
- while(fgetc(fp)=='\n'); /* Guard against Unix files & TC bug */
- continue;
- }
- place2=ftell(fp);
- while (p=strchr(dostring,'\xc')) memmove(p,&p[1],strlen(&p[1])+1);
- while (p=strchr(dostring,'\x1b')) memmove(p,&p[1],strlen(&p[1])+1);
- if (!strcmp(dostring,"\n")) {
- if (prev) {
- prev=0;
- eof=skip_blanks(fp);
- if (eof) break;
- else goto Domore2;
- }
- else prev++;
- }
- else prev=0;
- if (*searchstring) {
- if (strstr(strupr(dostring),searchstring)) {
- printanyway++;
- break;
- }
- }
- lines++;
- scratch=strlen(dostring);
- p=dostring;
- while(tempo=strchr(p,'\t')) {
- p=tempo+1;
- scratch+=3;
- }
- if (scratch<79) {
- scratch++;
- }
- if (scratch>width) lines++;
- if (numlines) if ((lines>=numlines-2) || (feof(fp)) || (eof)) break;
- }
- fossil(PURGEIN,0);
- eof=skip_blanks(fp);
- if (feof(fp) || eof || printanyway) {
- if (*searchstring && !printanyway) {
- printm("\nNot found...\n");
- goto EEOF;
- }
- fseek(fp,place,SEEK_SET);
- clearerr(fp);
- cls();
- printg("\x1b[0;1;33m");
- printfm(" -=-=Reading: %s=-=- Page #%u\n",here,page+1);
- printg("\x1b[0;1;32m");
- findend=prev=eof=0;
- lastpage=lines=1;
- goto Domore;
- }
- if ((*searchstring || findend) && !eof) {
- if (++page>1024) page=1;
- pos[page]=place=place2=ftell(fp);
- lines=1;
- goto Domore1;
- }
- }
- EEOF:
- if (numlines) if ((lines>=numlines-2) || (feof(fp)) || (eof)) {
- Direct:
- linelen=0;
- prev=0;
- eof=skip_blanks(fp);
- if (feof(fp) || eof) {
- printg("\x1b[0;1;31m");
- printm(" (END)");
- linelen+=6;
- printg("\x1b[0;1;33m");
- temp='S';
- }
- else {
- if (a=='M' || a=='N') goto SkipThis;
- temp='N';
- printg("\x1b[0;1;33m");
- printm(" [F]ind [E]nd [N]ext [M]ore");
- linelen+=27;
- }
- if (page) {
- printm(" [H]ome [P]rior");
- linelen+=15;
- }
- linelen+=sprintf(dostring," [O]ver [S]top: [%c] ",temp);
- printm(dostring);
- fossil(FLUSHOUT,0);
- pos[page+1]=ftell(fp);
- Getitagain:
- fossil(PURGEIN,0);
- a=*genin(1,0,1,1,ALLL);
- SkipThis:
- findend=0;
- lastpage=0;
- printanyway=0;
- *searchstring=0;
- switch (a) {
- case 'S': goto Abort;
- case 'H': if (!page) {
- printm(BACKSPACE);
- printm("\x7");
- goto Getitagain;
- }
- page=0;
- fseek(fp,0,SEEK_SET);
- break;
- case 'E': if (feof(fp) || eof) {
- printm(BACKSPACE);
- printm("\x7");
- goto Getitagain;
- }
- findend++;
- break;
- case 'F': if (feof(fp) || eof) {
- printm(BACKSPACE);
- printm("\x7");
- goto Getitagain;
- }
- printg("\x1b[0;1;35m");
- printfm("\n Search string: [%s]\n -> ",holdstring);
- strcpy(searchstring,genin(40,0,1,0,ALLL));
- if (!*searchstring) {
- if (*holdstring) {
- strcpy(searchstring,holdstring);
- if (++page>1024) page=1;
- pos[page]=ftell(fp);
- }
- }
- else strcpy(holdstring,searchstring);
- fseek(fp,pos[page],SEEK_SET);
- eof=skip_blanks(fp);
- break;
- case 0: if (feof(fp) || eof) goto Abort;
- case 'N': if (feof(fp) || eof) {
- printm(BACKSPACE);
- printm("\x7");
- goto Getitagain;
- }
- a=0;
- if (++page>1024) page=1;
- pos[page]=ftell(fp);
- break;
- case 'O': fseek(fp,pos[page],SEEK_SET);
- eof=skip_blanks(fp);
- break;
- case 'P':
- case '-': if (page) {
- fseek(fp,pos[--page],SEEK_SET);
- eof=skip_blanks(fp);
- break;
- }
- printm(BACKSPACE);
- printm("\x7");
- goto Getitagain;
- case 'M': if (feof(fp) || eof) {
- printm("\x7");
- printm(BACKSPACE);
- goto Getitagain;
- }
- for (x=0;x<linelen;x++) printm(BACKSPACE);
- printg("\x1b[0;1;32m");
- if (numlines) lines=numlines-3;
- goto Domore;
- default: printm(BACKSPACE);
- goto Getitagain;
- }
- place2=ftell(fp);
- eof=0;
- cls();
- printg("\x1b[0;1;33m");
- if (findend || *searchstring) strcpy(teststring,"Scanning");
- else strcpy(teststring,"Reading");
- printfm(" -=-=%s: %s=-=- Page #%u\n",teststring,here,page+1);
- printg("\x1b[0;1;32m");
- lines=1;
- }
- }
- Abort:
- if(pos) free(pos);
- fclose(fp);
- return 0;
-
- }
-
-
-
- /*
-
- char * pascal write_line (char **text,word linelen) {
-
- static char line[81];
- word register x=0;
- char *p;
- char *pp;
-
- p=*text;
- pp=line;
- *pp=0;
- while(++x<linelen && *p && *p!='\r') {
- *pp++=*p++;
- *pp=0;
- }
- while(*pp==' ' && pp>line) {
- *pp=0;
- --pp;
- }
- if(*p==' ' || *p=='\r') {
- if(*p==' ') *pp=0;
- else p++;
- while(*p==' ') p++;
- }
- else if(x==linelen) {
- while(p>*text && *pp!=' ') {
- *pp=0;
- pp--;
- p--;
- }
- if(p==*text) {
- strncpy(line,*text,linelen);
- line[linelen]=0;
- p=text[linelen];
- }
- else p++;
- }
- *text=p;
- return line;
- }
-
-
- void pascal strip_blanklines (char *hold) {
-
- char *p;
-
- p=&hold[strlen(hold)-1];
- while(*p=='\r' && p>hold) {
- *p=0;
- p--;
- }
- }
-
- */
-
- #endif
-
-
-
- char pascal skip_blanks (FILE *fp) { /* Skips blank lines, what else? */
-
- ulong pos;
- char temp[81];
- char eof=0;
-
- do {
- pos=ftell(fp);
- if (!fgets(temp,81,fp)) eof++;
- stripcr(temp);
- } while ((!eof) && (!feof(fp)) && (!*temp));
- if (!eof && !feof(fp)) fseek(fp,pos,SEEK_SET);
- return eof;
-
- }
-
-
-
- char pascal printg (text) /* Print only if user has graphics set */
-
- char *text;
-
- {
-
- if (graphics) return (printm(text));
-
- }
-
-
-
- char pascal inkey (void) /* MIMICS BASIC'S INKEY$ FUNCTION */
-
- {
-
- char arg=0;
- static int check=0;
-
- rg.h.ah=11;
- int86(33,&rg,&rg);
- if (rg.h.al!=0) {
- rg.h.ah=8;
- int86(33,&rg,&rg);
- if (rg.h.al!=0)return((char)(rg.h.al));
- rg.h.ah=8;
- int86(33,&rg,&rg);
- arg=specialkey(rg.h.al);
- if (arg) return (arg);
- }
- if (baud) {
- arg=carrchk();
- if (!(arg & 1)) return (0);
- return (fossil(RECVWAIT,arg));
- }
- if (check!=(int)(timelimit-(getxbbstime()/60))) {
- check=(int)(timelimit-(getxbbstime()/60));
- }
- return (0);
- }
-
-
-
- char pascal specialkey (a) /* Handles special local-only keys
- Add anything you like (extended keys) */
-
- char a;
-
- {
-
- char middle[82];
- int drive;
- char dir[MAXDIR];
-
- switch (a) {
- case 45:exit (0); /* QUIT DOOR */
- case 46:if (!chatting) { /* CHAT */
- chatting++;
- chat();
- }
- else chatting=0;
- break;
- case 35: /* HANG UP */
- fossil(DTR,DOWN);
- exit(1);
- case 36: /* SysOp SHELL */
- printm("\nThe SysOp has jumped to DOS...please wait...\n");
- fossil(FLUSHOUT,0);
- drive=getdisk();
- getcurdir(++drive,dir);
- fossil(DEINIT,0);
- fputs("\nEXIT to return\n",stdout);
- system ("");
- fossil(INIT,0);
- setdisk (--drive);
- strcpy(middle,"\\");
- strcat(middle,dir);
- chdir(middle);
- printm("\nThe SysOp has returned...please continue...\n");
- chatted++;
- break;
- case 72: /* MORE TIME */
- timelimit++;
- break;
- case 80: /* LESS TIME */
- if (timelimit<1) timelimit=0;
- else timelimit--;
- break;
- case 73:return 'P';
- case 81:return 'N';
- case 71:return 'H';
- }
- startt=getxbbstime();
- return 0;
- }
-
-
-
- void pascal cls (void) { /* MIMICS BASIC'S CLS FUNCTION LOCAL & REMOTE */
-
- char clr_string[]="\x1b[0m\x1b[2J";
- char *p;
-
- if(!graphics)strcpy(clr_string,"\xc");
- p=clr_string;
- if(baud) while (*p++) while(!fossil(TRANSMIT,*p)) carrchk();
- fputs("\x1b[0;2m\x1b[2J",stdout);
- print_stat();
- }
-
-
- char pascal fossil (function,arg) /* HANDLES MOST USEFUL FOSSIL CALLS */
-
- char function;
- char arg;
-
- {
-
- if(!baud) return 0;
- if ((function == FLUSHOUT) && (baud>0))
- {
- do {
- carrchk();
- rg.h.ah=3;
- rg.x.dx=commport;
- int86(20,&rg,&rg);
- }
- while ((rg.h.ah & 64)==0);
- return(0);
- }
-
- if (function == WATCHDOG) rg.h.al = arg;
- if (function == DTR) rg.h.al = arg;
- if (function == TRANSWAIT) rg.h.al = arg;
- if (function == TRANSMIT) rg.h.al = arg;
- if (function == ONOFF) rg.h.al = arg;
-
- rg.x.dx=commport;
- rg.h.ah=function;
- int86(20,&rg,&rg);
-
- if (function == INIT)
- {
- if (rg.x.ax != INITOK)
- {
- fputs("\nFossil not responding...RTFM.\n",stdout);
- exit (3);
- }
- return (0);
- }
-
- if (function == GETSTAT)
- {
- arg = rg.h.ah;
- if (rg.h.al & 128)
- {
- arg |= 128;
- return (arg);
- }
- arg &= 127;
- return (arg);
- }
-
- if (function == RECVWAIT) return (rg.h.al);
- if (function == TRANSMIT) return (rg.x.ax);
-
- return (0);
-
- }
-
-
-
- void cdecl deinitialize (void) /* DEINITIALIZES FOSSIL ON EXIT */
-
- {
-
- register word x;
-
- fossil(FLUSHOUT,0);
- fossil (DEINIT,0);
- if(marea)free((struct _mmboard far *)marea);
- marea=NULL;
- baud=0;
- fcloseall();
- printm("\n");
- fputs("\x1b[0;2;37m\n",stdout);
- }
-
-
-
- char * pascal genin (length,password,caps,hot,type) /* GENERIC INPUT ROUTINE */
-
- char length;
- char password;
- char caps;
- char hot;
- char type;
-
- {
-
- static char input[257];
- int x=0;
- char one=0;
- char randchr[2];
-
- length--;
-
- AfterChat:
-
- strset(input,0);
- startt=getxbbstime();
-
- while ((getxbbstime()-startt)<241 || (chatted!=0)) {
-
- one=inkey();
- if (one == '\r') break;
-
- Nogo:
-
- if (one == 8) {
- if (x>0) {
- printm(BACKSPACE);
- input [--x]=0;
- if ((type==PHONE) && ((x==2) or (x==5))) printm(BACKSPACE);
- if ((type==DATE) && ((x==1) or (x==3))) printm(BACKSPACE);
- }
- continue;
- }
- if ((caps) or (type==YESNO) or (type==YESNOM) or (type==FLE) or (type==FLEW) or (type==FLEPW) or (type==FLEP)) one=toupper(one);
- if (x <= length) {
- if (type==NAME) {
- if((isalpha(one)==0) && (one!=' ') && (one!='.') && (one!='-') or (x==0 && one==' ')) continue;
- if ((one==' ') && (strchr(input,' ')!=NULL)) continue;
- }
- if (type==NEAT) {
- if((isalnum(one)==0) && (one!=' ') or (x==0 && one==' ')) continue;
- }
- if ((type==NEAT) or (type==NAME)) {
- if(x==0) {
- one=toupper(one);
- }
- else one=tolower(one);
- }
- if((type==NEAT) or (type==NAME)) {
- if((x>0) && ((input[x-1]==' ') or (input[x-1]=='.') or (input[x-1]=='-'))) one=toupper(one);
- }
- if ((type==SUBJECT) && (x==0)) one=toupper(one);
- if ((type==SUBJECT) && (isprint(one)==0)) continue;
- if ((type==ALLL) && (isprint(one)==0)) continue;
- if ((type==ALLL) && (one==127)) one=8;
- if ((type==ALPHA) && (isalpha(one)==0) && (one!=' ')) continue;
- if (((type==NUM) or (type==PHONE) or (type==DATE)) and (isdigit(one)==0)) continue;
- if ((type==ALPHANUM) and (isalnum(one)==0) and (one!=' ')) continue;
- if (((type==YESNO) or (type==YESNOM)) and (one!='Y' and one!='N')) continue;
- if (type==FLE) {
- if ((isalnum(one)==0) and (!strchr("._-+=!@#$%^&<>/",one))) continue;
- }
- if (type==FLEP) {
- if ((isalnum(one)==0) and (!strchr("._-+=!@#$%^&<>/\\:",one))) continue;
- }
- if (type==FLEW) {
- if ((isalnum(one)==0) and (!strchr("._-+=!@#$%^&<>/?*",one))) continue;
- }
- if (type==FLEPW) {
- if ((isalnum(one)==0) and (!strchr("._-+=!@#$%^&<>/?*\\:",one))) continue;
- }
- if ((type==FLE) or (type==FLEP) or (type==FLEW) or (type==FLEPW)) {
- if ((one=='.') and (strchr(input,'.')!=NULL)) continue;
- }
- }
- if (chatted>0) {
- chatted=0;
- goto AfterChat;
- }
-
- if ((one!=0) and (x <= length)) {
- input[x]=one;
- input[++x]=0;
- if (type==YESNOM) {
- return(input);
- }
- if (password==0) printm(&input[x-1]);
- if (password!=0) {
- randchr[0]=random(10)+33;
- randchr[1]=0;
- printm(randchr);
- }
- if ((type==PHONE) and ((x==3) or (x==6))) printm("-");
- if ((type==DATE) and ((x==2) or (x==4))) printm("/");
- AfterCtrl:
- if ((hot!=0)and(x >= length)) {
- return (input);
- }
- startt=getxbbstime();
- }
-
- }
- if (chatted) {
- chatted=0;
- goto AfterChat;
- }
- if ((getxbbstime()-startt)>240) {
- fputs("\nUser time-out...\n",stdout);
- exit (2);
- }
- return (input);
- }
-
-
- char pascal carrchk (void) /* Checks for carrier */
-
- {
- if (baud) {
- rg.x.dx=commport;
- rg.h.ah=GETSTAT;
- int86(20,&rg,&rg);
- if (!(rg.h.al & 128)) {
- sleep(1);
- rg.x.dx=commport;
- rg.h.ah=GETSTAT;
- int86(20,&rg,&rg);
- if (!(rg.h.al & 128)) {
- fossil(DTR,DOWN);
- baud=0;
- fputs("\n\04 Lost carrier...\n",stdout);
- exit (1);
- }
- }
- return (rg.h.ah);
- }
- return 0;
- }
-
-
- void pascal hitreturn (void) /* Pause until [Enter] is pressed */
-
- {
-
- register word x;
-
- startt=getxbbstime();
- printm("\n[Enter] to continue...");
- while ((getxbbstime()-startt)<241) {
- if (inkey()==13) goto hedid;
- }
- fputs("\n\x4 User time-out...\n",stdout);
- exit (2);
- hedid:
- for(x=0;x<22;x++) printm(BACKSPACE);
- }
-
-
- ulong pascal getxbbstime (void) /* GP User Timer */
-
- {
-
- static int hour;
- static int min;
- static int sec;
- static int lastsec;
- static int x;
- static int y;
- static struct time dos_time;
- static ulong xbbs_time;
- static int warned;
- static int byebye=0;
-
- gettime(&dos_time);
-
- hour=dos_time.ti_hour-starter.ti_hour;
- min=dos_time.ti_min-starter.ti_min;
- sec=dos_time.ti_sec-starter.ti_sec;
-
- if (dos_time.ti_hour<starter.ti_hour) hour=hour+24;
-
- xbbs_time=(long)(hour*3600)+(min*60)+sec;
-
- if (((timelimit*60)<(xbbs_time+120)) && (warned==0)) {
- warned++;
- printfm("\nWARNING: %u minutes remaining.",(timelimit-(xbbs_time)/60));
- }
-
- if (((timelimit*60) > ((xbbs_time+1L)+120L)) && (warned!=0)) warned=0;
-
- if ((timelimit*60) < (xbbs_time+1)) {
- if(byebye) return xbbs_time;
- byebye=1;
- timelimit=(word)(xbbs_time/60L)+4;
- printm("\nSorry, time to logoff...\n");
- fossil(FLUSHOUT,0);
- exit(0);
- }
-
- juststarting:
-
- if(dos_time.ti_sec!=lastsec) {
- lastsec=dos_time.ti_sec;
- x=wherex();
- y=wherey();
- gotoxy(68,25);
- textbackground(7);
- textcolor(0);
- cprintf("%02d:%02d:%02d|%03u",dos_time.ti_hour,dos_time.ti_min,dos_time.ti_sec,(word)(timelimit-(word)(xbbs_time/60L)));
- gotoxy(x,y);
- }
- return(xbbs_time);
- }
-
-
- void pascal printinfo (void) /* Just prints prog info locally */
-
- {
-
- printf(" %s\n\04 %s\n\04 Compiled: %s %s\n",PROGRAM_NAME,COPY_RIGHT,__DATE__,__TIME__);
-
- }
-
-
-
- char * pascal fidodate (void) /* Builds a Fido(tm) datestring */
-
- {
-
- char months[12][4]={
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- };
- static char fdate[20];
- struct date dos_date;
- struct time dos_time;
-
- /* 26 Jul 89 06:23:47 */
-
- getdate(&dos_date);
- gettime(&dos_time);
-
- sprintf(fdate,"%02hu %s %02d %02hu:%02hu:%02hu",dos_date.da_day,months[dos_date.da_mon-1],dos_date.da_year%100,dos_time.ti_hour,dos_time.ti_min,dos_time.ti_sec);
- return(fdate);
-
- }
-
-
-
- char * pascal stripcr (char *a) /* Strips trailing CR's & LF's */
-
- {
-
- while (a[strlen(a)-1]=='\n' || a[strlen(a)-1]=='\r') a[strlen(a)-1]=0;
- return a;
-
- }
-
-
-
-
- char * pascal lstrip (char *a) { /* Strips leading blanks */
-
- while (*a==' ') memmove (a,(a+1),strlen(a));
- return (a);
- }
-
-
-
- char * pascal rstrip (char *a) { /* Strips trailing blanks */
-
- while (*a && a[strlen(a)-1]==' ') a[strlen(a)-1]=0;
- return a;
- }
-
-
-
- void cdecl debug_print (char *string,...) { /* Local-only messages only
- displayed if debug-mode is
- turned on by ! argument */
-
- word tempbaud;
- static char buffer[318];
-
- va_list ap;
- va_start(ap,string);
- vsprintf(buffer,string,ap);
- va_end(ap);
- if(debug_mode){
- tempbaud=baud;
- baud=0;
- printm(buffer);
- baud=tempbaud;
- }
- }
-
-
-
- int cdecl printfm (char *string,...) { /* Like printf() for local
- and remote */
-
- static char buffer[318];
-
- va_list ap;
- va_start(ap,string);
- vsprintf(buffer,string,ap);
- va_end(ap);
- return(printm(buffer));
- }
-
-
-
- char pascal printm (char *text) { /* Prints local and remote */
-
- char *p;
-
- while ((p=strstr(text,"\x1b[2J"))!=NULL) {
- memmove(&p[1],&p[4],strlen(&p[4])+1);
- *p='\xc';
- }
- while ((p=strchr(text,'\x7')) && !sysopin) memmove(p,&p[1],strlen(&p[1])+1);
- while (p=strchr(text,'\r')) *p='\n';
- if (fast) {
- if(fast==1) {
- textbackground(0);
- textcolor(10);
- }
- if(fast==2) {
- textbackground(10);
- textcolor(0);
- }
- }
- while(*text) {
- if (*text=='\xc') { /* Clear screen */
- cls();
- text++;
- continue;
- }
- if(*text=='\t') {
- text++;
- printm(" ");
- continue;
- }
- if (fast && *text!='\n') {
- putch(*text);
- }
- else if (fastANSI) {
- Again1:
- _AX=(int)*text;
- geninterrupt(0x29);
- if(baud) while (!fossil(TRANSMIT,*text)) carrchk();
- if (*text=='\n') {
- *text='\r';
- goto Again1;
- }
- }
- else {
- Again2:
- _DL=*text;
- _AH=2;
- geninterrupt(33);
- if(baud) while (!fossil(TRANSMIT,*text)) carrchk();
- if (*text=='\n') {
- *text='\r';
- goto Again2;
- }
- }
- text++;
- _AH=3;
- _BH=0;
- geninterrupt(16);
- if (_DH>23) checkpos();
- }
- getxbbstime();
- fast=0;
- }
-
-
- void pascal checkpos (void) { /* Protect status line */
-
- _AH=3;
- _BH=0;
- geninterrupt(16);
- if (_DH>23) {
- _AH=6;
- _AL=1;
- _BH=7;
- _CH=0;
- _CL=0;
- _DH=23;
- _DL=79;
- geninterrupt(16);
- _AH=2;
- _BH=0;
- _DL=0;
- _DH=23;
- geninterrupt(16);
- }
- }
-
-
-
-
- void pascal print_stat (void) { /* Print status line */
-
- int x;
- int y;
-
- x=wherex();
- y=wherey();
- gotoxy(1,25);
- textbackground(7);
- textcolor(0);
- cprintf("%-31.31s \04 %31.31s\04 ",PROGRAM_NAME,username);
- gotoxy(x,y);
- }
-
-
-
- char * pascal addtolog (text) /* WRITE LOGFILE ENTRIES */
-
- char *text;
-
- {
-
- FILE *pf;
- char p[127];
-
- pf = fopen(logfile,"a");
- if (pf == NULL) return text;
- fseek(pf,0,SEEK_END);
- if (text[0]!='*') {
- strcpy(p,fidodate());
- p[16]=0;
- strcat(p," ");
- strncat(p,text,126-strlen(p));
- p[126]=0;
- }
- else {
- strncpy(p,text,79);
- p[79]=0;
- }
- fputs(p,pf);
- fputs("\n",pf);
- fclose(pf);
- return text;
-
- }
-
-
-
- #ifdef XBBS
-
- void pascal readconfig (void) /* Read CONFIG.BBS */
-
- {
-
- FILE *fp;
- char s[15];
-
- if (nodenumber!=1) sprintf(s,"config%hu.bbs",nodenumber);
- else strcpy(s,"config.bbs");
-
- if(!(fp=fopen(s,"rb"))) {
- Fatal:
- perror("\nCONFIG ERROR");
- #ifndef DORINFO
- exit(1);
- #endif
- }
- if (fread(&conf,sizeof(conf),1,fp)!=1) goto Fatal;
- fclose(fp);
- strcpy(system_name,conf.system);
- strcpy(sysop,conf.sysop);
- commport=conf.commport;
- strcpy(logfile,conf.logfile);
- sysopin=conf.sysopin;
- fastANSI=conf.fastANSI;
- directvideo=conf.dvideo;
- }
-
-
-
- void pascal getonline (void) { /* Read ONLINE.XBS */
-
- FILE *fp;
- char s[90];
- char numnode[4]="";
-
- if (nodenumber!=1) sprintf(numnode,"%hu",nodenumber);
- sprintf(s,"%sonline%s.xbs",conf.homepath,numnode);
-
- if (!((fp=fopen(s,"rb")))) {
- printf("Can't open %s!\n",s);
- goto FatalError;
- }
- else {
- fread(&user,sizeof(struct _user),1,fp);
- fread(&userno,sizeof(userno),1,fp);
- fread(&timelimit,sizeof(timelimit),1,fp);
- fread(&timeon,sizeof(timeon),1,fp);
- fread(&starter,sizeof(starter),1,fp);
- fread(&baud,sizeof(baud),1,fp);
- fread(&pages,sizeof(pages),1,fp);
- fread(&age,sizeof(age),1,fp);
- fread(&timer_off,sizeof(timer_off),1,fp);
- fread(&hold_time,sizeof(hold_time),1,fp);
- fread(variable,(sizeof(variable[0])*10),1,fp);
- fread(&mboard,sizeof(mboard),1,fp);
- fread(&fboard,sizeof(fboard),1,fp);
- if (fread(event,(sizeof(struct _events)*10),1,fp)<1) {
- printf("Came up short!\n");
- goto FatalError;
- }
- }
- if (ferror(fp)) {
- FatalError:
- perror("ONLINE READ");
- fclose(fp);
- #ifndef DORINFO
- exit(1);
- #endif
- }
- fclose(fp);
- strcpy(username,user.name);
- seclvl=user.stat[0];
- width=user.width;
- numlines=user.length;
- graphics=user.graphics;
- }
-
-
-
- void pascal prepare (void) /* Rewrite ONLINE.XBS */
-
- {
-
- FILE *fp;
- char s[90];
- char numnode[4]="";
-
- if (nodenumber!=1) sprintf(numnode,"%hu",nodenumber);
- sprintf(s,"%sonline%s.xbs",conf.homepath,numnode);
- if(!(fp=fopen(s,"wb"))) perror("ONLINE OPEN");
- else {
- fwrite(&user,sizeof(struct _user),1,fp);
- fwrite(&userno,sizeof(userno),1,fp);
- fwrite(&timelimit,sizeof(timelimit),1,fp);
- fwrite(&timeon,sizeof(timeon),1,fp);
- fwrite(&starter,sizeof(starter),1,fp);
- fwrite(&baud,sizeof(baud),1,fp);
- fwrite(&pages,sizeof(pages),1,fp);
- fwrite(&age,sizeof(age),1,fp);
- fwrite(&timer_off,sizeof(timer_off),1,fp);
- fwrite(&hold_time,sizeof(hold_time),1,fp);
- fwrite(variable,sizeof(variable[0]),10,fp);
- fwrite(&mboard,sizeof(struct _mboard),1,fp);
- fwrite(&fboard,sizeof(struct _fboard),1,fp);
- fwrite(event,sizeof(struct _events),10,fp);
- if (ferror(fp)) perror("ONLINE WRITE");
- fclose(fp);
- }
- }
-
-
-
- void pascal saveconfig (void) /* Rewrite CONFIG.BBS */
-
- {
-
- FILE *fp;
- char s[14];
-
- if (nodenumber!=1) sprintf(s,"config%hu.bbs",nodenumber);
- else strcpy(s,"config.bbs");
-
- if (!(fp=fopen(s,"wb"))) perror("CONFIG OPEN");
- else {
- fwrite(&conf,sizeof(conf),1,fp);
- fclose(fp);
- }
- }
-
- #endif
-
-
-
- void pascal load_msgareas (char *file) {
-
- FILE *fp;
- char *p;
- char *pp;
- struct ffblk f;
- static char string[256];
- word tempareas=0;
-
- if(findfirst(file,&f,0)) return;
- if(!(fp=fopen(file,"rt"))) {
- printfm("\nCan't open %s\n");
- hitreturn();
- return;
- }
- while (!feof(fp)) {
- if (!fgets(string,255,fp)) break;
- if (*string=='\n' || *string==';') continue;
- stripcr(string);
- strncpy(marea[tempareas].name,strtok(string,","),48);
- marea[tempareas].name[47]=0;
- marea[tempareas].attr=(word)atoi(strtok(0," ,"));
- marea[tempareas].max=(word)atoi(strtok(0," ,"));
- marea[tempareas].number=(word)atoi(strtok(0," ,"));
- marea[tempareas].substat1=(word)atoi(strtok(0," ,"));
- marea[tempareas].substat2=(word)atoi(strtok(0," ,"));
- if(marea[tempareas].substat1>user.stat[0]) continue;
- pp=strtok(0,"\n");
- p=NULL;
- if(pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(p!=NULL)strncpy(marea[tempareas].forceto,p,36);
- else *marea[tempareas].forceto=0;
- marea[tempareas].forceto[35]=0;
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(!p) strcpy(marea[tempareas].descr,"No Description");
- else strncpy(marea[tempareas].descr,p,79);
- marea[tempareas].descr[78]=0;
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(!p) marea[tempareas].age=0;
- else marea[tempareas].age=(signed char)atoi(p);
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(!p)marea[tempareas].flags=0;
- else marea[tempareas].flags=(word)atol(p);
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(!p) marea[tempareas].zone=marea[tempareas].net=marea[tempareas].node=marea[tempareas].point=0;
- else {
- p=strtok(p,":");
- marea[tempareas].zone=(word)atol(p);
- p=strtok(0,"/");
- marea[tempareas].net=(word)atol(p);
- p=strtok(0,".");
- marea[tempareas].node=(word)atol(p);
- p=strtok(0,"@");
- marea[tempareas].point=(word)atol(p);
- }
- p=NULL;
- if(pp && *pp) {
- if(*pp!=',') {
- p=strtok(pp,",");
- pp=strtok(0,"\n");
- }
- else pp++;
- }
- if(!p) *marea[tempareas].yourname=0;
- else {
- strncpy(marea[tempareas].yourname,p,36);
- marea[tempareas].yourname[35]=0;
- }
- p=NULL;
- if(*pp && pp) {
- if(*pp!=',' && *pp!=0) p=strtok(pp,"\n");
- else if(*pp)p=++pp;
- }
- if(!p) marea[tempareas].minwrite=0;
- else marea[tempareas].minwrite=(word)atol(p);
-
- if (marea[tempareas].number>higharea) higharea=marea[tempareas].number;
- tempareas++;
- }
- maxareas=tempareas;
- fclose(fp);
- }
-
-
-
- void pascal display_current (char enable,int lorange,int hirange) {
-
- int register x,y;
- int register lines=2;
- char gotone=0;
-
- if(enable==1) printm("\n\nCurrently enabled areas:\n\n");
- else if (enable==2) printm("\n\nCurrently disabled areas:\n\n");
- else printm("\n\nAll available areas:\n\n");
- for(x=0;x<maxareas;x++) {
- if(marea[x].substat1>user.stat[0]) continue;
- if(marea[x].number<lorange) continue;
- if(marea[x].number>hirange) continue;
- if(marea[x].age) {
- if(marea[x].age>0) {
- if(age<(char)marea[x].age) {
- continue;
- }
- }
- else {
- if(age>(char)abs(marea[x].age)) {
- continue;
- }
- }
- }
- if(marea[x].flags) {
- for(y=0;y<16;y++) {
- if(marea[x].flags & (1<<y)) {
- if(!(user.attr2 & (1<<y))) {
- continue;
- }
- }
- }
- }
- if(enable==1) {
- if(do_bits((int)marea[x].number-1,0)!=0) {
- lines++;
- printfm("%5u. %s -- %s\n",marea[x].number,marea[x].name,marea[x].descr);
- }
- }
- else if (enable==2) {
- if(do_bits((int)marea[x].number-1,0)==0) {
- lines++;
- printfm("%5u. %s -- %s\n",marea[x].number,marea[x].name,marea[x].descr);
- }
- }
- else {
- lines++;
- printfm("%5u. %s -- %s\n",marea[x].number,marea[x].name,marea[x].descr);
- }
- if(lines)gotone=1;
- if(lines>(int)(user.length-2)) {
- printm("More? (Y/n) ");
- if(*genin(1,0,1,1,YESNOM)=='N') {
- printm("\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b\n");
- return;
- }
- printm("\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b");
- lines=0;
- }
- }
- if(!gotone) printm("None found.\n");
- if(lines>(int)(user.length-9)) hitreturn();
- }
-
-
- word pascal load_user (void) {
-
- FILE *fp;
- int x=0;
- struct _msetup temp;
-
- fp=fopen(searchpath("msetup.usr"),"rb");
- if(!fp) return 0; /* Assume new file */
- while(!feof(fp)) {
- if(fread(&temp,sizeof(struct _msetup),1,fp)!=1) break;
- if(temp.userid==mset.userid && temp.node==mset.node) {
- memcpy(&mset,&temp,sizeof(struct _msetup));
- break;
- }
- x++;
- }
- fclose(fp);
- return x;
- }
-
-
- void pascal save_user (word numuser) {
-
- FILE *fp;
-
- fp=fopen(searchpath("msetup.usr"),"r+b");
- if(!fp) fp=fopen("msetup.usr","wb");
- if(!fp) {
- printm("\nCouldn't create MSETUP.USR!\n");
- return;
- }
- fseek(fp,(long)numuser*(long)sizeof(struct _msetup),SEEK_SET);
- fwrite(&mset,sizeof(struct _msetup),1,fp);
- fclose(fp);
- }
-
-
- int pascal edit_areas (void) {
-
- int register x;
- char command[7];
- int bitnum;
- char hitemp[7]="4096";
- char lotemp[7]="1";
- char hi[7];
- char lo[7];
- char temp[50];
-
- while(1) {
- printm("\n"
- "Enter # of area to toggle, or:\n"
- "Turn [A]ll areas on Turn All areas [O]ff\n"
- "[L]ist all areas List areas o[N]\n"
- "List areas o[F]f [R]ange list\n"
- "[Q]uit (finished) [H]elp\n"
- " -> ");
- strcpy(command,genin(5,0,1,1,ALPHANUM));
- lstrip(command);
- rstrip(command);
- switch ((int)*command) {
- case 0: break;
- case 'A': for(x=0;x<512;x++) mset.areas[x]=255;
- break;
- case 'O': for(x=0;x<512;x++) mset.areas[x]=0;
- break;
- case 'L': display_current(0,1,4095);
- break;
- case 'N': display_current(1,1,4095);
- break;
- case 'F': display_current(2,1,4095);
- break;
- case 'R': printfm("\nStart at #[%s]: ",lotemp);
- strcpy(lo,genin(5,0,1,1,NUM));
- lstrip(lo);
- rstrip(lo);
- if(atoi(lo)<1 || atoi(lo)>4096 || !*lo) {
- if(*lo) printm("\nInvalid; adjusted to ");
- strcpy(lo,lotemp);
- printm(lo);
- }
- strcpy(lotemp,lo);
- printfm("\nEnd at # [%s]: ",hitemp);
- strcpy(hi,genin(5,0,1,1,NUM));
- lstrip(hi);
- rstrip(hi);
- if(atoi(hi)<atoi(lo) || atoi(hi)>4096 || !*hi) {
- if(*hi) printm("\nInvalid; adjusted to ");
- strcpy(hi,hitemp);
- printm(hi);
- }
- strcpy(hitemp,hi);
- printm("\nList [A]ll, O[N] or O[F]f? [A] ");
- *command=*genin(1,0,1,1,ALPHA);
- if(*command=='N') display_current(1,atoi(lo),atoi(hi));
- else if (*command=='F') display_current(2,atoi(lo),atoi(hi));
- else display_current(0,atoi(lo),atoi(hi));
- break;
- case 'Q': printm("\nSave new settings? (Y/n) ");
- if(*genin(1,0,1,1,YESNO)=='N') return 0;
- else return 1;
- case 'H': readtext(searchpath("MSETUP.HLP"),1);
- break;
- default: bitnum=atoi(command);
- if(bitnum<1 || bitnum>4096) {
- printm("\07");
- break;
- }
- strcpy(temp,"Unknown area");
- for(x=0;x<maxareas;x++) {
- if(marea[x].number==(word)bitnum) {
- strcpy(temp,marea[x].name);
- break;
- }
- }
- if(do_bits(bitnum-1,3)) printfm("\n\n#%d (%s) toggled on.\n",bitnum,temp);
- else printfm("\n\n#%d (%s) toggled off.\n",bitnum,temp);
- break;
- }
- }
- }
-
-
- int pascal do_bits (int x,char what) {
-
- int y;
- char z;
-
- if(x<0 || x>4095) {
- printm("\nInvalid bit #...ignored.\n");
- return -1;
- }
-
- y=x/8;
- z=x-(y*8);
-
- /* printf("\n%d %d %d %d %d",x,y,z,(1<<z),mset.areas[y]); */
-
- if (what==1) { /* Set */
- mset.areas[y]=mset.areas[y] | (char)(1<<z);
- }
- else if (what==2) { /* ReSet */
- mset.areas[y]=mset.areas[y] & (char)(~(1<<z));
- }
- else if (what==3) { /* Toggle */
- if((mset.areas[y] & (char)(1<<z))==0) mset.areas[y]=mset.areas[y] | (char)(1<<z);
- else mset.areas[y]=mset.areas[y] & (char)(~(1<<z));
- }
- return((mset.areas[y] & (char)(1<<z))!=0); /* Test */
- }