home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / msgd196s.lzh / SETTINGS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-02  |  14.2 KB  |  328 lines

  1. /*
  2.  
  3. Title:    MsgEd
  4.   
  5. File:   settings.c
  6.   
  7. Author:    Jim Nutt
  8.     
  9. Copr:   1988 by Jim Nutt
  10.   
  11. Description:
  12.     
  13.     Small, fast fido message editor.
  14.     
  15. Revision History:
  16.   
  17.         0.00    28 October 1988
  18.     
  19. Support Files:
  20.   
  21.     msged.h
  22.   
  23. */
  24.  
  25. #include "msged.h"
  26.  
  27. #define TLEN    64
  28. #define ILEN    40
  29.  
  30. #define FFIRST  1
  31. #define FLAST   18
  32.  
  33. #define SWBEGIN  9
  34. #define SWEND    18
  35.  
  36. #define SBEGIN  1
  37. #define SEND    6
  38.  
  39. #define NBEGIN  7
  40. #define NEND    8
  41.  
  42. #define SWLINE  15
  43. #define STLINE  5
  44. #define NULINE  11
  45. #define PILINE  1
  46.  
  47. #define OFFSET 35
  48.  
  49. static void update(int f);
  50.  
  51. static  char    taddr[TLEN];
  52.  
  53. static  char   *tname,
  54.                *tlist1,
  55.                *tlist2,
  56.                *tqs,
  57.                *torg;
  58.  
  59. static  int     trm,
  60.                 ttab;
  61.  
  62. static  int     tseen,
  63.                 ttear,
  64.                 tcr,
  65.                 tconfirm,
  66.                 tread,
  67.                 tshow,
  68.                 thold,
  69.                 tpriv,
  70.                 tcrash,
  71.                 tkill;
  72.  
  73.  
  74. void settings()
  75.  
  76. {
  77.         int f = 1;
  78.         int ch = 0;
  79.         FILE *fp;
  80.         char tmp[TLEN];
  81.         char path[TLEN];
  82.  
  83.         /* temporary variables until <enter> is pressed */
  84.  
  85.         tname = strdup(username);
  86.         tqs = strdup(quotestr);
  87.  
  88.         memset(tmp,0,sizeof tmp);
  89.         sprintf(path,"%s\\origin",arealist[area].path);
  90.  
  91.         if ((fp = fopen(path,"rt")) != NULL) {
  92.                 fgets(tmp,sizeof(tmp),fp);
  93.                 fclose(fp);
  94.         }
  95.         else if (origin != NULL)
  96.                 strcpy(tmp,origin);
  97.         else
  98.                 strcpy(tmp,username);
  99.  
  100.         torg = strdup(tmp);
  101.  
  102.         trm = rm;
  103.         ttab = tabsize;
  104.  
  105.         tseen = seenbys;
  106.         ttear = tearline;
  107.         tcr = softcr;
  108.         tconfirm = confirmations;
  109.         tread = readthread;
  110.         tshow = shownotes;
  111.         thold = msgbits.hold;
  112.         tpriv = msgbits.private;
  113.         tcrash = msgbits.crash;
  114.         tkill = msgbits.killsent;
  115.  
  116.         if (userlist != NULL)
  117.                 tlist2 = strdup(userlist);
  118.         else
  119.                 tlist2 = strdup(" ");
  120.  
  121.         if (fidolist != NULL)
  122.                 tlist1 = strdup(fidolist);
  123.         else
  124.                 tlist1 = strdup(" ");
  125.  
  126.         sprintf(taddr,"%d:%d/%d",thisnode.zone,thisnode.net,thisnode.node);
  127.         if (thisnode.point != 0) {
  128.                 sprintf(tmp,".%d",thisnode.point);
  129.                 strcat(taddr,tmp);
  130.         }
  131.         if (thisnode.domain != NULL) {
  132.                 sprintf(tmp,">%s",thisnode.domain);
  133.                 strcat(taddr,tmp);
  134.         }
  135.         cls();
  136.         gotoxy(1,PILINE);  bputs("msged " VERSION " settings");
  137.         gotoxy(1,STLINE); bputs("String Settings");
  138.         gotoxy(1,NULINE); bputs("Numeric Settings");
  139.         gotoxy(1,SWLINE); bputs("Switches");
  140.         for (f = FFIRST; f <= FLAST; f++)
  141.                 update(f);
  142.         f = 1;
  143.         gotoxy(1,22);
  144.         bputs("________________________________________________________________________________");
  145.         gotoxy(10,23); bputs("Use the arrow keys to select a setting or switch.");
  146.         gotoxy(10,24); bputs("Press the <spacebar> to change a setting or toggle a switch.");
  147.         gotoxy(10,25); bputs("Use the normal editing keys to change string and numeric settings.");
  148.  
  149.         while (ch != ABORT) {
  150.  
  151.                 foreground(normback);
  152.                 background(normfore);
  153.                 update(f);
  154.                 background(normback);
  155.                 foreground(normfore);
  156.  
  157.                 ch = getkey();
  158.  
  159.                 if (ch != SPACE)
  160.                         update(f);
  161.  
  162.                 switch (ch) {
  163.                         case UP:
  164.                                 if (f > FFIRST)
  165.                                         f--;
  166.                                 else
  167.                                         f = FLAST;
  168.  
  169.                                 if ((f > SWBEGIN) && (f <= SWEND))
  170.                                         f--;
  171.                                 break;
  172.  
  173.                         case DOWN:
  174.                                 if (f < FLAST)
  175.                                         f++;
  176.                                 else
  177.                                         f = FFIRST;
  178.  
  179.                                 if ((f < SWEND) && (f > SWBEGIN))
  180.                                         f++;
  181.                                 break;
  182.  
  183.                         case LEFT:
  184.                                 if (f > FFIRST)
  185.                                         f--;
  186.                                 else
  187.                                         f = FLAST;
  188.                                 break;
  189.  
  190.                         case RIGHT:
  191.                                 if (f < FLAST)
  192.                                         f++;
  193.                                 else
  194.                                         f = FFIRST;
  195.                                 break;
  196.  
  197.                         case ENTER :
  198.                                 seenbys = tseen;
  199.                                 tearline = ttear;
  200.                                 softcr = tcr;
  201.                                 confirmations = tconfirm;
  202.                                 shownotes = tshow;
  203.                                 readthread = tread;
  204.                                 free(username);
  205.                                 free(fidolist);
  206.                                 free(userlist);
  207.                                 free(quotestr);
  208.                                 free(origin);
  209.                                 origin = torg;
  210.                                 username = tname;
  211.                                 fidolist = tlist1;
  212.                                 userlist = tlist2;
  213.                                 quotestr = tqs;
  214.                                 thisnode = parsenode(taddr);
  215.                                 tabsize = ttab;
  216.                                 msgbits.private = tpriv;
  217.                                 msgbits.crash = tcrash;
  218.                                 msgbits.killsent = tkill;
  219.                                 msgbits.hold = thold;
  220.                                 rm = trm;
  221.                                 return;
  222.  
  223.                         case SPACE:
  224.                                 intense(ON);
  225.                                 switch (f) {
  226.                                         case 1 : strcpy(tmp,tname);
  227.                                                  gotoxy(OFFSET,PILINE + 1); bgets(tmp,ILEN);
  228.                                                  free(tname);
  229.                                                  tname = strdup(tmp);
  230.                                                  break;
  231.                                         case 2 : gotoxy(OFFSET,PILINE + 2); bgets(taddr,ILEN);
  232.                                                  break;
  233.                                         case 3 : strcpy(tmp,tlist1);
  234.                                                  gotoxy(OFFSET,STLINE + 1); bgets(tmp,ILEN);
  235.                                                  free(tlist1);
  236.                                                  tlist1 = strdup(tmp);
  237.                                                  break;
  238.                                         case 4 : strcpy(tmp,tlist2);
  239.                                                  gotoxy(OFFSET,STLINE + 2); bgets(tmp,ILEN);
  240.                                                  free(tlist2);
  241.                                                  tlist2 = strdup(tmp);
  242.                                                  break;
  243.                                         case 5 : strcpy(tmp,tqs);
  244.                                                  gotoxy(OFFSET,STLINE + 3); bgets(tmp,ILEN);
  245.                                                  free(tqs);
  246.                                                  tqs = strdup(tmp);
  247.                                                  break;
  248.                                         case 6 : strcpy(tmp,torg);
  249.                                                  gotoxy(OFFSET,STLINE + 4); bgets(tmp,ILEN);
  250.                                                  free(torg);
  251.                                                  override = TRUE;
  252.                                                  torg = strdup(tmp);
  253.                                                  break;
  254.                                         case 7 : gotoxy(OFFSET,NULINE + 1);
  255.                                                  ttab = getnum(1,trm,ttab);
  256.                                                  break;
  257.                                         case 8 : gotoxy(OFFSET,NULINE + 2);
  258.                                                  trm = getnum(1,maxx,trm);
  259.                                                  break;
  260.                                         case 9 : tseen   = !tseen; break;
  261.                                         case 10: ttear   = !ttear; break;
  262.                                         case 11: tcr     = !tcr; break;
  263.                                         case 12: tconfirm= !tconfirm; break;
  264.                                         case 13: tshow   = !tshow; break;
  265.                                         case 14: tread   = !tread; break;
  266.                                         case 15: tpriv   = !tpriv; break;
  267.                                         case 16: tkill   = !tkill; break;
  268.                                         case 17: tcrash  = !tcrash; break;
  269.                                         case 18: thold   = !thold; break;
  270.                                 }
  271.                                 intense(OFF);
  272.                                 break;
  273.                         default :
  274.                                 switch (tolower(ch & 0xff)) {
  275.                                         case 'n' : f = 1; break;
  276.                                         case 'a' : f = 2; break;
  277.                                         case 'p' : f = 3; break;
  278.                                         case 's' : f = 4; break;
  279.                                         case 'q' : f = 5; break;
  280.                                         case 'o' : f = 6; break;
  281.                                         case 't' : f = 7; break;
  282.                                         case 'r' : f = 8; break;
  283.                                         case 'b' : f = 9; tseen   = !tseen; break;
  284.                                         case 'l' : f = 10; ttear   = !ttear; break;
  285.                                         case 'c' : f = 11; tcr     = !tcr; break;
  286.                                         case 'd' : f = 12; tconfirm= !tconfirm; break;
  287.                                         case 'h' : f = 13; tshow   = !tshow; break;
  288.                                         case 'f' : f = 14; tread   = !tread; break;
  289.                                         case 'v' : f = 15; tpriv   = !tpriv; break;
  290.                                         case 'i' : f = 16; tkill   = !tkill; break;
  291.                                         case 'k' : f = 17; tcrash  = !tcrash; break;
  292.                                         case 'e' : f = 18; thold   = !thold; break;
  293.                                 }
  294.                                 break;
  295.                 }
  296.         }
  297.  
  298.         free(tname);
  299.         free(tlist1);
  300.         free(tlist2);
  301.         free(tqs);
  302. }
  303.  
  304. static void update(int f)
  305.  
  306. {
  307.         switch (f) {
  308.                 case 1 : gotoxy(10,PILINE + 1); intense(ON); bputc('N'); intense(OFF); bputs("ame:"); gotoxy(OFFSET,PILINE + 1); bputs(tname);                              break;
  309.                 case 2 : gotoxy(10,PILINE + 2); intense(ON); bputc('A'); intense(OFF); bputs("ddress:"); gotoxy(OFFSET,PILINE + 2); bputs(taddr);                            break;
  310.                 case 3 : gotoxy(10,STLINE + 1); bputs("Userlist ("); intense(ON); bputc('P'); intense(OFF); bputs("rimary):"); gotoxy(OFFSET,STLINE + 1); bputs(tlist1);     break;
  311.                 case 4 : gotoxy(10,STLINE + 2); bputs("         ("); intense(ON); bputc('S'); intense(OFF); bputs("econdary):"); gotoxy(OFFSET,STLINE + 2); bputs(tlist2);   break;
  312.                 case 5 : gotoxy(10,STLINE + 3); intense(ON); bputc('Q'); intense(OFF); bputs("uote String:"); gotoxy(OFFSET,STLINE + 3); bputs(tqs);                         break;
  313.                 case 6 : gotoxy(10,STLINE + 4); intense(ON); bputc('O'); intense(OFF); bputs("rigin:"); gotoxy(OFFSET,STLINE + 4); bputs(torg);                              break;
  314.                 case 7 : gotoxy(10,NULINE + 1); intense(ON); bputc('T'); intense(OFF); bputs("ab setting:"); gotoxy(OFFSET,NULINE + 1); bprintf("%d",ttab);                  break;
  315.                 case 8 : gotoxy(10,NULINE + 2); intense(ON); bputc('R'); intense(OFF); bputs("ight margin:"); gotoxy(OFFSET,NULINE + 2); bprintf("%d",trm);                  break;
  316.                 case 9 : gotoxy(10,SWLINE + 1); bputs("Seen-"); intense(ON); bputc('B'); intense(OFF); bprintf("ys:        %s",(tseen   ) ? "Yes" : "No ");                  break;
  317.                 case 10: gotoxy(OFFSET,SWLINE + 1); bputs("Tear"); intense(ON); bputc('l'); intense(OFF); bprintf("ines:          %s",(ttear   ) ? "Yes" : "No ");              break;
  318.                 case 11: gotoxy(10,SWLINE + 2); bputs("Soft "); intense(ON); bputc('C'); intense(OFF); bprintf("Rs:        %s",(tcr     ) ? "Yes" : "No ");          break;
  319.                 case 12: gotoxy(OFFSET,SWLINE + 2); bputs("Confirm "); intense(ON); bputc('D'); intense(OFF); bprintf("eletes:    %s",(tconfirm) ? "Yes" : "No ");               break;
  320.                 case 13: gotoxy(10,SWLINE + 3); intense(ON); bputc('H'); intense(OFF); bprintf("idden Lines:    %s",(tshow   ) ? "Yes" : "No "); break;
  321.                 case 14: gotoxy(OFFSET,SWLINE + 3); intense(ON); bputc('F'); intense(OFF); bprintf("ast Read Threads:  %s",(tread) ? "Yes" : "No "); break;
  322.                 case 15: gotoxy(10,SWLINE + 4); bputs("Pri"); intense(ON); bputc('v'); intense(OFF); bprintf("iliged:      %s",(tpriv) ? "On " : "Off"); break;
  323.                 case 16: gotoxy(OFFSET,SWLINE + 4); bputc('K'); intense(ON); bputc('i'); intense(OFF); bprintf("ll/Sent:          %s",(tkill) ? "On " : "Off"); break;
  324.                 case 17: gotoxy(10,SWLINE + 5); intense(ON); bputc('K'); intense(OFF); bprintf("rash:           %s",(tcrash) ? "On " : "Off"); break;
  325.                 case 18: gotoxy(OFFSET,SWLINE + 5); bputc('K'); intense(ON); bputc('e'); intense(OFF); bprintf("ep (hold):        %s",(thold) ? "On " : "Off"); break;
  326.         }
  327. }
  328.