home *** CD-ROM | disk | FTP | other *** search
- /*======================================================================*/
- /* XBBS Bulletin Board System.....MAIN module */
- /* Copyright (c) 1989 by M. Kimes -- All Rights Reserved */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xglob.h"
-
- /* Function prototypes */
-
- void pascal login (void);
- void pascal phonecan (char *);
- void pascal xmain (void);
- void pascal xijit (void);
-
- /* Global variables */
-
- word timetoevent;
-
-
- void cdecl main (int argc,char *argv[]) {
-
- register int x;
- struct date dos_date;
-
- setcbrk(0);
- strset(keyqueue,0);
- keyptr=0;
- conf.trace=0;
- for(x=0;x<MAXALLOCHANDLES;x++) allochandles[x]=NULL;
- for(x=0;x<MAXFPHANDLES;x++) fphandles[x]=-1;
-
- userno=0;
- *filetoread=0;
- ctrlbrk(break_handler);
- randomize();
- atexit(deinitialize);
- fputs("\x1b[2J\x1b[0;2;37m",stdout);
- memset(&oldmsg,0,sizeof(struct _xmsg));
-
- *filetoread=0;
-
- 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);
-
- timelimit=2;
-
- if (argc>1 && !strnicmp(argv[1],"-R",2)) {
- strcpy(startfile,"START.XBS");
- for (x=1;x<argc;x++) {
- if (*argv[x]!='-') continue;
- switch ((int)toupper(argv[x][1])) {
- case 'R': if (strlen(argv[x])==2) strcpy(startfile,"MAIN.XBS");
- else strcpy(startfile,&argv[x][2]);
- break;
- case 'N': nodenumber=(char)atoi(&argv[x][2]);
- break;
- }
- }
- readconfig();
- strcpy(messpath,conf.messpath);
- lastread=(word far *)farmalloc(conf.nolmrs * sizeof(word));
- if(lastread==NULL) {
- gprintf(LOGONLY | LOCALONLY,"\nOut of memory for LMRs!\n");
- exit(254);
- }
- getonline();
- fossil (INIT,0);
- getxbbstime();
- xmain();
- exit(255);
- }
-
- for (x=0;x<10;x++) *variable[x]=0;
-
- /* Defaults */
-
- timetoevent = 24 * 59;
-
- /* Get command line arguments */
-
- if (argc >1) baud=(word)atol(argv[1]);
- if (argc >2) timetoevent=(word)atol(argv[2]);
- if (argc >3) nodenumber=(char)atoi(argv[3]);
- if (argc>4) {
- for (x=0;x<(argc-4);x++) {
- strncpy(variable[x],argv[x+4],81);
- argv[x+4][80]=0;
- }
- }
-
- login(); /* Do new user login */
- getdate(&dos_date);
- age=((dos_date.da_year-user.birthdate.da_year)-1);
- if (dos_date.da_mon>user.birthdate.da_mon) age++;
- else if ((dos_date.da_mon==user.birthdate.da_mon) && (dos_date.da_day>=user.birthdate.da_day)) age++;
- if ((dos_date.da_mon==user.birthdate.da_mon) && (dos_date.da_day==user.birthdate.da_day)) readfile("happy.xbs",0,0,1);
- getdate(&user.logondate);
- gettime(&user.logontime);
- userinfo(baud,0);
- readfile("welcome.xbs",0,0,1);
- fossil(FLUSHOUT,0);
- strcpy(startfile,"START.XBS");
- xmain(); /* To BBS 'proper' */
- }
-
-
-
- void pascal xmain (void) {
-
- register word x;
- char filename[103];
- struct ffblk f;
-
- pauser=0;
-
- x=setjmp(envbuf);
- slowprint=0;
- safe=0;
- disablesub=0;
- disablejump=0;
- helpnum=0;
- *msginfo=0;
- switch ((int)x) {
- case 0: break;
- case 98:
- case 99: goto FreeEm;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10: strcpy(startfile,conf.jumpfile[x-1]);
- FreeEm:
- ccloseall();
- ffreeall();
- default: break;
- }
- safe=1;
- inwindow=0;
- while (1) {
-
- checkfile:
-
- inkey();
- if(x==98) {
- goto DoMijit2;
- }
- sprintf(filename,"%s%s",conf.menupath,startfile);
- if (findfirst(filename,&f,0)) {
- if (!stricmp(startfile,"MAIN.XBS")) {
- sprintf(menufile,"%sMAIN.MNU",conf.menupath);
- DoMijit2:
- if(!findfirst(menufile,&f,0)) {
- DoMijit:
- gprintf(LOCALONLY,"\n\04Mijit-mode\n");
- xmenu(menufile);
- exit(253);
- }
- else {
- sprintf(menufile,"MAIN.MNU",conf.menupath);
- if(!findfirst(menufile,&f,0)) goto DoMijit;
- }
- say_prompt(208);
- xijit();
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- exit(253);
- }
- else strcpy(startfile,"MAIN.XBS");
- goto checkfile;
- }
- readfile(startfile,1,1,1);
- if (!strcmp(startfile,"START.XBS")) strcpy(startfile,"MAIN.XBS");
- }
- }
-
-
-
- void pascal user_func (char *b) { /* This function for easy user expansion.
- Called by ^a_ (CTRL-A&Underline)
- Additional args, if any, will be in b */
-
- /* Here's an example of something you could do here...
-
- mprint(b);
- return;
-
- That would print the line after a ^a_ to the modem only.
- You could hook in other libraries (like a database library)
- hook in your own functions (you can do something like:
-
- char a;
-
- a=*b;
- b++;
- switch((int)a {
- case 'A': do_something();
- case 'B': do_something_else();
- }
-
- and so forth. Use your imagination. */
- }
-
- /* End of file: LOGON.C */
-