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