home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / WWIV420S.ZIP / DEFAULTS.C < prev    next >
C/C++ Source or Header  |  1991-04-06  |  16KB  |  725 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1991 by Wayne Bell
  5.  
  6. Distribution of the source code for WWIV, in any form, modified or unmodified,
  7. without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
  8. Distribution of compiled versions of WWIV is limited to copies compiled BY
  9. THE AUTHOR.  Distribution of any copies of WWIV not compiled by the author
  10. is expressly prohibited.
  11.  
  12.  
  13. *****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "vars.h"
  18.  
  19. #pragma hdrstop
  20.  
  21.  
  22. void select_editor()
  23. {
  24.   char s[81],s1[81],*ss;
  25.   int i;
  26.  
  27.   helpl=37;
  28.   if (numed==0) {
  29.     nl();
  30.     pl("No full screen editors available.");
  31.     nl();
  32.     return;
  33.   }
  34.   for (i=0; i<5; i++)
  35.     odc[i]=0;
  36.   pl("0. Normal non-full screen editor");
  37.   for (i=0; i<numed; i++) {
  38.     npr("%d. %s\r\n",i+1,editors[i].description);
  39.     if (((i+1) %10)==0)
  40.       odc[(i+1)/10-1]=(i+1)/10;
  41.   }
  42.   nl();
  43.   ansic(2);
  44.   npr("Which editor (1-%d, <C/R>=leave as is) ? ",numed);
  45.   ss=mmkey(2);
  46.   i=atoi(ss);
  47.   if ((i>=1) && (i<=numed))
  48.     thisuser.defed=i;
  49.   else
  50.     if (strcmp(ss,"0")==0)
  51.       thisuser.defed=0;
  52. }
  53.  
  54.  
  55. void print_cur_stat()
  56. {
  57.   char s[81],s1[81],s2[81];
  58.   userrec ur;
  59.  
  60.   outchr(12);
  61.  
  62.   npr("1. Screen size       : %d X %d\r\n",
  63.         thisuser.screenchars,
  64.         thisuser.screenlines);
  65.   npr("2. ANSI              : %s\r\n",
  66.      (thisuser.sysstatus & sysstatus_ansi)?
  67.        ((thisuser.sysstatus & sysstatus_color)? "Color":"Monochrome"):
  68.      "No ANSI");
  69.   npr("3. Pause on screen   : %s\r\n",
  70.      (thisuser.sysstatus & sysstatus_pause_on_page)?"On":"Off");
  71.   outstr("4. Mailbox           : ");
  72.   if ((thisuser.forwardsys==0) && (thisuser.forwardusr==0))
  73.     pl("Normal");
  74.   else {
  75.     if (thisuser.forwardsys) {
  76.       sprintf(s,"Forward to #%u @%u.",thisuser.forwardusr,thisuser.forwardsys);
  77.       pl(s);
  78.     } else {
  79.       read_user(thisuser.forwardusr,&ur);
  80.       if (ur.inact & inact_deleted) {
  81.         thisuser.forwardusr=0;
  82.         pl("Normal");
  83.       } else {
  84.         sprintf(s,"Forward to %s",nam(&ur,thisuser.forwardusr));
  85.         pl(s);
  86.       }
  87.     }
  88.   }
  89.   pl("5. Configured Q-scan");
  90.   pl("6. Change password");
  91.   pl("7. Update macros");
  92.   if (okansi()) {
  93.     pl("8. Change colors");
  94.     npr("9. Full screen editor: %s\r\n",
  95.       ((thisuser.defed) && (thisuser.defed<=numed))?
  96.         editors[thisuser.defed-1].description:"None.");
  97.     npr("A. Extended colors   : %s\r\n",
  98.       (thisuser.sysstatus & sysstatus_funky_colors)?"Yes":"No");
  99.   }
  100.   npr("B. Optional lines    : %d\r\n",thisuser.optional_val);
  101.   if (thisuser.wwiv_regnum)
  102.     npr("W. WWIV reg num      : %ld\r\n",thisuser.wwiv_regnum);
  103.   else
  104.     pl("W. WWIV reg num      : <NONE>");
  105.   pl("Q. Quit to main menu");
  106.   nl();
  107.   nl();
  108. }
  109.  
  110.  
  111. char *cn(char c)
  112. {
  113.   static char s[20];
  114.  
  115.   if ((checkcomp("Ami")) || (checkcomp("Mac"))) {
  116.     sprintf(s,"Color #%d",c);
  117.     return(s);
  118.   }
  119.  
  120.   switch(c) {
  121.     case 0:
  122.       return("Black");
  123.     case 1:
  124.       return("Blue");
  125.     case 2:
  126.       return("Green");
  127.     case 3:
  128.       return("Cyan");
  129.     case 4:
  130.       return("Red");
  131.     case 5:
  132.       return("Magenta");
  133.     case 6:
  134.       return("Yellow");
  135.     case 7:
  136.       return("White");
  137.   }
  138.   return("");
  139. }
  140.  
  141. char *describe(char col)
  142. {
  143.   static char s[81];
  144.   char s1[81];
  145.  
  146.  
  147.   if (thisuser.sysstatus & sysstatus_color) {
  148.     strcpy(s1,cn(col&0x07));
  149.     sprintf(s,"%s on %s", s1, cn((col>>4)&0x07));
  150.   } else {
  151.     if ((col & 0x07) == 0)
  152.       strcpy(s,"Inversed");
  153.     else
  154.       strcpy(s,"Normal");
  155.   }
  156.   if (col & 0x08) {
  157.     if ((checkcomp("Ami")) || (checkcomp("Mac")))
  158.       strcat(s,", Bold");
  159.     else
  160.       strcat(s,", Intense");
  161.   }
  162.   if (col & 0x80) {
  163.     if (checkcomp("Ami"))
  164.       strcat(s,", Italicized");
  165.     else
  166.       if (checkcomp("Mac"))
  167.         strcat(s,", Underlined");
  168.       else
  169.         strcat(s,", Blinking");
  170.   }
  171.   return(s);
  172. }
  173.  
  174. void color_list()
  175. {
  176.   int i;
  177.  
  178.   nl();
  179.   nl();
  180.   for (i=0; i<8; i++) {
  181.     if (i==0)
  182.       setc(0x70);
  183.     else
  184.       setc(i);
  185.     npr("%d. %s",i,cn(i));
  186.     setc(0x07);
  187.     nl();
  188.   }
  189. }
  190.  
  191.  
  192.  
  193. void change_colors()
  194. {
  195.   int i,done,i1,i2;
  196.   char s[81],ch,nc;
  197.  
  198.   done=0;
  199.   helpl=36;
  200.   nl();
  201.   do {
  202.     if ((thisuser.sysstatus & sysstatus_color)==0) {
  203.       strcpy(s,"Monochrome base color : ");
  204.       if ((thisuser.bwcolors[1] & 0x70) == 0)
  205.         strcat(s,cn(thisuser.bwcolors[1] & 0x07));
  206.       else
  207.         strcat(s,cn((thisuser.bwcolors[1] >> 4) & 0x07));
  208.       pl(s);
  209.       nl();
  210.     }
  211.     for (i=0; i<8; i++) {
  212.       ansic(i);
  213.       itoa(i,s,10);
  214.       strcat(s,". ");
  215.       switch(i) {
  216.         case 0:
  217.           strcat(s,"Default           ");
  218.           break;
  219.         case 1:
  220.           strcat(s,"Yes/No            ");
  221.           break;
  222.         case 2:
  223.           strcat(s,"Prompt            ");
  224.           break;
  225.         case 3:
  226.           strcat(s,"Note              ");
  227.           break;
  228.         case 4:
  229.           strcat(s,"Input line        ");
  230.           break;
  231.         case 5:
  232.           strcat(s,"Yes/No Question   ");
  233.           break;
  234.         case 6:
  235.           strcat(s,"Notice!           ");
  236.           break;
  237.         case 7:
  238.           strcat(s,"Border            ");
  239.           break;
  240.       }
  241.       if (thisuser.sysstatus & sysstatus_color)
  242.         strcat(s,describe(thisuser.colors[i]));
  243.       else
  244.         strcat(s,describe(thisuser.bwcolors[i]));
  245.       pl(s);
  246.     }
  247.     nl();
  248.     prt(2,"Change which (0-7, Q=Quit) ? ");
  249.     ch=onek("Q01234567");
  250.     if (ch=='Q')
  251.       done=1;
  252.     else {
  253.       i1=ch-'0';
  254.       if (thisuser.sysstatus & sysstatus_color)  {
  255.         color_list();
  256.         ansic(0);
  257.         nl();
  258.         prt(2,"Foreground? ");
  259.         ch=onek("01234567");
  260.         nc=ch-'0';
  261.         prt(2,"Background? ");
  262.         ch=onek("01234567");
  263.         nc=nc | ((ch-'0') << 4);
  264.       } else {
  265.          nl();
  266.          prt(5,"Inversed? ");
  267.            if (yn()) {
  268.              if ((thisuser.bwcolors[1] & 0x70) == 0)
  269.                nc=0 | ((thisuser.bwcolors[1] & 0x07) << 4);
  270.              else
  271.                nc=(thisuser.bwcolors[1] & 0x70);
  272.            } else {
  273.              if ((thisuser.bwcolors[1] & 0x70) == 0)
  274.                nc=0 | (thisuser.bwcolors[1] & 0x07);
  275.              else
  276.                nc=((thisuser.bwcolors[1] & 0x70) >> 4);
  277.            }
  278.       }
  279.       if ((checkcomp("Ami")) || (checkcomp("Mac")))
  280.         prt(5,"Bold? ");
  281.       else
  282.         prt(5,"Intensified? ");
  283.       if (yn())
  284.         nc |= 0x08;
  285.  
  286.       if (checkcomp("Ami"))
  287.         prt(5,"Italicized? ");
  288.       else
  289.         if (checkcomp("Mac"))
  290.           prt(5,"Underlined? ");
  291.         else
  292.           prt(5,"Blinking? ");
  293.       if (yn())
  294.         nc |= 0x80;
  295.  
  296.       nl();
  297.       nl();
  298.       setc(nc);
  299.       outstr(describe(nc));
  300.       ansic(0);
  301.       nl();
  302.       nl();
  303.       prt(5,"Is this OK? ");
  304.       if (yn()) {
  305.         nl();
  306.         pl("Color saved.");
  307.         nl();
  308.         if (thisuser.sysstatus & sysstatus_color)
  309.           thisuser.colors[i1]=nc;
  310.         else
  311.           thisuser.bwcolors[i1]=nc;
  312.       } else {
  313.         nl();
  314.         pl("Not saved, then.");
  315.         nl();
  316.       }
  317.     }
  318.   } while ((!done) && (!hangup));
  319. }
  320.  
  321.  
  322.  
  323. void l_config_qscan()
  324. {
  325.   int i,abort;
  326.   char s[81];
  327.  
  328.   abort=0;
  329.   nl();
  330.   pl("Boards to q-scan marked with '*'");
  331.   nl();
  332.   for (i=0; (i<MAX_SUBS) && (usub[i].subnum!=-1) && (!abort); i++) {
  333.     sprintf(s,"%c %s. %s",
  334. #if MAX_SUBS>32
  335.       (i>=32)?
  336.          (((1L << (usub[i].subnum-32)) & thisuser.qscn2)?'*':' '):
  337.          (((1L << (usub[i].subnum)) & thisuser.qscn)?'*':' '),
  338. #else
  339.       ((1L << (usub[i].subnum)) & thisuser.qscn)?'*':' ',
  340. #endif
  341.       usub[i].keys,
  342.       subboards[usub[i].subnum].name);
  343.     pla(s,&abort);
  344.   }
  345.   nl();
  346.   nl();
  347. }
  348.  
  349. void config_qscan()
  350. {
  351.   char *s;
  352.   int i,done;
  353.  
  354.   l_config_qscan();
  355.   done=0;
  356.   do {
  357.     nl();
  358.     pl("Enter sub-board identifier, or Q to Quit");
  359.     helpl=7;
  360.     outstr("Config: ");
  361.     s=mmkey(0);
  362.     if (s[0])
  363.       for (i=0; i<MAX_SUBS; i++)
  364.         if (strcmp(usub[i].keys,s)==0) {
  365. #if MAX_SUBS>32
  366.           if (i>=32)
  367.             thisuser.qscn2 ^=((1L) << (usub[i].subnum-32));
  368.           else
  369.             thisuser.qscn ^=((1L) << (usub[i].subnum));
  370. #else
  371.           thisuser.qscn ^=((1L) << (usub[i].subnum));
  372. #endif
  373.         }
  374.     if (strcmp(s,"Q")==0)
  375.       done=1;
  376.     if (strcmp(s,"?")==0)
  377.       l_config_qscan();
  378.   } while ((!done) && (!hangup));
  379. }
  380.  
  381.  
  382. void list_macro(unsigned char *s)
  383. {
  384.   int i;
  385.  
  386.   i=0;
  387.   outchr('\"');
  388.   while ((i<80) && (s[i]!=0)) {
  389.     if (s[i]>=32)
  390.       outchr(s[i]);
  391.     else {
  392.       outchr('^');
  393.       outchr(s[i]+64);
  394.     }
  395.     ++i;
  396.   }
  397.   outchr('"');
  398.   nl();
  399. }
  400.  
  401.  
  402. void make_macros()
  403. {
  404.   unsigned char tempmac[81],s[81];
  405.   unsigned char ch,ch1;
  406.   int i,i1,done,done1;
  407.  
  408.   done=0;
  409.   do {
  410.     nl();
  411.     prt(2,"Macros: L:ist, M:ake, Q:uit  : ");
  412.     helpl=33;
  413.     ch=onek("QLM");
  414.     switch(ch) {
  415.       case 'Q':
  416.         done=1;
  417.         break;
  418.       case 'L':
  419.         nl();
  420.         nl();
  421.         pl("Ctrl-D macro: ");
  422.         list_macro(&(thisuser.macros[0][0]));
  423.         nl();
  424.         pl("Ctrl-F macro: ");
  425.         list_macro(&(thisuser.macros[1][0]));
  426.         nl();
  427.         pl("Ctrl-A macro: ");
  428.         list_macro(&(thisuser.macros[2][0]));
  429.         break;
  430.       case 'M':
  431.         nl();
  432.         prt(2,"Which (A,D,F, Q=quit) : ");
  433.         ch1=onek("QADF");
  434.         if (ch1!='Q') {
  435.           switch(ch1) {
  436.             case 'A': i1=2; break;
  437.             case 'D': i1=0; break;
  438.             case 'F': i1=1; break;
  439.           }
  440.           strcpy(s,&(thisuser.macros[i1][0]));
  441.           thisuser.macros[i1][0]=0;
  442.           done1=0;
  443.           i=0;
  444.           nl();
  445.           pl("Enter your macro now, hit ctrl-Z when done.");
  446.           nl();
  447.       okskey=0;
  448.           do {
  449.             ch1=getkey();
  450.             if (ch1==26)
  451.               done1=1;
  452.             else
  453.               if (ch1==8) {
  454.                 if (i>0) {
  455.                   i--;
  456.                   backspace();
  457.                   if (tempmac[i]<32)
  458.                     backspace();
  459.                 }
  460.               } else {
  461.                 if (ch1>=32) {
  462.                   tempmac[i++]=ch1;
  463.                   outchr(ch1);
  464.                 } else {
  465.                   tempmac[i++]=ch1;
  466.                   outchr('^');
  467.                   outchr(ch1+64);
  468.                 }
  469.               }
  470.             if (i>=78)
  471.               done1=1;
  472.           } while ((!done1) && (!hangup));
  473.       okskey=1;
  474.           tempmac[i]=0;
  475.           nl();
  476.           pl("You entered:");
  477.           nl();
  478.           nl();
  479.           list_macro(tempmac);
  480.           nl();
  481.           prt(5,"Is this OK? ");
  482.           if (yn()) {
  483.             strcpy(&(thisuser.macros[i1][0]),tempmac);
  484.             nl();
  485.             pl("Macro saved.");
  486.           } else {
  487.             nl();
  488.             strcpy(&(thisuser.macros[i1][0]),s);
  489.             pl("Nothing saved.");
  490.           }
  491.         }
  492.         break;
  493.     }
  494.   } while ((!done) && (!hangup));
  495. }
  496.  
  497.  
  498. void input_pw1()
  499. {
  500.   char s[81],s1[81];
  501.   int ok;
  502.  
  503.   nl();
  504.   prt(5,"Change password? ");
  505.   if (yn()) {
  506.     nl();
  507.     pl("You must now enter your current password.");
  508.     outstr(": ");
  509.     echo=0;
  510.     input(s,8);
  511.     if (strcmp(s,thisuser.pw)) {
  512.       nl();
  513.       pl("Incorrect.");
  514.       nl();
  515.       return;
  516.     }
  517.     nl();
  518.     nl();
  519.     pl("Enter your new password, 3 to 8 characters long.");
  520.     outstr(": ");
  521.     echo=0;
  522.     input(s,8);
  523.     nl();
  524.     nl();
  525.     pl("Repeat password for verification.");
  526.     outstr(": ");
  527.     echo=0;
  528.     input(s1,8);
  529.     if (strcmp(s,s1)==0) {
  530.       strcpy(thisuser.pw,s);
  531.       nl();
  532.       pl("Password changed.");
  533.       nl();
  534.       sysoplog("Changed Password.");
  535.     } else {
  536.       nl();
  537.       pl("VERIFY FAILED.");
  538.       pl("Password not changed.");
  539.       nl();
  540.     }
  541.   }
  542. }
  543.  
  544. void modify_mailbox()
  545. {
  546.   int i,i1,i2;
  547.   unsigned int u;
  548.   char s[81];
  549.   net_system_list_rec *csne;
  550.  
  551.   nl();
  552.   helpl=35;
  553.   prt(5,"Do you want to forward your mail? ");
  554.   if (!yn()) {
  555.     thisuser.forwardsys=0;
  556.     thisuser.forwardusr=0;
  557.     return;
  558.   }
  559.   nl();
  560.   if (syscfg.systemnumber) {
  561.     prt(5,"Forward to another system? ");
  562.     if (yn()) {
  563.       nl();
  564.       prt(2,"Which system (number)? ");
  565.       input(s,5);
  566.       i2=atoi(s);
  567.       if ((csne=next_system(i2))==NULL) {
  568.         nl();
  569.         pl("Unknown system.");
  570.         nl();
  571.         return;
  572.       }
  573.       nl();
  574.       npr("System name: %s\r\n",csne -> name);
  575.       nl();
  576.       if (i2==syscfg.systemnumber) {
  577.         nl();
  578.         pl("That's this system.");
  579.         nl();
  580.         return;
  581.       }
  582.       prt(2,"Which user number on that system? ");
  583.       input(s,5);
  584.       i=atoi(s);
  585.       if ((i>0) && (i<20000)) {
  586.         thisuser.forwardsys=i2;
  587.         thisuser.forwardusr=i;
  588.         nl();
  589.         pl("Saved.");
  590.         nl();
  591.       }
  592.       return;
  593.     }
  594.   }
  595.   nl();
  596.   prt(2,"Forward to which user? ");
  597.   input(s,40);
  598.   i=finduser1(s);
  599.   if (i==usernum) {
  600.     thisuser.forwardsys=0;
  601.     thisuser.forwardusr=0;
  602.     nl();
  603.     pl("Forwarding reset.");
  604.     nl();
  605.     return;
  606.   }
  607.   if (i>0) {
  608.     thisuser.forwardsys=0;
  609.     thisuser.forwardusr=i;
  610.     nl();
  611.     pl("Saved.");
  612.     nl();
  613.   }
  614. }
  615.  
  616.  
  617. void optional_lines()
  618. {
  619.   char s[81];
  620.   int i;
  621.  
  622.   pl("You may specify your optional lines value from 0-10,");
  623.   pl("0 being all, 10 being none.");
  624.   prt(2,"What value? ");
  625.   input(s,2);
  626.  
  627.   i=atoi(s);
  628.   if ((s[0]) && (i>=0) && (i<11))
  629.     thisuser.optional_val = i;
  630.  
  631. }
  632.  
  633.  
  634. void enter_regnum()
  635. {
  636.   char s[81];
  637.   long l;
  638.  
  639.   pl("You may now enter your WWIV registration number.");
  640.   pl("Enter 0 for none.");
  641.   nl();
  642.   prt(2,"WWIV: ");
  643.   input(s,5);
  644.   l=atol(s);
  645.   if ((s[0]) && (l>=0))
  646.     thisuser.wwiv_regnum = l;
  647.  
  648. }
  649.  
  650. void defaults()
  651. {
  652.   int i,i1,i2,done;
  653.   char s[81],s1[81],s2[81],ch;
  654.  
  655.   done=0;
  656.   print_cur_stat();
  657.   do {
  658.     nl();
  659.     helpl=4;
  660.     if (okansi()) {
  661.       prt(2,"Defaults: (1-9,A-B,?,Q) : ");
  662.       ch=onek("Q?123456789ABW");
  663.     } else {
  664.       prt(2,"Defaults: (1-7,B,?,Q) : ");
  665.       ch=onek("Q?1234567BW");
  666.     }
  667.     switch(ch) {
  668.       case 'Q':
  669.         done=1;
  670.         break;
  671.       case '?':
  672.         print_cur_stat();
  673.         break;
  674.       case '1':
  675.         input_screensize();
  676.         break;
  677.       case '2':
  678.         input_ansistat();
  679.         break;
  680.       case '3':
  681.         if (thisuser.sysstatus & sysstatus_pause_on_page)
  682.           thisuser.sysstatus ^= sysstatus_pause_on_page;
  683.         nl();
  684.         prt(5,"Pause each screenfull? ");
  685.         if (yn())
  686.           thisuser.sysstatus |= sysstatus_pause_on_page;
  687.         break;
  688.       case '4':
  689.         modify_mailbox();
  690.         break;
  691.       case '5':
  692.         config_qscan();
  693.         break;
  694.       case '6':
  695.         input_pw1();
  696.         break;
  697.       case '7':
  698.         make_macros();
  699.         break;
  700.       case '8':
  701.         change_colors();
  702.         break;
  703.       case '9':
  704.     select_editor();
  705.     break;
  706.       case 'A':
  707.         if (thisuser.sysstatus & sysstatus_funky_colors)
  708.           thisuser.sysstatus ^= sysstatus_funky_colors;
  709.         nl();
  710.         prt(5,"Use extended colors? ");
  711.         if (yn())
  712.           thisuser.sysstatus |= sysstatus_funky_colors;
  713.         break;
  714.       case 'B':
  715.         optional_lines();
  716.         break;
  717.       case 'W':
  718.         enter_regnum();
  719.         break;
  720.     }
  721.   } while ((!done) && (!hangup));
  722. }
  723.  
  724.  
  725.