home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / BBS / XSRC_117.ZIP / LOGON.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-27  |  5.1 KB  |  215 lines

  1. /*======================================================================*/
  2. /*  XBBS Bulletin Board System.....MAIN module                          */
  3. /*  Copyright (c) 1989 by M. Kimes -- All Rights Reserved               */
  4. /*======================================================================*/
  5.  
  6. #include "msg.h"
  7. #include "xglob.h"
  8.  
  9. /* Function prototypes */
  10.  
  11. void   pascal login (void);
  12. void   pascal phonecan (char *);
  13. void   pascal xmain (void);
  14. void   pascal xijit (void);
  15.  
  16. /* Global variables */
  17.  
  18. word           timetoevent;
  19.  
  20.  
  21. void cdecl main (int argc,char *argv[]) {
  22.  
  23.   register int x;
  24.   struct date dos_date;
  25.  
  26.   setcbrk(0);
  27.   strset(keyqueue,0);
  28.   keyptr=0;
  29.   conf.trace=0;
  30.   for(x=0;x<MAXALLOCHANDLES;x++) allochandles[x]=NULL;
  31.   for(x=0;x<MAXFPHANDLES;x++) fphandles[x]=-1;
  32.  
  33.   userno=0;
  34.   *filetoread=0;
  35.   ctrlbrk(break_handler);
  36.   randomize();
  37.   atexit(deinitialize);
  38.   fputs("\x1b[2J\x1b[0;2;37m",stdout);
  39.   memset(&oldmsg,0,sizeof(struct _xmsg));
  40.  
  41.   *filetoread=0;
  42.  
  43.   r.x.ax=0x4400;        /* Set console in raw mode */
  44.   r.x.bx=1;
  45.   int86(33,&r,&r);
  46.   r.h.dh=0;
  47.   r.h.dl=r.h.dl|0x20;
  48.   r.x.ax=0x4401;
  49.   int86(33,&r,&r);
  50.  
  51.   timelimit=2;
  52.  
  53.     if (argc>1 && !strnicmp(argv[1],"-R",2)) {
  54.       strcpy(startfile,"START.XBS");
  55.       for (x=1;x<argc;x++) {
  56.         if (*argv[x]!='-') continue;
  57.         switch ((int)toupper(argv[x][1])) {
  58.             case 'R':   if (strlen(argv[x])==2) strcpy(startfile,"MAIN.XBS");
  59.                         else strcpy(startfile,&argv[x][2]);
  60.                         break;
  61.             case 'N':   nodenumber=(char)atoi(&argv[x][2]);
  62.                         break;
  63.         }
  64.       }
  65.       readconfig();
  66.       strcpy(messpath,conf.messpath);
  67.       lastread=(word far *)farmalloc(conf.nolmrs * sizeof(word));
  68.       if(lastread==NULL) {
  69.         gprintf(LOGONLY | LOCALONLY,"\nOut of memory for LMRs!\n");
  70.         exit(254);
  71.       }
  72.       getonline();
  73.       fossil (INIT,0);
  74.       getxbbstime();
  75.       xmain();
  76.       exit(255);
  77.     }
  78.  
  79.   for (x=0;x<10;x++) *variable[x]=0;
  80.  
  81. /* Defaults */
  82.  
  83. timetoevent = 24 * 59;
  84.  
  85. /* Get command line arguments */
  86.  
  87.   if (argc >1) baud=(word)atol(argv[1]);
  88.   if (argc >2) timetoevent=(word)atol(argv[2]);
  89.   if (argc >3) nodenumber=(char)atoi(argv[3]);
  90.   if (argc>4) {
  91.         for (x=0;x<(argc-4);x++) {
  92.             strncpy(variable[x],argv[x+4],81);
  93.             argv[x+4][80]=0;
  94.         }
  95.   }
  96.  
  97.   login();      /* Do new user login */
  98.        getdate(&dos_date);
  99.        age=((dos_date.da_year-user.birthdate.da_year)-1);
  100.        if (dos_date.da_mon>user.birthdate.da_mon) age++;
  101.        else if ((dos_date.da_mon==user.birthdate.da_mon) && (dos_date.da_day>=user.birthdate.da_day)) age++;
  102.        if ((dos_date.da_mon==user.birthdate.da_mon) && (dos_date.da_day==user.birthdate.da_day)) readfile("happy.xbs",0,0,1);
  103.        getdate(&user.logondate);
  104.        gettime(&user.logontime);
  105.        userinfo(baud,0);
  106.        readfile("welcome.xbs",0,0,1);
  107.        fossil(FLUSHOUT,0);
  108.        strcpy(startfile,"START.XBS");
  109.   xmain();      /* To BBS 'proper' */
  110. }
  111.  
  112.  
  113.  
  114. void pascal xmain (void) {
  115.  
  116.   register word x;
  117.   char filename[103];
  118.   struct ffblk f;
  119.  
  120.   pauser=0;
  121.  
  122.   x=setjmp(envbuf);
  123.   slowprint=0;
  124.   safe=0;
  125.   disablesub=0;
  126.   disablejump=0;
  127.   helpnum=0;
  128.   *msginfo=0;
  129.   switch ((int)x) {
  130.         case 0:        break;
  131.         case 98:
  132.         case 99:    goto FreeEm;
  133.         case 1:
  134.         case 2:
  135.         case 3:
  136.         case 4:
  137.         case 5:
  138.         case 6:
  139.         case 7:
  140.         case 8:
  141.         case 9:
  142.         case 10:    strcpy(startfile,conf.jumpfile[x-1]);
  143. FreeEm:
  144.                     ccloseall();
  145.                     ffreeall();
  146.         default:    break;
  147.   }
  148.   safe=1;
  149.   inwindow=0;
  150.   while (1) {
  151.  
  152. checkfile:
  153.  
  154.    inkey();
  155.    if(x==98) {
  156.         goto DoMijit2;
  157.    }
  158.    sprintf(filename,"%s%s",conf.menupath,startfile);
  159.    if (findfirst(filename,&f,0)) {
  160.      if (!stricmp(startfile,"MAIN.XBS")) {
  161.         sprintf(menufile,"%sMAIN.MNU",conf.menupath);
  162. DoMijit2:
  163.         if(!findfirst(menufile,&f,0)) {
  164. DoMijit:
  165.             gprintf(LOCALONLY,"\n\04Mijit-mode\n");
  166.             xmenu(menufile);
  167.             exit(253);
  168.         }
  169.         else {
  170.             sprintf(menufile,"MAIN.MNU",conf.menupath);
  171.             if(!findfirst(menufile,&f,0)) goto DoMijit;
  172.         }
  173.         say_prompt(208);
  174.         xijit();
  175.         fossil(FLUSHOUT,0);
  176.         fossil(DTR,DOWN);
  177.         exit(253);
  178.      }
  179.      else strcpy(startfile,"MAIN.XBS");
  180.      goto checkfile;
  181.    }
  182.    readfile(startfile,1,1,1);
  183.    if (!strcmp(startfile,"START.XBS")) strcpy(startfile,"MAIN.XBS");
  184.   }
  185. }
  186.  
  187.  
  188.  
  189. void pascal user_func (char *b) {   /* This function for easy user expansion.
  190.                                        Called by ^a_ (CTRL-A&Underline)
  191.                                        Additional args, if any, will be in b */
  192.  
  193.     /* Here's an example of something you could do here...
  194.  
  195.     mprint(b);
  196.     return;
  197.  
  198.     That would print the line after a ^a_ to the modem only.
  199.     You could hook in other libraries (like a database library)
  200.     hook in your own functions (you can do something like:
  201.  
  202.         char a;
  203.  
  204.         a=*b;
  205.         b++;
  206.         switch((int)a {
  207.             case 'A':   do_something();
  208.             case 'B':   do_something_else();
  209.         }
  210.  
  211.     and so forth.  Use your imagination. */
  212. }
  213.  
  214. /* End of file: LOGON.C */
  215.