home *** CD-ROM | disk | FTP | other *** search
- /*
- * SETTINGS.C - Settings screen
- *
- * Msged/Q message editor for QuickBBS Copyright 1990 by P.J. Muller
- *
- */
-
- #include <stdlib.h> /* must be here for min/max */
-
- #include "msged.h"
- #include "qmsgbase.h"
-
- #ifdef SETTINGS
-
- #include "screen.h"
- #include <string.h> /* include here for compile speed */
- #include <stdio.h>
- #include <ctype.h>
-
- #define TLEN 64
- #define ILEN 40
- #define ORGOFS 15
-
- #define FFIRST 1
- #define FLAST 18
-
- #define SWBEGIN 9
- #define SWEND 18
-
- #define SBEGIN 1
- #define SEND 6
-
- #define NBEGIN 7
- #define NEND 8
-
- #define SWLINE 15
- #define STLINE 5
- #define NULINE 11
- #define PILINE 1
-
- #define OFFSET 35
-
- static void update(int f);
- static BOOLEAN checkname(char *n);
-
- static char taddr[TLEN];
-
- static char *tname,
- *tlist1,
- *tlist2,
- *tqs,
- *torg;
-
- static int trm,
- tusernum,
- ttab;
-
- static int tcr,
- #ifdef SEENBY
- tseen,
- #endif
- #ifdef TEARLINE
- ttear,
- #endif
- tconfirm,
- tbeep,
- tshow,
- tsrch,
- tpriv,
- tcrash,
- tkill;
-
- void settings()
- {
- int f = 1;
- int ch = 0;
- char tmp[TLEN];
-
- /* first close the message base */
- if (!closemsgbase())
- fatal("Could not close message base");
-
- /* temporary variables until <enter> is pressed */
-
- tname = strdup(username);
- tqs = strdup(quotestr);
-
- memset(tmp,0,sizeof(tmp));
-
- /* Removed: read origin line for current area into 'tmp', else */
-
- if (origin != NULL)
- strcpy(tmp,origin);
- else
- strcpy(tmp,username);
-
- torg = strdup(tmp);
-
- trm = rm;
- tusernum = usernum;
- ttab = tabsize;
-
- #ifdef SEENBY
- tseen = seenbys;
- #endif
- #ifdef TEARLINE
- ttear = tearline;
- #endif
- tcr = arealist[area].softcr;
- tconfirm = confirmations;
- tbeep = beepson;
- tshow = shownotes;
- tpriv = arealist[area].msgbits.is_priv;
- tcrash = arealist[area].msgbits.is_crash;
- tkill = arealist[area].msgbits.is_kill;
- tsrch = globsrch;
-
- if (userlist != NULL)
- tlist2 = strdup(userlist);
- else
- tlist2 = strdup(" ");
-
- if (fidolist != NULL)
- tlist1 = strdup(fidolist);
- else
- tlist1 = strdup(" ");
-
- strcpy(taddr,formaddr(thisnode[CurAKA],Z_A|N_A|P_O|D_O));
-
- set_color(co_info);
-
- cls();
- gotoxy(1,PILINE); bputs("Msged/Q " VERSION " settings");
- gotoxy(1,STLINE); bputs("String Settings");
- gotoxy(1,NULINE); bputs("Numeric Settings");
- gotoxy(1,SWLINE); bputs("Switches");
- gotoxy(16,SWLINE); bprintf("Current area %s (%s)", arealist[area].tag,
- arealist[area].description);
- for (f = FFIRST; f <= FLAST; f++)
- update(f);
-
- f = 1;
- gotoxy(1,22);
- bputs("________________________________________________________________________________");
- gotoxy(10,23); bputs("Use the arrow keys to select a setting or switch. Esc to abort.");
- gotoxy(10,24); bputs("Press the <spacebar> to change a setting or toggle a switch.");
- gotoxy(10,25); bputs("Use the normal editing keys to change string and numeric settings.");
-
- while (ch != ABORT) {
-
- set_color(co_hilite);
- update(f);
- set_color(co_info);
-
- gotoxy(1,maxy);
- video_update();
-
- ch = getkey();
-
- if (ch != SPACE)
- update(f);
-
- switch (ch) {
- case UP:
- if (f > FFIRST)
- f--;
- else
- f = FLAST;
- if ((f > SWBEGIN) && (f <= SWEND))
- f--;
- #ifndef TEARLINE
- if (f == 10) f--;
- #endif
- #ifndef SEENBY
- if (f == 9) f--;
- #endif
- break;
-
- case DOWN:
- if (f < FLAST)
- f++;
- else
- f = FFIRST;
- if ((f < SWEND) && (f > SWBEGIN))
- f++;
- #ifndef SEENBY
- if (f == 9) f++;
- #endif
- #ifndef TEARLINE
- if (f == 10) f++;
- #endif
- break;
-
- case LEFT:
- if (f > FFIRST)
- f--;
- else
- f = FLAST;
- #ifndef TEARLINE
- if (f == 10) f--;
- #endif
- #ifndef SEENBY
- if (f == 9) f--;
- #endif
- break;
-
- case RIGHT:
- if (f < FLAST)
- f++;
- else
- f = FFIRST;
- #ifndef SEENBY
- if (f == 9) f++;
- #endif
- #ifndef TEARLINE
- if (f == 10) f++;
- #endif
- break;
-
- case ENTER :
- if (!checkname(tname)) {
- f = 1;
- break;
- } /* if */
-
- #ifdef SEENBY
- seenbys = tseen;
- #endif
- #ifdef TEARLINE
- tearline = ttear;
- #endif
- arealist[area].softcr = tcr;
- confirmations = tconfirm;
- shownotes = tshow;
- beepson = tbeep;
- ptrfree(username);
- ptrfree(fidolist);
- ptrfree(userlist);
- ptrfree(quotestr);
- ptrfree(origin);
- origin = torg;
- username = tname;
- fidolist = tlist1;
- userlist = tlist2;
- quotestr = tqs;
- thisnode[CurAKA] = parsenode(taddr);
- tabsize = ttab;
- arealist[area].msgbits.is_priv = tpriv;
- arealist[area].msgbits.is_crash = tcrash;
- arealist[area].msgbits.is_kill = tkill;
- globsrch = tsrch;
- rm = trm;
- usernum = tusernum;
- if (!openmsgbase())
- fatal("Could not open message base");
- return;
-
- case SPACE:
- set_color(co_normal);
-
- switch (f) {
- case 1 : strcpy(tmp,tname);
- gotoxy(OFFSET,PILINE + 1);
- if (bgets(tmp,ILEN) != ABORT) {
- ptrfree(tname);
- tname = strdup(tmp);
- }
- break;
- case 2 : gotoxy(OFFSET,PILINE + 2);
- (void)bgets(taddr,ILEN);
- break;
- case 3 : strcpy(tmp,tlist1);
- gotoxy(OFFSET,STLINE + 1);
- if (bgets(tmp,ILEN) != ABORT) {
- ptrfree(tlist1);
- tlist1 = strdup(tmp);
- }
- break;
- case 4 : strcpy(tmp,tlist2);
- gotoxy(OFFSET,STLINE + 2);
- if (bgets(tmp,ILEN) != ABORT) {
- ptrfree(tlist2);
- tlist2 = strdup(tmp);
- }
- break;
- case 5 : strcpy(tmp,tqs);
- gotoxy(OFFSET,STLINE + 3);
- if (bgets(tmp,ILEN) != ABORT) {
- ptrfree(tqs);
- tqs = strdup(tmp);
- }
- break;
- case 6 : strcpy(tmp,torg);
- gotoxy(OFFSET-ORGOFS,STLINE + 4);
- if (bgets(tmp,ILEN+ORGOFS) != ABORT) {
- ptrfree(torg);
- override = TRUE;
- torg = strdup(tmp);
- }
- break;
- case 7 : gotoxy(OFFSET,NULINE + 1);
- ttab = getnum(1,trm,ttab);
- break;
- case 8 : gotoxy(OFFSET,NULINE + 2);
- trm = getnum(1,maxx,trm);
- break;
- #ifdef SEENBY
- case 9 : tseen = !tseen; break;
- #endif
- #ifdef TEARLINE
- case 10: ttear = !ttear; break;
- #endif
- case 11: tcr = !tcr; break;
- case 12: tconfirm= !tconfirm; break;
- case 13: tshow = !tshow; break;
- case 14: tbeep = !tbeep; break;
- case 15: tpriv = !tpriv; break;
- case 16: tkill = !tkill; break;
- case 17: tcrash = !tcrash; break;
- case 18: tsrch = !tsrch; break;
- } /* switch */
- set_color(co_info);
- break;
-
- default :
- switch (tolower(ch & 0xff)) {
- case 'n' : f = 1; break;
- case 'a' : f = 2; break;
- case 'p' : f = 3; break;
- case 's' : f = 4; break;
- case 'q' : f = 5; break;
- case 'o' : f = 6; break;
- case 't' : f = 7; break;
- case 'r' : f = 8; break;
- #ifdef SEENBY
- case 'b' : f = 9; tseen = !tseen; break;
- #endif
- #ifdef TEARLINE
- case 'l' : f = 10; ttear = !ttear; break;
- #endif
- case 'c' : f = 11; tcr = !tcr; break;
- case 'd' : f = 12; tconfirm= !tconfirm; break;
- case 'h' : f = 13; tshow = !tshow; break;
- case 'w' : f = 14; tbeep = !tbeep; break;
- case 'v' : f = 15; tpriv = !tpriv; break;
- case 'i' : f = 16; tkill = !tkill; break;
- case 'k' : f = 17; tcrash = !tcrash; break;
- case 'g' : f = 18; tsrch = !tsrch; break;
- } /* switch */
- break;
- } /* switch */
- } /* while */
-
- ptrfree(tname);
- ptrfree(tlist1);
- ptrfree(tlist2);
- ptrfree(tqs);
-
- if (!openmsgbase())
- fatal("Could not open message base");
- } /* settings */
-
- static void update(int f)
- {
- int color = get_color();
-
- switch (f) {
- case 1 : gotoxy(10,PILINE + 1); set_color(co_hilite); bputc('N'); set_color(color); bputs("ame:"); gotoxy(OFFSET,PILINE + 1); bputs(tname); break;
- case 2 : gotoxy(10,PILINE + 2); set_color(co_hilite); bputc('A'); set_color(color); bputs("ddress:"); gotoxy(OFFSET,PILINE + 2); bputs(taddr); break;
- case 3 : gotoxy(10,STLINE + 1); bputs("Userlist ("); set_color(co_hilite); bputc('P'); set_color(color); bputs("rimary):"); gotoxy(OFFSET,STLINE + 1); bputs(tlist1); break;
- case 4 : gotoxy(10,STLINE + 2); bputs(" ("); set_color(co_hilite); bputc('S'); set_color(color); bputs("econdary):"); gotoxy(OFFSET,STLINE + 2); bputs(tlist2); break;
- case 5 : gotoxy(10,STLINE + 3); set_color(co_hilite); bputc('Q'); set_color(color); bputs("uote String:"); gotoxy(OFFSET,STLINE + 3); bputs(tqs); break;
- case 6 : gotoxy(10,STLINE + 4); set_color(co_hilite); bputc('O'); set_color(color); bputs("rigin:"); gotoxy(OFFSET-ORGOFS,STLINE + 4); bputs(torg); break;
- case 7 : gotoxy(10,NULINE + 1); set_color(co_hilite); bputc('T'); set_color(color); bputs("ab setting:"); gotoxy(OFFSET,NULINE + 1); bprintf("%d",ttab); break;
- case 8 : gotoxy(10,NULINE + 2); set_color(co_hilite); bputc('R'); set_color(color); bputs("ight margin:"); gotoxy(OFFSET,NULINE + 2); bprintf("%d",trm); break;
- #ifdef SEENBY
- case 9 : gotoxy(10,SWLINE + 1); bputs("Seen-"); set_color(co_hilite); bputc('B'); set_color(color); bprintf("ys: %s",(tseen ) ? "Yes" : "No "); break;
- #endif
- #ifdef TEARLINE
- case 10: gotoxy(OFFSET,SWLINE + 1); bputs("Tear"); set_color(co_hilite); bputc('l'); set_color(color); bprintf("ines: %s",(ttear ) ? "Yes" : "No "); break;
- #endif
- case 11: gotoxy(10,SWLINE + 2); bputs("Soft "); set_color(co_hilite); bputc('C'); set_color(color); bprintf("Rs: %s",(tcr ) ? "Yes" : "No "); break;
- case 12: gotoxy(OFFSET,SWLINE + 2); bputs("Confirm "); set_color(co_hilite); bputc('D'); set_color(color); bprintf("eletes: %s",(tconfirm) ? "Yes" : "No "); break;
- case 13: gotoxy(10,SWLINE + 3); set_color(co_hilite); bputc('H'); set_color(color); bprintf("idden Lines: %s",(tshow ) ? "Yes" : "No "); break;
- case 14: gotoxy(OFFSET,SWLINE + 3); set_color(co_hilite); bputc('W'); set_color(color); bprintf("arning beeps: %s",(tbeep) ? "Yes" : "No "); break;
- case 15: gotoxy(10,SWLINE + 4); bputs("Pri"); set_color(co_hilite); bputc('v'); set_color(color); bprintf("ileged: %s",(tpriv) ? "On " : "Off"); break;
- case 16: gotoxy(OFFSET,SWLINE + 4); bputc('K'); set_color(co_hilite); bputc('i'); set_color(color); bprintf("ll/Sent: %s",(tkill) ? "On " : "Off"); break;
- case 17: gotoxy(10,SWLINE + 5); set_color(co_hilite); bputc('K'); set_color(color); bprintf("rash: %s",(tcrash) ? "On " : "Off"); break;
- case 18: gotoxy(OFFSET,SWLINE + 5); set_color(co_hilite); bputc('G'); set_color(color); bprintf("lobal Search: %s",(tsrch) ? "On " : "Off"); break;
- } /* switch */
-
- set_color(color);
- } /* update */
-
- static BOOLEAN checkname(char *n)
- {
- int i;
-
- if (!useusersbbs) { /* doesn't use USERS.BBS? */
- if (*n == EOS) /* empty? */
- i = -1;
- else
- i = 0;
- } else {
- i = searchuser(n,FALSE);
- } /* else */
-
- if (i < 0) {
- gotoxy(1,22);
- bputs("________________________________________________________________________________");
- gotoxy(2,22);
- set_color(co_warn);
- bprintf(" User '%s' not found in user base ", n);
- set_color(co_normal);
- tusernum = 0;
- return FALSE;
- } else {
- tusernum = i;
- return TRUE;
- } /* else */
- } /* checkname */
-
- #endif