Annotation of sbbs/src/sbbs3/scfg/scfgchat.c, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.