Annotation of coherent/g/usr/lib/uucp/uuinstall/add_sys.c, revision 1.1

1.1     ! root        1: /* add_sys.c: works just like add_port.c, see comments there. */
        !             2: 
        !             3: #include "uuinstall.h"
        !             4: 
        !             5: add_sys()
        !             6: {
        !             7:        char b;
        !             8:        FILE *sysfd;
        !             9: 
        !            10:        sys_template();
        !            11:        wrefresh(portwin);
        !            12: 
        !            13:        b = get_sys_data();
        !            14:        wclear(portwin);
        !            15:        wrefresh(portwin);
        !            16:        if (b == 'y'){
        !            17:                if( (sysfd = fopen(SYSFILE,"a")) == NULL){
        !            18:                        mvwaddstr(portwin,12,28,"Error opening sys file!");
        !            19:                        wrefresh(portwin);
        !            20:                        sleep(1);
        !            21:                        wclear(portwin);
        !            22:                        wrefresh(portwin);
        !            23:                        return;
        !            24:                }
        !            25:                        
        !            26:                wclear(portwin);
        !            27:                mvwaddstr(portwin,12,32,"Adding entry...");
        !            28:                wrefresh(portwin);
        !            29:                sleep(1);
        !            30: 
        !            31:                fprintf(sysfd,"\n%s\n",sysname);                                
        !            32:                fprintf(sysfd,"%s\n",systime);
        !            33:                fprintf(sysfd,"%s\n",sysspeed);
        !            34:                if (strlen(sysport) > 0)
        !            35:                        fprintf(sysfd,"%s\n",sysport);
        !            36:                if (strlen(sysphone) > 0)
        !            37:                        fprintf(sysfd,"%s\n",sysphone);
        !            38:                fprintf(sysfd,"%s\n",syschat);
        !            39:                if (strlen(sysmyname) > 0)
        !            40:                        fprintf(sysfd,"%s\n",sysmyname);
        !            41: 
        !            42:                fprintf(sysfd,"%s\n",sysprot);
        !            43:                fprintf(sysfd,"%s\n",syscmds);
        !            44:                fprintf(sysfd,"%s\n",sysread);
        !            45:                fprintf(sysfd,"%s\n",syswrite);
        !            46: 
        !            47:                fclose(sysfd);
        !            48:        }
        !            49:        wclear(portwin);
        !            50:        wrefresh(portwin);
        !            51: 
        !            52: }
        !            53: 
        !            54: /* sys_template(): draw a template for a sys file entry */
        !            55: 
        !            56: sys_template()
        !            57: {
        !            58:        mvwaddstr(portwin,3,1,"system: ");
        !            59:        mvwaddstr(portwin,4,1,"time: ");
        !            60:        mvwaddstr(portwin,5,1,"speed: ");
        !            61:        mvwaddstr(portwin,6,1,"port: ");
        !            62:        mvwaddstr(portwin,7,1,"phone: ");
        !            63:        mvwaddstr(portwin,8,1,"chat: ");
        !            64:        mvwaddstr(portwin,9,1,"myname: ");
        !            65:        mvwaddstr(portwin,10,1,"protocol: ");
        !            66:        mvwaddstr(portwin,11,1,"commands: ");
        !            67:        mvwaddstr(portwin,12,1,"read path: ");
        !            68:        mvwaddstr(portwin,13,1,"write path: ");
        !            69: 
        !            70:        wstandout(portwin);
        !            71:        mvwaddstr(portwin,0,29,"Sys File Entry Screen");
        !            72:        mvwaddstr(portwin,3,12,"        ");
        !            73:        mvwaddstr(portwin,4,12,"                                             ");
        !            74:        mvwaddstr(portwin,5,12,"     ");
        !            75:        mvwaddstr(portwin,6,12,"              ");
        !            76:        mvwaddstr(portwin,7,12,"                                             ");
        !            77:        mvwaddstr(portwin,8,12,"                                                       ");
        !            78:        mvwaddstr(portwin,9,12,"        ");
        !            79:        mvwaddstr(portwin,10,12,"    ");
        !            80:        mvwaddstr(portwin,11,12,"                                                       ");
        !            81:        mvwaddstr(portwin,12,12,"                                                       ");
        !            82:        mvwaddstr(portwin,13,12,"                                                       ");
        !            83:        wstandend(portwin);
        !            84:        wrefresh(portwin);
        !            85: }
        !            86: 
        !            87: 
        !            88: /* get_sys_data(): functions just like get_port_data(). See add_port.c */
        !            89: 
        !            90: get_sys_data()
        !            91: {
        !            92:        char *workstring;
        !            93:        char b;
        !            94:        /* initialize fields we will use */
        !            95: 
        !            96:        strcpy(sysname,"system "); 
        !            97:        strcpy(systime,"time ");
        !            98:        strcpy(sysspeed,"baud ");
        !            99:        strcpy(sysport,"port ");
        !           100:        strcpy(sysphone,"phone ");
        !           101:        strcpy(syschat,"chat ");
        !           102:        strcpy(sysmyname,"myname ");
        !           103:        strcpy(sysprot,"protocol ");
        !           104:        strcpy(syscmds,"commands ");
        !           105:        strcpy(sysread,"remote-send ");
        !           106:        strcpy(syswrite,"remote-receive ");
        !           107: 
        !           108:        /* get a remote system name */
        !           109:        mvwaddstr(portwin,20,0,"Enter the name of a remote uucp system. You should");
        !           110:        mvwaddstr(portwin,21,0,"limit the name to 8 characters.");
        !           111:        mvwaddstr(portwin,23,0,"Leaving this field blank aborts entry.");
        !           112:        wrefresh(portwin);
        !           113: 
        !           114:        workstring = get_data(portwin,3,12,8,0,0);
        !           115:        if (strlen(workstring) == 0)
        !           116:                return('n');
        !           117: 
        !           118:        strcat(sysname,workstring);
        !           119:        strcpy(workstring,"");
        !           120: 
        !           121:        /* get a time to call */
        !           122:        wmove(portwin,20,0);
        !           123:        wclrtobot(portwin);
        !           124: 
        !           125:        mvwaddstr(portwin,20,0,"Enter a range of times to call this sytem. Each range must be separated");
        !           126:        mvwaddstr(portwin,21,0,"a comma or semi-colon. Please refer to your manual for more information.");
        !           127:        mvwaddstr(portwin,23,0,"Examples:");
        !           128:        wstandout(portwin);
        !           129:        mvwaddstr(portwin,23,11,"Su0100-0200,Mo0400-1600");
        !           130:        mvwaddstr(portwin,23,35,"MoFr0300-0500");
        !           131:        mvwaddstr(portwin,23,49,"Any");
        !           132:        mvwaddstr(portwin,23,53,"Never");
        !           133:        wstandend(portwin);
        !           134:        wrefresh(portwin);
        !           135: 
        !           136:        workstring = get_data(portwin,4,12,45,0,0);
        !           137:        if (strlen(workstring) == 0)
        !           138:                strcpy(workstring,"Never");
        !           139:        strcat(systime,workstring);
        !           140:        strcpy(workstring,"");
        !           141: 
        !           142:        /* get the speed of the connection */
        !           143: 
        !           144:        do{
        !           145:                strcpy(workstring,"");
        !           146:                wmove(portwin,20,0);
        !           147:                wclrtobot(portwin);
        !           148:                mvwaddstr(portwin,20,0,"Enter the baud rate for communicating");
        !           149:                mvwaddstr(portwin,21,0,"this remote system.");
        !           150:                wrefresh(portwin);
        !           151:                workstring = get_data(portwin,5,12,5,1,0);
        !           152:        }
        !           153:        while(-1 == validate_speed(atoi(workstring)));
        !           154:        strcat(sysspeed,workstring);
        !           155:        strcpy(workstring,"");
        !           156: 
        !           157:        /* get the port that the call will be made on */
        !           158: 
        !           159:        wmove(portwin,20,0);
        !           160:        wclrtobot(portwin);
        !           161:        mvwaddstr(portwin,20,0,"Enter the name of the port (from the port file)");
        !           162:        mvwaddstr(portwin,21,0,"that this system will be called with.");
        !           163:        wrefresh(portwin);
        !           164:        workstring = get_data(portwin,6,12,14,0,1);
        !           165:        if (strlen(workstring) == 0)
        !           166:                strcpy(sysport,"");
        !           167:        else
        !           168:                strcat(sysport,workstring);
        !           169: 
        !           170: 
        !           171:        /* get the phone number, if any is required */
        !           172:        wmove(portwin,20,0);
        !           173:        wclrtobot(portwin);
        !           174:        mvwaddstr(portwin,20,0,"Enter the phone number to call this remote system with. If this is a direct");
        !           175:        mvwaddstr(portwin,21,0,"connection, then press return to leave this field blank.");
        !           176:        mvwaddstr(portwin,23,0,"Examples:");
        !           177:        wstandout(portwin);
        !           178:        mvwaddstr(portwin,23,11,"17085590412");
        !           179:        mvwaddstr(portwin,23,24,"9,5590412");
        !           180:        wrefresh(portwin);
        !           181:        workstring = get_data(portwin,7,12,45,0,0);
        !           182:        if (strlen(workstring) == 0)
        !           183:                strcpy(sysphone,"");
        !           184:        else
        !           185:                strcat(sysphone,workstring);
        !           186: 
        !           187:        strcpy(workstring,"");
        !           188: 
        !           189: 
        !           190:        /* now the killer, get the chat script. The killer isn't actually
        !           191:         * getting the script, it's the help info that's a bear.
        !           192:         */
        !           193: 
        !           194:        wmove(portwin,20,0);
        !           195:        wclrtobot(portwin);
        !           196:        mvwaddstr(portwin,15,0,"Enter the chat script used to log into the remote system. A chat script consists");
        !           197:        mvwaddstr(portwin,16,0,"of pairs of expect_msgs and send_msgs. These messages are separated by a space.");
        !           198:        mvwaddstr(portwin,17,0,"To represent a space within an expect_msg or send_msg, enter '\\s'.");
        !           199:        mvwaddstr(portwin,18,0,"Example:");
        !           200:        wstandout(portwin);
        !           201:        mvwaddstr(portwin,18,10,"\"\" in:--BREAK--in: mylogin word: mypassword");
        !           202:        wstandend(portwin);
        !           203:        mvwaddstr(portwin,19,0,"Example:");
        !           204:        wstandout(portwin);
        !           205:        mvwaddstr(portwin,19,10,"\"\" in:--in: nuucp word: public word: 123456789");
        !           206:        wstandend(portwin);
        !           207:        mvwaddstr(portwin,21,0,"Escape characters that may be used in a chat script:");
        !           208:        mvwaddstr(portwin,22,0,"\\b (backspace)  \\N (null)            \\s (space)  \\d (delay)  BREAK (break)");
        !           209:        mvwaddstr(portwin,23,0,"\\n (newline)    \\r(carriage return)  \\t (tab)    \\K (break)  EOT (control-d)");
        !           210:        wrefresh(portwin);
        !           211: 
        !           212:        workstring = get_data(portwin,8,12,55,1,0);
        !           213:        strcat(syschat,workstring);
        !           214:        strcpy(workstring,"");
        !           215: 
        !           216:        /* get a myname alias */
        !           217:        wmove(portwin,15,0);
        !           218:        wclrtobot(portwin);
        !           219:        mvwaddstr(portwin,20,0,"If you need to identify your system as something other than the contents of");
        !           220:        mvwaddstr(portwin,21,0,"/etc/uucpname when calling this remote system, enter that name here.");
        !           221:        mvwaddstr(portwin,23,0,"Enter nothing to ignore this field.");
        !           222:        wrefresh(portwin);
        !           223:        workstring = get_data(portwin,9,12,8,0,0);
        !           224:        if (strlen(workstring) == 0)
        !           225:                strcpy(sysmyname,"");
        !           226:        else
        !           227:                strcat(sysmyname,workstring);
        !           228: 
        !           229:        strcpy(workstring,"");
        !           230: 
        !           231:        /* get protocols */
        !           232: 
        !           233:        wmove(portwin,20,0);
        !           234:        wclrtobot(portwin);
        !           235:        mvwaddstr(portwin,15,0,"Taylor uucp supports various protocols which may or may not be supported by");
        !           236:        mvwaddstr(portwin,16,0,"the remote system being described. In part, these protocols are 'g', 'f' and");
        !           237:        mvwaddstr(portwin,17,0,"'i'. Please refer to your manual for more information on available protocols.");
        !           238:        mvwaddstr(portwin,18,0,"If uncertain about which protocol(s) to use, remember that the 'g' protocol is");
        !           239:        mvwaddstr(portwin,19,0,"the common protocol supported amoung the various flavors of uucp.");
        !           240:        mvwaddstr(portwin,20,0,"If nothing is entered in this field, 'g' protocol will be used by default.");
        !           241:        wrefresh(portwin);
        !           242: 
        !           243:        workstring = get_data(portwin,10,12,5,0,0);
        !           244:        if (strlen(workstring) == 0){
        !           245:                strcpy(workstring,"g");
        !           246:                wstandout(portwin);
        !           247:                mvwaddstr(portwin,10,12,"g");
        !           248:                wstandend(portwin);
        !           249:                wrefresh(portwin);
        !           250:        }
        !           251:        strcat(sysprot,workstring);
        !           252:        strcpy(workstring,"");
        !           253: 
        !           254:        /* get a list of commands */
        !           255: 
        !           256:        wmove(portwin,15,0);
        !           257:        wclrtobot(portwin);
        !           258:        mvwaddstr(portwin,15,0,"Specify a list of commands the remote system may execute on this system. If");
        !           259:        mvwaddstr(portwin,16,0,"you enter nothing, a default list will be used, consisting of rnews, rmail, uux");
        !           260:        mvwaddstr(portwin,17,0,"and uucp.");
        !           261:        wrefresh(portwin);
        !           262: 
        !           263:        workstring = get_data(portwin,11,12,55,0,0);
        !           264:        if (strlen(workstring) == 0){
        !           265:                strcpy(workstring,"rmail rnews uucp uux");
        !           266:                strcat(syscmds,"rmail rnews uucp uux");
        !           267:                wstandout(portwin);
        !           268:                mvwaddstr(portwin,11,12,workstring);
        !           269:                wstandend(portwin);
        !           270:                wrefresh(portwin);
        !           271:        }else{
        !           272:                strcat(syscmds,workstring);
        !           273:        }
        !           274:        strcpy(workstring,"");
        !           275: 
        !           276:        /* get a read pathlist */
        !           277:        wmove(portwin,15,0);
        !           278:        wclrtobot(portwin);
        !           279:        mvwaddstr(portwin,15,0,"Specify a list of directories that the remote system may download from. To");
        !           280:        mvwaddstr(portwin,16,0,"exclude a directory, precede the directory path with a '!'.");
        !           281:        mvwaddstr(portwin,17,0,"Example:");
        !           282:        wstandout(portwin);
        !           283:        mvwaddstr(portwin,17,11,"/usr/spool/uucppublic /tmp !/usr/spool/uucppublic/my_files");
        !           284:        wstandend(portwin);
        !           285:        mvwaddstr(portwin,19,0,"If nothing is entered, a default of /usr/spool/uucppublic will be used.");
        !           286:        wrefresh(portwin);
        !           287: 
        !           288:        workstring = get_data(portwin,12,12,55,0,0);
        !           289:        if (strlen(workstring) == 0){
        !           290:                strcpy(workstring,"/usr/spool/uucppublic");
        !           291:                strcat(sysread,"/usr/spool/uucppublic");
        !           292:                wstandout(portwin);
        !           293:                mvwaddstr(portwin,12,12,workstring);
        !           294:                wstandend(portwin);
        !           295:                wrefresh(portwin);
        !           296:        }else{
        !           297:                strcat(sysread,workstring);
        !           298:        }
        !           299:        strcpy(workstring,"");
        !           300: 
        !           301:        /* get a write path */
        !           302:        mvwaddstr(portwin,15,0,"Specify a list of directories that the remote system may send files to. To   ");
        !           303:        wrefresh(portwin);
        !           304:        workstring = get_data(portwin,13,12,55,0,0);
        !           305:        if (strlen(workstring) == 0){
        !           306:                strcpy(workstring,"/usr/spool/uucppublic");
        !           307:                strcat(syswrite,"/usr/spool/uucppublic");
        !           308:                wstandout(portwin);
        !           309:                mvwaddstr(portwin,13,12,workstring);
        !           310:                wstandend(portwin);
        !           311:                wrefresh(portwin);
        !           312:        }else{
        !           313:                strcat(syswrite,workstring);
        !           314:        }
        !           315: 
        !           316:        strcpy(workstring,"");
        !           317: 
        !           318:        wmove(portwin,15,0);
        !           319:        wclrtobot(portwin);
        !           320:        mvwaddstr(portwin,17,23,"Do you wish to save this entry? (y/n)");
        !           321:        wrefresh(portwin);
        !           322: 
        !           323:        do{
        !           324:                b = wgetch(portwin);
        !           325:        }
        !           326:        while ((b != 'n') && (b != 'y'));
        !           327: 
        !           328:        return(b);
        !           329: 
        !           330: }

unix.superglobalmegacorp.com

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