|
|
1.1 root 1: /* scfgchat.c */
2:
3: /* $Id: scfgchat.c,v 1.7 2004/05/30 06:56:05 deuce Exp $ */
4:
5: /****************************************************************************
6: * @format.tab-size 4 (Plain Text/Source Code File Header) *
7: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
8: * *
9: * Copyright 2002 Rob Swindell - http://www.synchro.net/copyright.html *
10: * *
11: * This program is free software; you can redistribute it and/or *
12: * modify it under the terms of the GNU General Public License *
13: * as published by the Free Software Foundation; either version 2 *
14: * of the License, or (at your option) any later version. *
15: * See the GNU General Public License for more details: gpl.txt or *
16: * http://www.fsf.org/copyleft/gpl.html *
17: * *
18: * Anonymous FTP access to the most recent released source is available at *
19: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
20: * *
21: * Anonymous CVS access to the development source and modification history *
22: * is available at cvs.synchro.net:/cvsroot/sbbs, example: *
23: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login *
24: * (just hit return, no password is necessary) *
25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src *
26: * *
27: * For Synchronet coding style and modification guidelines, see *
28: * http://www.synchro.net/source.html *
29: * *
30: * You are encouraged to submit any modifications (preferably in Unix diff *
31: * format) via e-mail to [email protected] *
32: * *
33: * Note: If this box doesn't appear square, then you need to fix your tabs. *
34: ****************************************************************************/
35:
36: #include "scfg.h"
37:
38: void page_cfg()
39: {
40: static int dflt,bar;
41: char str[81],done=0;
42: int j,k;
43: uint i;
44: static page_t savpage;
45:
46: while(1) {
47: for(i=0;i<cfg.total_pages && i<MAX_OPTS;i++)
48: sprintf(opt[i],"%-40.40s %-.20s",cfg.page[i]->cmd,cfg.page[i]->arstr);
49: opt[i][0]=0;
50: uifc.savnum=0;
51: j=WIN_ACT|WIN_SAV|WIN_RHT|WIN_BOT;
52: if(cfg.total_pages)
53: j|=WIN_DEL|WIN_GET;
54: if(cfg.total_pages<MAX_OPTS)
55: j|=WIN_INS|WIN_INSACT|WIN_XTR;
56: if(savpage.cmd[0])
57: j|=WIN_PUT;
58: SETHELP(WHERE);
59: /*
60: &External Sysop Chat Pagers:&
61:
62: This is a list of the configured external sysop chat pagers.
63:
64: To add a pager, select the desired location and hit INS .
65:
66: To delete a pager, select it and hit DEL .
67:
68: To configure a pager, select it and hit ENTER .
69: */
70: i=uifc.list(j,0,0,45,&dflt,&bar,"External Sysop Chat Pagers",opt);
71: if((signed)i==-1)
72: return;
73: if((i&MSK_ON)==MSK_INS) {
74: i&=MSK_OFF;
75: sprintf(str,"%%!tone +chatpage.ton");
76: SETHELP(WHERE);
77: /*
78: &External Chat Pager Command Line:&
79:
80: This is the command line to execute for this external chat pager.
81: */
82: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Command Line",str,50
83: ,K_EDIT)<1)
84: continue;
85: if((cfg.page=(page_t **)REALLOC(cfg.page,sizeof(page_t *)*(cfg.total_pages+1)))
86: ==NULL) {
87: errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_pages+1);
88: cfg.total_pages=0;
89: bail(1);
90: continue; }
91: if(cfg.total_pages)
92: for(j=cfg.total_pages;j>i;j--)
93: cfg.page[j]=cfg.page[j-1];
94: if((cfg.page[i]=(page_t *)MALLOC(sizeof(page_t)))==NULL) {
95: errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(page_t));
96: continue; }
97: memset((page_t *)cfg.page[i],0,sizeof(page_t));
98: strcpy(cfg.page[i]->cmd,str);
99: cfg.total_pages++;
100: uifc.changes=1;
101: continue; }
102: if((i&MSK_ON)==MSK_DEL) {
103: i&=MSK_OFF;
104: FREE(cfg.page[i]);
105: cfg.total_pages--;
106: for(j=i;j<cfg.total_pages;j++)
107: cfg.page[j]=cfg.page[j+1];
108: uifc.changes=1;
109: continue; }
110: if((i&MSK_ON)==MSK_GET) {
111: i&=MSK_OFF;
112: savpage=*cfg.page[i];
113: continue; }
114: if((i&MSK_ON)==MSK_PUT) {
115: i&=MSK_OFF;
116: *cfg.page[i]=savpage;
117: uifc.changes=1;
118: continue; }
119: j=0;
120: done=0;
121: while(!done) {
122: k=0;
123: sprintf(opt[k++],"%-27.27s%.40s","Command Line",cfg.page[i]->cmd);
124: sprintf(opt[k++],"%-27.27s%.40s","Access Requirements",cfg.page[i]->arstr);
125: sprintf(opt[k++],"%-27.27s%s","Intercept I/O Interrupts"
126: ,cfg.page[i]->misc&IO_INTS ? "Yes":"No");
127: opt[k][0]=0;
128: sprintf(str,"Sysop Chat Pager #%d",i+1);
129: uifc.savnum=1;
130: switch(uifc.list(WIN_ACT|WIN_MID|WIN_SAV,0,0,60,&j,0,str,opt)) {
131: case -1:
132: done=1;
133: break;
134: case 0:
135: SETHELP(WHERE);
136: /*
137: &External Chat Pager Command Line:&
138:
139: This is the command line to execute for this external chat pager.
140: */
141: strcpy(str,cfg.page[i]->cmd);
142: if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Command Line"
143: ,cfg.page[i]->cmd,sizeof(cfg.page[i]->cmd)-1,K_EDIT))
144: strcpy(cfg.page[i]->cmd,str);
145: break;
146: case 1:
147: uifc.savnum=2;
148: getar(str,cfg.page[i]->arstr);
149: break;
150: case 2:
151: k=1;
152: strcpy(opt[0],"Yes");
153: strcpy(opt[1],"No");
154: opt[2][0]=0;
155: uifc.savnum=2;
156: SETHELP(WHERE);
157: /*
158: &Intercept I/O Interrupts:&
159:
160: If you wish the DOS screen output and keyboard input to be intercepted
161: when running this chat pager, set this option to &Yes&.
162: */
163: k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0,"Intercept I/O Interrupts"
164: ,opt);
165: if(!k && !(cfg.page[i]->misc&IO_INTS)) {
166: cfg.page[i]->misc|=IO_INTS;
167: uifc.changes=1; }
168: else if(k==1 && cfg.page[i]->misc&IO_INTS) {
169: cfg.page[i]->misc&=~IO_INTS;
170: uifc.changes=1; }
171: break;
172:
173: } } }
174: }
175:
176: void chan_cfg()
177: {
178: static int chan_dflt,chan_bar,opt_dflt;
179: char str[81],code[9],done=0,*p;
180: int j,k;
181: uint i;
182: static chan_t savchan;
183:
184: while(1) {
185: for(i=0;i<cfg.total_chans && i<MAX_OPTS;i++)
186: sprintf(opt[i],"%-25s",cfg.chan[i]->name);
187: opt[i][0]=0;
188: j=WIN_ACT|WIN_SAV|WIN_BOT|WIN_RHT;
189: uifc.savnum=0;
190: if(cfg.total_chans)
191: j|=WIN_DEL|WIN_GET;
192: if(cfg.total_chans<MAX_OPTS)
193: j|=WIN_INS|WIN_INSACT|WIN_XTR;
194: if(savchan.name[0])
195: j|=WIN_PUT;
196: SETHELP(WHERE);
197: /*
198: &Multinode Chat Channels:&
199:
200: This is a list of the configured multinode chat channels.
201:
202: To add a channel, select the desired location with the arrow keys and
203: hit INS .
204:
205: To delete a channel, select it with the arrow keys and hit DEL .
206:
207: To configure a channel, select it with the arrow keys and hit ENTER .
208: */
209: i=uifc.list(j,0,0,45,&chan_dflt,&chan_bar,"Multinode Chat Channels",opt);
210: if((signed)i==-1)
211: return;
212: if((i&MSK_ON)==MSK_INS) {
213: i&=MSK_OFF;
214: strcpy(str,"Open");
215: SETHELP(WHERE);
216: /*
217: &Channel Name:&
218:
219: This is the name or description of the chat channel.
220: */
221: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Chat Channel Name",str,25
222: ,K_EDIT)<1)
223: continue;
224: sprintf(code,"%.8s",str);
225: p=strchr(code,' ');
226: if(p) *p=0;
227: strupr(code);
228: SETHELP(WHERE);
229: /*
230: &Chat Channel Internal Code:&
231:
232: Every chat channel must have its own unique code for Synchronet to refer
233: to it internally. This code is usually an abreviation of the chat
234: channel name.
235: */
236: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Internal Code"
237: ,code,LEN_CODE,K_EDIT|K_UPPER)<1)
238: continue;
239: if(!code_ok(code)) {
240: uifc.helpbuf=invalid_code;
241: uifc.msg("Invalid Code");
242: uifc.helpbuf=0;
243: continue; }
244: if((cfg.chan=(chan_t **)REALLOC(cfg.chan,sizeof(chan_t *)*(cfg.total_chans+1)))
245: ==NULL) {
246: errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_chans+1);
247: cfg.total_chans=0;
248: bail(1);
249: continue; }
250: if(cfg.total_chans)
251: for(j=cfg.total_chans;j>i;j--)
252: cfg.chan[j]=cfg.chan[j-1];
253: if((cfg.chan[i]=(chan_t *)MALLOC(sizeof(chan_t)))==NULL) {
254: errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(chan_t));
255: continue; }
256: memset((chan_t *)cfg.chan[i],0,sizeof(chan_t));
257: strcpy(cfg.chan[i]->name,str);
258: strcpy(cfg.chan[i]->code,code);
259: cfg.total_chans++;
260: uifc.changes=1;
261: continue; }
262: if((i&MSK_ON)==MSK_DEL) {
263: i&=MSK_OFF;
264: FREE(cfg.chan[i]);
265: cfg.total_chans--;
266: for(j=i;j<cfg.total_chans;j++)
267: cfg.chan[j]=cfg.chan[j+1];
268: uifc.changes=1;
269: continue; }
270: if((i&MSK_ON)==MSK_GET) {
271: i&=MSK_OFF;
272: savchan=*cfg.chan[i];
273: continue; }
274: if((i&MSK_ON)==MSK_PUT) {
275: i&=MSK_OFF;
276: *cfg.chan[i]=savchan;
277: uifc.changes=1;
278: continue; }
279: j=0;
280: done=0;
281: while(!done) {
282: k=0;
283: sprintf(opt[k++],"%-27.27s%s","Name",cfg.chan[i]->name);
284: sprintf(opt[k++],"%-27.27s%s","Internal Code",cfg.chan[i]->code);
285: sprintf(opt[k++],"%-27.27s%lu","Cost in Credits",cfg.chan[i]->cost);
286: sprintf(opt[k++],"%-27.27s%.40s","Access Requirements"
287: ,cfg.chan[i]->arstr);
288: sprintf(opt[k++],"%-27.27s%s","Password Protection"
289: ,cfg.chan[i]->misc&CHAN_PW ? "Yes" : "No");
290: sprintf(opt[k++],"%-27.27s%s","Guru Joins When Empty"
291: ,cfg.chan[i]->misc&CHAN_GURU ? "Yes" : "No");
292: sprintf(opt[k++],"%-27.27s%s","Channel Guru"
293: ,cfg.chan[i]->guru<cfg.total_gurus ? cfg.guru[cfg.chan[i]->guru]->name : "");
294: sprintf(opt[k++],"%-27.27s%s","Channel Action Set"
295: ,cfg.actset[cfg.chan[i]->actset]->name);
296: opt[k][0]=0;
297: SETHELP(WHERE);
298: /*
299: &Chat Channel Configuration:&
300:
301: This menu is for configuring the selected chat channel.
302: */
303: uifc.savnum=1;
304: sprintf(str,"%s Chat Channel",cfg.chan[i]->name);
305: switch(uifc.list(WIN_ACT|WIN_MID|WIN_SAV,0,0,60,&opt_dflt,0,str,opt)) {
306: case -1:
307: done=1;
308: break;
309: case 0:
310: SETHELP(WHERE);
311: /*
312: &Chat Channel Name:&
313:
314: This is the name or description of the chat channel.
315: */
316: strcpy(str,cfg.chan[i]->name);
317: if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Chat Channel Name"
318: ,cfg.chan[i]->name,sizeof(cfg.chan[i]->name)-1,K_EDIT))
319: strcpy(cfg.chan[i]->name,str);
320: break;
321: case 1:
322: SETHELP(WHERE);
323: /*
324: &Chat Channel Internal Code:&
325:
326: Every chat channel must have its own unique code for Synchronet to refer
327: to it internally. This code is usually an abreviation of the chat
328: channel name.
329: */
330: strcpy(str,cfg.chan[i]->code);
331: if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Internal Code"
332: ,str,LEN_CODE,K_UPPER|K_EDIT))
333: break;
334: if(code_ok(str))
335: strcpy(cfg.chan[i]->code,str);
336: else {
337: uifc.helpbuf=invalid_code;
338: uifc.msg("Invalid Code");
339: uifc.helpbuf=0; }
340: break;
341: case 2:
342: ultoa(cfg.chan[i]->cost,str,10);
343: SETHELP(WHERE);
344: /*
345: &Chat Channel Cost to Join:&
346:
347: If you want users to be charged credits to join this chat channel, set
348: this value to the number of credits to charge. If you want this channel
349: to be free, set this value to &0&.
350: */
351: uifc.input(WIN_MID|WIN_SAV,0,0,"Cost to Join (in Credits)"
352: ,str,10,K_EDIT|K_NUMBER);
353: cfg.chan[i]->cost=atol(str);
354: break;
355: case 3:
356: uifc.savnum=2;
357: sprintf(str,"%s Chat Channel",cfg.chan[i]->name);
358: getar(str,cfg.chan[i]->arstr);
359: break;
360: case 4:
361: k=1;
362: strcpy(opt[0],"Yes");
363: strcpy(opt[1],"No");
364: opt[2][0]=0;
365: uifc.savnum=2;
366: SETHELP(WHERE);
367: /*
368: &Allow Channel to be Password Protected:&
369:
370: If you want to allow the first user to join this channel to password
371: protect it, set this option to &Yes&.
372: */
373: k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
374: ,"Allow Channel to be Password Protected"
375: ,opt);
376: if(!k && !(cfg.chan[i]->misc&CHAN_PW)) {
377: cfg.chan[i]->misc|=CHAN_PW;
378: uifc.changes=1; }
379: else if(k==1 && cfg.chan[i]->misc&CHAN_PW) {
380: cfg.chan[i]->misc&=~CHAN_PW;
381: uifc.changes=1; }
382: break;
383: case 5:
384: k=1;
385: strcpy(opt[0],"Yes");
386: strcpy(opt[1],"No");
387: opt[2][0]=0;
388: uifc.savnum=2;
389: SETHELP(WHERE);
390: /*
391: &Guru Joins This Channel When Empty:&
392:
393: If you want the system guru to join this chat channel when there is
394: only one user, set this option to &Yes&.
395: */
396: k=uifc.list(WIN_MID|WIN_SAV,0,0,0,&k,0
397: ,"Guru Joins This Channel When Empty"
398: ,opt);
399: if(!k && !(cfg.chan[i]->misc&CHAN_GURU)) {
400: cfg.chan[i]->misc|=CHAN_GURU;
401: uifc.changes=1; }
402: else if(k==1 && cfg.chan[i]->misc&CHAN_GURU) {
403: cfg.chan[i]->misc&=~CHAN_GURU;
404: uifc.changes=1; }
405: break;
406: case 6:
407: SETHELP(WHERE);
408: /*
409: &Channel Guru:&
410:
411: This is a list of available chat Gurus. Select the one that you wish
412: to have available in this channel.
413: */
414: k=0;
415: for(j=0;j<cfg.total_gurus && j<MAX_OPTS;j++)
416: sprintf(opt[j],"%-25s",cfg.guru[j]->name);
417: opt[j][0]=0;
418: uifc.savnum=2;
419: k=uifc.list(WIN_SAV|WIN_RHT,0,0,25,&j,0
420: ,"Available Chat Gurus",opt);
421: if(k==-1)
422: break;
423: cfg.chan[i]->guru=k;
424: break;
425: case 7:
426: SETHELP(WHERE);
427: /*
428: &Channel Action Set:&
429:
430: This is a list of available chat action sets. Select the one that you
431: wish to have available in this channel.
432: */
433: k=0;
434: for(j=0;j<cfg.total_actsets && j<MAX_OPTS;j++)
435: sprintf(opt[j],"%-25s",cfg.actset[j]->name);
436: opt[j][0]=0;
437: uifc.savnum=2;
438: k=uifc.list(WIN_SAV|WIN_RHT,0,0,25,&j,0
439: ,"Available Chat Action Sets",opt);
440: if(k==-1)
441: break;
442: uifc.changes=1;
443: cfg.chan[i]->actset=k;
444: break; } } }
445: }
446:
447: void chatact_cfg(uint setnum)
448: {
449: static int chatact_dflt,chatact_bar;
450: char str[128],cmd[128],out[128];
451: int j;
452: uint i,n,chatnum[MAX_OPTS+1];
453: static chatact_t savchatact;
454:
455: while(1) {
456: for(i=0,j=0;i<cfg.total_chatacts && j<MAX_OPTS;i++)
457: if(cfg.chatact[i]->actset==setnum) {
458: sprintf(opt[j],"%-*.*s %s",LEN_CHATACTCMD,LEN_CHATACTCMD
459: ,cfg.chatact[i]->cmd,cfg.chatact[i]->out);
460: chatnum[j++]=i; }
461: chatnum[j]=cfg.total_chatacts;
462: opt[j][0]=0;
463: uifc.savnum=2;
464: i=WIN_ACT|WIN_SAV;
465: if(j)
466: i|=WIN_DEL|WIN_GET;
467: if(j<MAX_OPTS)
468: i|=WIN_INS|WIN_INSACT|WIN_XTR;
469: if(savchatact.cmd[0])
470: i|=WIN_PUT;
471: SETHELP(WHERE);
472: /*
473: &Multinode Chat Actions:&
474:
475: This is a list of the configured multinode chat actions. The users can
476: use these actions in multinode chat by turning on action commands with
477: the &/A& command in multinode chat. Then if a line is typed which
478: begins with a valid &action command& and has a user name, chat handle,
479: or node number following, the output string will be displayed replacing
480: the &%s& symbols with the sending user's name and the receiving user's
481: name (in that order).
482:
483: To add an action, select the desired location with the arrow keys and
484: hit INS .
485:
486: To delete an action, select it with the arrow keys and hit DEL .
487:
488: To configure an action, select it with the arrow keys and hit ENTER .
489: */
490: sprintf(str,"%s Chat Actions",cfg.actset[setnum]->name);
491: i=uifc.list(i,0,0,70,&chatact_dflt,&chatact_bar,str,opt);
492: uifc.savnum=3;
493: if((signed)i==-1)
494: return;
495: if((i&MSK_ON)==MSK_INS) {
496: i&=MSK_OFF;
497: SETHELP(WHERE);
498: /*
499: &Chat Action Command:&
500:
501: This is the command word (normally a verb) to trigger the action output.
502: */
503: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Action Command",cmd,LEN_CHATACTCMD
504: ,K_UPPER)<1)
505: continue;
506: SETHELP(WHERE);
507: /*
508: &Chat Action Output String:&
509:
510: This is the output string displayed with this action output.
511: */
512: if(uifc.input(WIN_MID|WIN_SAV,0,0,"",out,LEN_CHATACTOUT
513: ,K_MSG)<1)
514: continue;
515: if((cfg.chatact=(chatact_t **)REALLOC(cfg.chatact
516: ,sizeof(chatact_t *)*(cfg.total_chatacts+1)))==NULL) {
517: errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_chatacts+1);
518: cfg.total_chatacts=0;
519: bail(1);
520: continue; }
521: if(j)
522: for(n=cfg.total_chatacts;n>chatnum[i];n--)
523: cfg.chatact[n]=cfg.chatact[n-1];
524: if((cfg.chatact[chatnum[i]]=(chatact_t *)MALLOC(sizeof(chatact_t)))==NULL) {
525: errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(chatact_t));
526: continue; }
527: memset((chatact_t *)cfg.chatact[chatnum[i]],0,sizeof(chatact_t));
528: strcpy(cfg.chatact[chatnum[i]]->cmd,cmd);
529: strcpy(cfg.chatact[chatnum[i]]->out,out);
530: cfg.chatact[chatnum[i]]->actset=setnum;
531: cfg.total_chatacts++;
532: uifc.changes=1;
533: continue; }
534: if((i&MSK_ON)==MSK_DEL) {
535: i&=MSK_OFF;
536: FREE(cfg.chatact[chatnum[i]]);
537: cfg.total_chatacts--;
538: for(j=chatnum[i];j<cfg.total_chatacts && j<MAX_OPTS;j++)
539: cfg.chatact[j]=cfg.chatact[j+1];
540: uifc.changes=1;
541: continue; }
542: if((i&MSK_ON)==MSK_GET) {
543: i&=MSK_OFF;
544: savchatact=*cfg.chatact[chatnum[i]];
545: continue; }
546: if((i&MSK_ON)==MSK_PUT) {
547: i&=MSK_OFF;
548: *cfg.chatact[chatnum[i]]=savchatact;
549: cfg.chatact[chatnum[i]]->actset=setnum;
550: uifc.changes=1;
551: continue; }
552: SETHELP(WHERE);
553: /*
554: &Chat Action Command:&
555:
556: This is the command that triggers this chat action.
557: */
558: strcpy(str,cfg.chatact[chatnum[i]]->cmd);
559: if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Chat Action Command"
560: ,cfg.chatact[chatnum[i]]->cmd,LEN_CHATACTCMD,K_EDIT|K_UPPER)) {
561: strcpy(cfg.chatact[chatnum[i]]->cmd,str);
562: continue; }
563: SETHELP(WHERE);
564: /*
565: &Chat Action Output String:&
566:
567: This is the output string that results from this chat action.
568: */
569: strcpy(str,cfg.chatact[chatnum[i]]->out);
570: if(!uifc.input(WIN_MID|WIN_SAV,0,10,""
571: ,cfg.chatact[chatnum[i]]->out,LEN_CHATACTOUT,K_EDIT|K_MSG))
572: strcpy(cfg.chatact[chatnum[i]]->out,str); }
573: }
574:
575: void guru_cfg()
576: {
577: static int guru_dflt,guru_bar,opt_dflt;
578: char str[81],code[9],done=0,*p;
579: int j,k;
580: uint i;
581: static guru_t savguru;
582:
583: while(1) {
584: for(i=0;i<cfg.total_gurus && i<MAX_OPTS;i++)
585: sprintf(opt[i],"%-25s",cfg.guru[i]->name);
586: opt[i][0]=0;
587: uifc.savnum=0;
588: j=WIN_ACT|WIN_SAV|WIN_RHT|WIN_BOT;
589: if(cfg.total_gurus)
590: j|=WIN_DEL|WIN_GET;
591: if(cfg.total_gurus<MAX_OPTS)
592: j|=WIN_INS|WIN_INSACT|WIN_XTR;
593: if(savguru.name[0])
594: j|=WIN_PUT;
595: SETHELP(WHERE);
596: /*
597: &Gurus:&
598:
599: This is a list of the configured Gurus.
600:
601: To add a Guru, select the desired location with the arrow keys and
602: hit INS .
603:
604: To delete a Guru, select it with the arrow keys and hit DEL .
605:
606: To configure a Guru, select it with the arrow keys and hit ENTER .
607: */
608: i=uifc.list(j,0,0,45,&guru_dflt,&guru_bar,"Artificial Gurus",opt);
609: if((signed)i==-1)
610: return;
611: if((i&MSK_ON)==MSK_INS) {
612: i&=MSK_OFF;
613: SETHELP(WHERE);
614: /*
615: &Guru Name:&
616:
617: This is the name of the selected Guru.
618: */
619: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Guru Name",str,25
620: ,0)<1)
621: continue;
622: sprintf(code,"%.8s",str);
623: p=strchr(code,' ');
624: if(p) *p=0;
625: strupr(code);
626: SETHELP(WHERE);
627: /*
628: &Guru Internal Code:&
629:
630: Every Guru must have its own unique code for Synchronet to refer to
631: it internally. This code is usually an abreviation of the Guru name.
632: */
633: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Internal Code"
634: ,code,LEN_CODE,K_EDIT|K_UPPER)<1)
635: continue;
636: if(!code_ok(code)) {
637: uifc.helpbuf=invalid_code;
638: uifc.msg("Invalid Code");
639: uifc.helpbuf=0;
640: continue; }
641: if((cfg.guru=(guru_t **)REALLOC(cfg.guru,sizeof(guru_t *)*(cfg.total_gurus+1)))
642: ==NULL) {
643: errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_gurus+1);
644: cfg.total_gurus=0;
645: bail(1);
646: continue; }
647: if(cfg.total_gurus)
648: for(j=cfg.total_gurus;j>i;j--)
649: cfg.guru[j]=cfg.guru[j-1];
650: if((cfg.guru[i]=(guru_t *)MALLOC(sizeof(guru_t)))==NULL) {
651: errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(guru_t));
652: continue; }
653: memset((guru_t *)cfg.guru[i],0,sizeof(guru_t));
654: strcpy(cfg.guru[i]->name,str);
655: strcpy(cfg.guru[i]->code,code);
656: cfg.total_gurus++;
657: uifc.changes=1;
658: continue; }
659: if((i&MSK_ON)==MSK_DEL) {
660: i&=MSK_OFF;
661: FREE(cfg.guru[i]);
662: cfg.total_gurus--;
663: for(j=i;j<cfg.total_gurus;j++)
664: cfg.guru[j]=cfg.guru[j+1];
665: uifc.changes=1;
666: continue; }
667: if((i&MSK_ON)==MSK_GET) {
668: i&=MSK_OFF;
669: savguru=*cfg.guru[i];
670: continue; }
671: if((i&MSK_ON)==MSK_PUT) {
672: i&=MSK_OFF;
673: *cfg.guru[i]=savguru;
674: uifc.changes=1;
675: continue; }
676: j=0;
677: done=0;
678: while(!done) {
679: k=0;
680: sprintf(opt[k++],"%-27.27s%s","Guru Name",cfg.guru[i]->name);
681: sprintf(opt[k++],"%-27.27s%s","Guru Internal Code",cfg.guru[i]->code);
682: sprintf(opt[k++],"%-27.27s%.40s","Access Requirements",cfg.guru[i]->arstr);
683: opt[k][0]=0;
684: uifc.savnum=1;
685: SETHELP(WHERE);
686: /*
687: &Guru Configuration:&
688:
689: This menu is for configuring the selected Guru.
690: */
691: switch(uifc.list(WIN_ACT|WIN_MID|WIN_SAV,0,0,60,&opt_dflt,0,cfg.guru[i]->name
692: ,opt)) {
693: case -1:
694: done=1;
695: break;
696: case 0:
697: SETHELP(WHERE);
698: /*
699: &Guru Name:&
700:
701: This is the name of the selected Guru.
702: */
703: strcpy(str,cfg.guru[i]->name);
704: if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Guru Name"
705: ,cfg.guru[i]->name,sizeof(cfg.guru[i]->name)-1,K_EDIT))
706: strcpy(cfg.guru[i]->name,str);
707: break;
708: case 1:
709: SETHELP(WHERE);
710: /*
711: &Guru Internal Code:&
712:
713: Every Guru must have its own unique code for Synchronet to refer to
714: it internally. This code is usually an abreviation of the Guru name.
715: */
716: strcpy(str,cfg.guru[i]->code);
717: if(!uifc.input(WIN_MID|WIN_SAV,0,0,"Guru Internal Code"
718: ,str,LEN_CODE,K_EDIT|K_UPPER))
719: break;
720: if(code_ok(str))
721: strcpy(cfg.guru[i]->code,str);
722: else {
723: uifc.helpbuf=invalid_code;
724: uifc.msg("Invalid Code");
725: uifc.helpbuf=0; }
726: break;
727: case 2:
728: uifc.savnum=2;
729: getar(cfg.guru[i]->name,cfg.guru[i]->arstr);
730: break; } } }
731: }
732:
733: void actsets_cfg()
734: {
735: static int actset_dflt,actset_bar,opt_dflt;
736: char str[81];
737: int j,k,done;
738: uint i;
739: static actset_t savactset;
740:
741: while(1) {
742: for(i=0;i<cfg.total_actsets && i<MAX_OPTS;i++)
743: sprintf(opt[i],"%-25s",cfg.actset[i]->name);
744: opt[i][0]=0;
745: j=WIN_ACT|WIN_RHT|WIN_BOT|WIN_SAV;
746: uifc.savnum=0;
747: if(cfg.total_actsets)
748: j|=WIN_DEL|WIN_GET;
749: if(cfg.total_actsets<MAX_OPTS)
750: j|=WIN_INS|WIN_INSACT|WIN_XTR;
751: if(savactset.name[0])
752: j|=WIN_PUT;
753: SETHELP(WHERE);
754: /*
755: &Chat Action Sets:&
756:
757: This is a list of the configured action sets.
758:
759: To add an action set, select the desired location with the arrow keys and
760: hit INS .
761:
762: To delete an action set, select it with the arrow keys and hit DEL .
763:
764: To configure an action set, select it with the arrow keys and hit
765: ENTER .
766: */
767: i=uifc.list(j,0,0,45,&actset_dflt,&actset_bar,"Chat Action Sets",opt);
768: if((signed)i==-1)
769: return;
770: if((i&MSK_ON)==MSK_INS) {
771: i&=MSK_OFF;
772: SETHELP(WHERE);
773: /*
774: &Chat Action Set Name:&
775:
776: This is the name of the selected chat action set.
777: */
778: if(uifc.input(WIN_MID|WIN_SAV,0,0,"Chat Action Set Name",str,25
779: ,0)<1)
780: continue;
781: if((cfg.actset=(actset_t **)REALLOC(cfg.actset,sizeof(actset_t *)*(cfg.total_actsets+1)))
782: ==NULL) {
783: errormsg(WHERE,ERR_ALLOC,nulstr,cfg.total_actsets+1);
784: cfg.total_actsets=0;
785: bail(1);
786: continue; }
787: if(cfg.total_actsets)
788: for(j=cfg.total_actsets;j>i;j--)
789: cfg.actset[j]=cfg.actset[j-1];
790: if((cfg.actset[i]=(actset_t *)MALLOC(sizeof(actset_t)))==NULL) {
791: errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(actset_t));
792: continue; }
793: memset((actset_t *)cfg.actset[i],0,sizeof(actset_t));
794: strcpy(cfg.actset[i]->name,str);
795: cfg.total_actsets++;
796: uifc.changes=1;
797: continue; }
798: if((i&MSK_ON)==MSK_DEL) {
799: i&=MSK_OFF;
800: FREE(cfg.actset[i]);
801: cfg.total_actsets--;
802: for(j=i;j<cfg.total_actsets;j++)
803: cfg.actset[j]=cfg.actset[j+1];
804: uifc.changes=1;
805: continue; }
806: if((i&MSK_ON)==MSK_GET) {
807: i&=MSK_OFF;
808: savactset=*cfg.actset[i];
809: continue; }
810: if((i&MSK_ON)==MSK_PUT) {
811: i&=MSK_OFF;
812: *cfg.actset[i]=savactset;
813: uifc.changes=1;
814: continue; }
815: j=0;
816: done=0;
817: while(!done) {
818: k=0;
819: sprintf(opt[k++],"%-27.27s%s","Action Set Name",cfg.actset[i]->name);
820: sprintf(opt[k++],"%-27.27s","Configure Chat Actions...");
821: opt[k][0]=0;
822: SETHELP(WHERE);
823: /*
824: &Chat Action Set Configuration:&
825:
826: This menu is for configuring the selected chat action set.
827: */
828: sprintf(str,"%s Chat Action Set",cfg.actset[i]->name);
829: uifc.savnum=1;
830: switch(uifc.list(WIN_ACT|WIN_MID|WIN_SAV,0,0,60,&opt_dflt,0,str
831: ,opt)) {
832: case -1:
833: done=1;
834: break;
835: case 0:
836: SETHELP(WHERE);
837: /*
838: &Chat Action Set Name:&
839:
840: This is the name of the selected action set.
841: */
842: strcpy(str,cfg.actset[i]->name);
843: if(!uifc.input(WIN_MID|WIN_SAV,0,10,"Action Set Name"
844: ,cfg.actset[i]->name,sizeof(cfg.actset[i]->name)-1,K_EDIT))
845: strcpy(cfg.actset[i]->name,str);
846: break;
847: case 1:
848: chatact_cfg(i);
849: break; } } }
850: }
851:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.