home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / bbbsr2.zip / scripts / opendoor.bz < prev    next >
Text File  |  1997-06-26  |  3KB  |  119 lines

  1. /*
  2.  * Run by the OPen command in main menu. Remember to recompile!
  3.  */
  4.  
  5. #include <stdlib.bzh>
  6.  
  7. int logdoor(int door) {
  8.   int f;
  9.  
  10.   if ((f=fopen(bl_logfile,"at"))!=-1) {
  11.     fprintf(f,"%02u:%02u Opened door %u\n",bf_hour,bf_min,door);
  12.     fclose(f);
  13.   }
  14. }
  15.  
  16. int make_dorinfo1def(char fn) {
  17.   char nam1, nam2, sys1, sys2;
  18.   int f, security, foo;
  19.  
  20.   if ((f=fopen(fn,"wt"))==-1) {
  21.     printf("No way, %s, man!",fn);
  22.     return(1);
  23.   }
  24.   if (bv_unum==0) security=32000;
  25.   else security=1;
  26.   nam1=copy(bu_name,1,pos(" ",bu_name)-1);
  27.   nam2=copy(bu_name,pos(" ",bu_name)+1,30);
  28.   sys1=copy(bg_sysop_name,1,pos(" ",bg_sysop_name)-1);
  29.   sys2=copy(bg_sysop_name,pos(" ",bg_sysop_name)+1,30);
  30.   if (!bv_com) foo=0;
  31.   else foo=bv_baud;
  32. //             1   2   3      4   5              6  7   8   9  10  11  12
  33.   fprintf(f,"%s\n%s\n%s\nCOM%u\n%u BAUD,N,8,1\n%u\n%s\n%s\n%s\n%u\n%u\n%d\n",
  34.       bg_bbbs_name,                  // 1    - BBS name
  35.       sys1,                          // 2    - SysOp first name
  36.       sys2,                          // 3    - SysOp last name
  37.       bv_com,                        // 4    - COM port
  38.       foo,                           // 5    - Baud rate
  39.       foo,                           // 6    - Baud, again
  40.       nam1,                          // 7    - User first name
  41.       nam2,                          // 8    - User last name
  42.       bu_city,                       // 9    - User location
  43.       (bu_termcap & 15)>0,           // 10   - ANSI (1/0)
  44.       security,                      // 11   - user security
  45.       bf_timleft);                   // 12   - Time left
  46.   fclose(f);
  47.   return(0);
  48. }
  49.  
  50. int make_doorsys(char fn) {
  51.   int f;
  52.  
  53.   if ((f=fopen(fn,"wt"))!=-1) {
  54.     fprintf(f,"%s\n%u\n%u\n%d\nG\nA\n",bu_name,bv_com,
  55.       bv_realbaud,bf_timleft);
  56.     fclose(f);
  57.   }
  58. }
  59.  
  60. int main() {
  61.   char b;
  62.   int z, n;
  63.  
  64.   if ((n=bn_zstatus)==1) bn_zstatus=8;
  65.   if (bv_comstring=="") showfile(strcat(bg_menudir,"doormenu"));
  66.   do {
  67.     switch (z=parsecom("Quit/?/1/2/3/4/5",b=input("Number of door to open: ",60,1))) {
  68.        case 2:{
  69.                 showfile(strcat(bg_menudir,"doormenu"));
  70.                 break;
  71.               }
  72.        case 3:{
  73.                 if (yellsysop(0)) {
  74.                   logdoor(1);
  75.                   tictactoe(1,0);
  76.                 }
  77.                 break;
  78.               }
  79.        case 4:{
  80.                 if (yellsysop(0)) {
  81.                   tictactoe(2,1);
  82.                   logdoor(2);
  83.                 }
  84.                 break;
  85.               }
  86.        case 5:{
  87.                 if (yellsysop(0)) {
  88.                   tictactoe(2,2);
  89.                   logdoor(3);
  90.                 }
  91.                 break;
  92.               }
  93.        case 6:{
  94.                 if (yellsysop(0)) {
  95.                   logdoor(4);
  96.                   make_dorinfo1def(sprintf("dorinfo%u.def",bv_nodenumber));
  97.                   make_doorsys(sprintf("door%u.sys",bv_nodenumber));
  98.                   make_pcboard12sys(sprintf("pcb%u.s12",bv_nodenumber));
  99.                   make_pcboard14sys(sprintf("pcb%u.s14",bv_nodenumber));
  100.                   system("lw2 s3 duel",1);
  101.                 }
  102.                 break;
  103.               }
  104.        case 7:{
  105.                 logdoor(5);
  106.                 spawn("mastermind");
  107.                 break;
  108.               }
  109.      case 255:{
  110.                 printf(bv_txt[23],b);
  111.                 bv_comstring="";
  112.                 break;
  113.               }
  114.     }
  115.   } while (bv_carrier && (z==2 || z==255));
  116.   bn_zstatus=n;
  117. }
  118.  
  119.