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