1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1998 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #include "uucp.h" 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #include <unistd.h> 36*7c478bd9Sstevel@tonic-gate #include "sysfiles.h" 37*7c478bd9Sstevel@tonic-gate #include <sys/stropts.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate /* 40*7c478bd9Sstevel@tonic-gate * manage systems files (Systems, Devices, and Dialcodes families). 41*7c478bd9Sstevel@tonic-gate * 42*7c478bd9Sstevel@tonic-gate * also manage new file Devconfig, allows per-device setup. 43*7c478bd9Sstevel@tonic-gate * present use is to specify what streams modules to push/pop for 44*7c478bd9Sstevel@tonic-gate * AT&T TLI/streams network. 45*7c478bd9Sstevel@tonic-gate * 46*7c478bd9Sstevel@tonic-gate * TODO: 47*7c478bd9Sstevel@tonic-gate * call bsfix()? 48*7c478bd9Sstevel@tonic-gate * combine the 3 versions of everything (sys, dev, and dial) into one. 49*7c478bd9Sstevel@tonic-gate * allow arbitrary classes of service. 50*7c478bd9Sstevel@tonic-gate * need verifysys() for uucheck. 51*7c478bd9Sstevel@tonic-gate * nameserver interface? 52*7c478bd9Sstevel@tonic-gate * pass sysname (or 0) to getsysline(). (might want reg. exp. or NS processing 53*7c478bd9Sstevel@tonic-gate */ 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* private variables */ 56*7c478bd9Sstevel@tonic-gate static void tokenize(), nameparse(), setfile(), setioctl(), 57*7c478bd9Sstevel@tonic-gate scansys(), scancfg(), setconfig(); 58*7c478bd9Sstevel@tonic-gate static int namematch(), nextdialers(), nextdevices(), nextsystems(), getline(); 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* pointer arrays might be dynamically allocated */ 61*7c478bd9Sstevel@tonic-gate static char *Systems[64] = {0}; /* list of Systems files */ 62*7c478bd9Sstevel@tonic-gate static char *Devices[64] = {0}; /* list of Devices files */ 63*7c478bd9Sstevel@tonic-gate static char *Dialers[64] = {0}; /* list of Dialers files */ 64*7c478bd9Sstevel@tonic-gate static char *Pops[64] = {0}; /* list of STREAMS modules to be popped */ 65*7c478bd9Sstevel@tonic-gate static char *Pushes[64] = {0}; /* list of STREAMS modules to be pushed */ 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate static int nsystems; /* index into list of Systems files */ 68*7c478bd9Sstevel@tonic-gate static int ndevices; /* index into list of Devices files */ 69*7c478bd9Sstevel@tonic-gate static int ndialers; /* index into list of Dialers files */ 70*7c478bd9Sstevel@tonic-gate static int npops; /* index into list of STREAMS modules */ 71*7c478bd9Sstevel@tonic-gate /*to be popped */ 72*7c478bd9Sstevel@tonic-gate static int npushes; /* index into list of STREAMS modules */ 73*7c478bd9Sstevel@tonic-gate /*to be pushed */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate GLOBAL unsigned connecttime = CONNECTTIME; 76*7c478bd9Sstevel@tonic-gate GLOBAL unsigned expecttime = EXPECTTIME; 77*7c478bd9Sstevel@tonic-gate GLOBAL unsigned msgtime = MSGTIME; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate static FILE *fsystems; 80*7c478bd9Sstevel@tonic-gate static FILE *fdevices; 81*7c478bd9Sstevel@tonic-gate static FILE *fdialers; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate static char errformat[BUFSIZ]; 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate /* this might be dynamically allocated */ 86*7c478bd9Sstevel@tonic-gate #define NTOKENS 16 87*7c478bd9Sstevel@tonic-gate static char *tokens[NTOKENS], **tokptr; 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate /* export these */ 90*7c478bd9Sstevel@tonic-gate EXTERN void sysreset(), devreset(), dialreset(), setdevcfg(), setservice(); 91*7c478bd9Sstevel@tonic-gate EXTERN char *strsave(); 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate /* import these */ 94*7c478bd9Sstevel@tonic-gate extern char *strcpy(), *strtok(), *strchr(), *strsave(); 95*7c478bd9Sstevel@tonic-gate EXTERN int eaccess(); 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate /* 98*7c478bd9Sstevel@tonic-gate * setservice init's Systems, Devices, Dialers lists from Sysfiles 99*7c478bd9Sstevel@tonic-gate */ 100*7c478bd9Sstevel@tonic-gate GLOBAL void 101*7c478bd9Sstevel@tonic-gate setservice(service) 102*7c478bd9Sstevel@tonic-gate char *service; 103*7c478bd9Sstevel@tonic-gate { 104*7c478bd9Sstevel@tonic-gate char *prev = _uu_setlocale(LC_ALL, "C"); 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate setconfig(); 107*7c478bd9Sstevel@tonic-gate scansys(service); 108*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 109*7c478bd9Sstevel@tonic-gate return; 110*7c478bd9Sstevel@tonic-gate } 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate /* 113*7c478bd9Sstevel@tonic-gate * setdevcfg init's Pops, Pushes lists from Devconfig 114*7c478bd9Sstevel@tonic-gate */ 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate GLOBAL void 117*7c478bd9Sstevel@tonic-gate setdevcfg(service, device) 118*7c478bd9Sstevel@tonic-gate char *service, *device; 119*7c478bd9Sstevel@tonic-gate { 120*7c478bd9Sstevel@tonic-gate char *prev = _uu_setlocale(LC_ALL, "C"); 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate scancfg(service, device); 123*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 124*7c478bd9Sstevel@tonic-gate return; 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate /* administrative files access */ 128*7c478bd9Sstevel@tonic-gate GLOBAL int 129*7c478bd9Sstevel@tonic-gate sysaccess(type) 130*7c478bd9Sstevel@tonic-gate int type; 131*7c478bd9Sstevel@tonic-gate { 132*7c478bd9Sstevel@tonic-gate switch (type) { 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate case ACCESS_SYSTEMS: 135*7c478bd9Sstevel@tonic-gate return(access(Systems[nsystems], R_OK)); 136*7c478bd9Sstevel@tonic-gate case ACCESS_DEVICES: 137*7c478bd9Sstevel@tonic-gate return(access(Devices[ndevices], R_OK)); 138*7c478bd9Sstevel@tonic-gate case ACCESS_DIALERS: 139*7c478bd9Sstevel@tonic-gate return(access(Dialers[ndialers], R_OK)); 140*7c478bd9Sstevel@tonic-gate case EACCESS_SYSTEMS: 141*7c478bd9Sstevel@tonic-gate return(eaccess(Systems[nsystems], R_OK)); 142*7c478bd9Sstevel@tonic-gate case EACCESS_DEVICES: 143*7c478bd9Sstevel@tonic-gate return(eaccess(Devices[ndevices], R_OK)); 144*7c478bd9Sstevel@tonic-gate case EACCESS_DIALERS: 145*7c478bd9Sstevel@tonic-gate return(eaccess(Dialers[ndialers], R_OK)); 146*7c478bd9Sstevel@tonic-gate default: 147*7c478bd9Sstevel@tonic-gate (void)sprintf(errformat, "bad access type %d", type); 148*7c478bd9Sstevel@tonic-gate logent(errformat, "sysaccess"); 149*7c478bd9Sstevel@tonic-gate return(FAIL); 150*7c478bd9Sstevel@tonic-gate } 151*7c478bd9Sstevel@tonic-gate } 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * read Sysfiles, set up lists of Systems/Devices/Dialers file names. 156*7c478bd9Sstevel@tonic-gate * allow multiple entries for a given service, allow a service 157*7c478bd9Sstevel@tonic-gate * type to describe resources more than once, e.g., systems=foo:baz systems=bar. 158*7c478bd9Sstevel@tonic-gate */ 159*7c478bd9Sstevel@tonic-gate static void 160*7c478bd9Sstevel@tonic-gate scansys(service) 161*7c478bd9Sstevel@tonic-gate char *service; 162*7c478bd9Sstevel@tonic-gate { FILE *f; 163*7c478bd9Sstevel@tonic-gate char *tok, buf[BUFSIZ]; 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate Systems[0] = Devices[0] = Dialers[0] = NULL; 166*7c478bd9Sstevel@tonic-gate if ((f = fopen(SYSFILES, "r")) != 0) { 167*7c478bd9Sstevel@tonic-gate while (getline(f, buf) > 0) { 168*7c478bd9Sstevel@tonic-gate /* got a (logical) line from Sysfiles */ 169*7c478bd9Sstevel@tonic-gate /* strtok's of this buf continue in tokenize() */ 170*7c478bd9Sstevel@tonic-gate tok = strtok(buf, " \t"); 171*7c478bd9Sstevel@tonic-gate if (namematch("service=", tok, service)) { 172*7c478bd9Sstevel@tonic-gate tokenize(); 173*7c478bd9Sstevel@tonic-gate nameparse(); 174*7c478bd9Sstevel@tonic-gate } 175*7c478bd9Sstevel@tonic-gate } 176*7c478bd9Sstevel@tonic-gate (void) fclose(f); 177*7c478bd9Sstevel@tonic-gate } 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate /* if didn't find entries in Sysfiles, use defaults */ 180*7c478bd9Sstevel@tonic-gate if (Systems[0] == NULL) { 181*7c478bd9Sstevel@tonic-gate Systems[0] = strsave(SYSTEMS); 182*7c478bd9Sstevel@tonic-gate ASSERT(Systems[0] != NULL, Ct_ALLOCATE, "scansys: Systems", 0); 183*7c478bd9Sstevel@tonic-gate Systems[1] = NULL; 184*7c478bd9Sstevel@tonic-gate } 185*7c478bd9Sstevel@tonic-gate if (Devices[0] == NULL) { 186*7c478bd9Sstevel@tonic-gate Devices[0] = strsave(DEVICES); 187*7c478bd9Sstevel@tonic-gate ASSERT(Devices[0] != NULL, Ct_ALLOCATE, "scansys: Devices", 0); 188*7c478bd9Sstevel@tonic-gate Devices[1] = NULL; 189*7c478bd9Sstevel@tonic-gate } 190*7c478bd9Sstevel@tonic-gate if (Dialers[0] == NULL) { 191*7c478bd9Sstevel@tonic-gate Dialers[0] = strsave(DIALERS); 192*7c478bd9Sstevel@tonic-gate ASSERT(Dialers[0] != NULL, Ct_ALLOCATE, "scansys: Dialers", 0); 193*7c478bd9Sstevel@tonic-gate Dialers[1] = NULL; 194*7c478bd9Sstevel@tonic-gate } 195*7c478bd9Sstevel@tonic-gate return; 196*7c478bd9Sstevel@tonic-gate } 197*7c478bd9Sstevel@tonic-gate 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate /* 200*7c478bd9Sstevel@tonic-gate * read Devconfig. allow multiple entries for a given service, allow a service 201*7c478bd9Sstevel@tonic-gate * type to describe resources more than once, e.g., push=foo:baz push=bar. 202*7c478bd9Sstevel@tonic-gate */ 203*7c478bd9Sstevel@tonic-gate static void 204*7c478bd9Sstevel@tonic-gate scancfg(service, device) 205*7c478bd9Sstevel@tonic-gate char *service, *device; 206*7c478bd9Sstevel@tonic-gate { FILE *f; 207*7c478bd9Sstevel@tonic-gate char *tok, buf[BUFSIZ]; 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate /* (re)initialize device-specific information */ 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate npops = npushes = 0; 212*7c478bd9Sstevel@tonic-gate Pops[0] = Pushes[0] = NULL; 213*7c478bd9Sstevel@tonic-gate connecttime = CONNECTTIME; 214*7c478bd9Sstevel@tonic-gate expecttime = EXPECTTIME; 215*7c478bd9Sstevel@tonic-gate msgtime = MSGTIME; 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate if ((f = fopen(DEVCONFIG, "r")) != 0) { 218*7c478bd9Sstevel@tonic-gate while (getline(f, buf) > 0) { 219*7c478bd9Sstevel@tonic-gate /* got a (logical) line from Devconfig */ 220*7c478bd9Sstevel@tonic-gate /* strtok's of this buf continue in tokenize() */ 221*7c478bd9Sstevel@tonic-gate tok = strtok(buf, " \t"); 222*7c478bd9Sstevel@tonic-gate if (namematch("service=", tok, service)) { 223*7c478bd9Sstevel@tonic-gate tok = strtok((char *)0, " \t"); 224*7c478bd9Sstevel@tonic-gate if ( namematch("device=", tok, device)) { 225*7c478bd9Sstevel@tonic-gate tokenize(); 226*7c478bd9Sstevel@tonic-gate nameparse(); 227*7c478bd9Sstevel@tonic-gate } 228*7c478bd9Sstevel@tonic-gate } 229*7c478bd9Sstevel@tonic-gate } 230*7c478bd9Sstevel@tonic-gate (void) fclose(f); 231*7c478bd9Sstevel@tonic-gate } 232*7c478bd9Sstevel@tonic-gate 233*7c478bd9Sstevel@tonic-gate return; 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate } 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate /* 238*7c478bd9Sstevel@tonic-gate * given a file pointer and buffer, construct logical line in buffer 239*7c478bd9Sstevel@tonic-gate * (i.e., concatenate lines ending in '\'). return length of line 240*7c478bd9Sstevel@tonic-gate * ASSUMES that buffer is BUFSIZ long! 241*7c478bd9Sstevel@tonic-gate */ 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate static int 244*7c478bd9Sstevel@tonic-gate getline(f, line) 245*7c478bd9Sstevel@tonic-gate FILE *f; 246*7c478bd9Sstevel@tonic-gate char *line; 247*7c478bd9Sstevel@tonic-gate { char *lptr, *lend; 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate lptr = line; 250*7c478bd9Sstevel@tonic-gate while (fgets(lptr, (line + BUFSIZ) - lptr, f) != NULL) { 251*7c478bd9Sstevel@tonic-gate lend = lptr + strlen(lptr); 252*7c478bd9Sstevel@tonic-gate if (lend == lptr || lend[-1] != '\n') 253*7c478bd9Sstevel@tonic-gate /* empty buf or line too long! */ 254*7c478bd9Sstevel@tonic-gate break; 255*7c478bd9Sstevel@tonic-gate *--lend = '\0'; /* lop off ending '\n' */ 256*7c478bd9Sstevel@tonic-gate if ( lend == line ) /* empty line - ignore */ 257*7c478bd9Sstevel@tonic-gate continue; 258*7c478bd9Sstevel@tonic-gate lptr = lend; 259*7c478bd9Sstevel@tonic-gate if (lend[-1] != '\\') 260*7c478bd9Sstevel@tonic-gate break; 261*7c478bd9Sstevel@tonic-gate /* continuation */ 262*7c478bd9Sstevel@tonic-gate lend[-1] = ' '; 263*7c478bd9Sstevel@tonic-gate } 264*7c478bd9Sstevel@tonic-gate return(lptr - line); 265*7c478bd9Sstevel@tonic-gate } 266*7c478bd9Sstevel@tonic-gate 267*7c478bd9Sstevel@tonic-gate /* 268*7c478bd9Sstevel@tonic-gate * given a label (e.g., "service=", "device="), a name ("cu", "uucico"), 269*7c478bd9Sstevel@tonic-gate * and a line: if line begins with the label and if the name appears 270*7c478bd9Sstevel@tonic-gate * in a colon-separated list of names following the label, return true; 271*7c478bd9Sstevel@tonic-gate * else return false 272*7c478bd9Sstevel@tonic-gate */ 273*7c478bd9Sstevel@tonic-gate static int 274*7c478bd9Sstevel@tonic-gate namematch(label, line, name) 275*7c478bd9Sstevel@tonic-gate char *label, *line, *name; 276*7c478bd9Sstevel@tonic-gate { char *lend; 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate if (strncmp(label, line, strlen(label)) != SAME) { 279*7c478bd9Sstevel@tonic-gate return(FALSE); /* probably a comment line */ 280*7c478bd9Sstevel@tonic-gate } 281*7c478bd9Sstevel@tonic-gate line += strlen(label); 282*7c478bd9Sstevel@tonic-gate if (*line == '\0') 283*7c478bd9Sstevel@tonic-gate return(FALSE); 284*7c478bd9Sstevel@tonic-gate /* 285*7c478bd9Sstevel@tonic-gate * can't use strtok() in the following because scansys(), 286*7c478bd9Sstevel@tonic-gate * scancfg() do an initializing call to strtok() before 287*7c478bd9Sstevel@tonic-gate * coming here and then CONTINUE calling strtok() in tokenize(), 288*7c478bd9Sstevel@tonic-gate * after returning from namematch(). 289*7c478bd9Sstevel@tonic-gate */ 290*7c478bd9Sstevel@tonic-gate while ((lend = strchr(line, ':')) != NULL) { 291*7c478bd9Sstevel@tonic-gate *lend = '\0'; 292*7c478bd9Sstevel@tonic-gate if (strcmp(line, name) == SAME) 293*7c478bd9Sstevel@tonic-gate return(TRUE); 294*7c478bd9Sstevel@tonic-gate line = lend+1; 295*7c478bd9Sstevel@tonic-gate } 296*7c478bd9Sstevel@tonic-gate return(strcmp(line, name) == SAME); 297*7c478bd9Sstevel@tonic-gate } 298*7c478bd9Sstevel@tonic-gate 299*7c478bd9Sstevel@tonic-gate /* 300*7c478bd9Sstevel@tonic-gate * tokenize() continues pulling tokens out of a buffer -- the 301*7c478bd9Sstevel@tonic-gate * initializing call to strtok must have been made before calling 302*7c478bd9Sstevel@tonic-gate * tokenize() -- and starts stuffing 'em into tokptr. 303*7c478bd9Sstevel@tonic-gate */ 304*7c478bd9Sstevel@tonic-gate static void 305*7c478bd9Sstevel@tonic-gate tokenize() 306*7c478bd9Sstevel@tonic-gate { char *tok; 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate tokptr = tokens; 309*7c478bd9Sstevel@tonic-gate while ((tok = strtok((char *) NULL, " \t")) != NULL) { 310*7c478bd9Sstevel@tonic-gate *tokptr++ = tok; 311*7c478bd9Sstevel@tonic-gate if (tokptr - tokens >= NTOKENS) 312*7c478bd9Sstevel@tonic-gate break; 313*7c478bd9Sstevel@tonic-gate } 314*7c478bd9Sstevel@tonic-gate *tokptr = NULL; 315*7c478bd9Sstevel@tonic-gate return; 316*7c478bd9Sstevel@tonic-gate } 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate /* 319*7c478bd9Sstevel@tonic-gate * look at top token in array: should be line of the form 320*7c478bd9Sstevel@tonic-gate * name=item1:item2:item3... 321*7c478bd9Sstevel@tonic-gate * if name is one we recognize, then call set[file|ioctl] to set up 322*7c478bd9Sstevel@tonic-gate * corresponding list. otherwise, log bad name. 323*7c478bd9Sstevel@tonic-gate */ 324*7c478bd9Sstevel@tonic-gate static void 325*7c478bd9Sstevel@tonic-gate nameparse() 326*7c478bd9Sstevel@tonic-gate { char **line, *equals; 327*7c478bd9Sstevel@tonic-gate int temp; 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate #define setuint(a,b,c) a = ( ((temp = atoi(b)) <= 0) ? (c) : temp ) 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate for (line = tokens; (line - tokens) < NTOKENS && *line; line++) { 332*7c478bd9Sstevel@tonic-gate equals = strchr(*line, '='); 333*7c478bd9Sstevel@tonic-gate if (equals == NULL) 334*7c478bd9Sstevel@tonic-gate continue; /* may be meaningful someday? */ 335*7c478bd9Sstevel@tonic-gate *equals = '\0'; 336*7c478bd9Sstevel@tonic-gate /* ignore entry with empty rhs */ 337*7c478bd9Sstevel@tonic-gate if (*++equals == '\0') 338*7c478bd9Sstevel@tonic-gate continue; 339*7c478bd9Sstevel@tonic-gate if (strcmp(*line, "systems") == SAME) 340*7c478bd9Sstevel@tonic-gate setfile(Systems, equals); 341*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "devices") == SAME) 342*7c478bd9Sstevel@tonic-gate setfile(Devices, equals); 343*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "dialers") == SAME) 344*7c478bd9Sstevel@tonic-gate setfile(Dialers, equals); 345*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "pop") == SAME) 346*7c478bd9Sstevel@tonic-gate setioctl(Pops, equals); 347*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "push") == SAME) 348*7c478bd9Sstevel@tonic-gate setioctl(Pushes, equals); 349*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "connecttime") == SAME) 350*7c478bd9Sstevel@tonic-gate setuint(connecttime, equals, CONNECTTIME); 351*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "expecttime") == SAME) 352*7c478bd9Sstevel@tonic-gate setuint(expecttime, equals, EXPECTTIME); 353*7c478bd9Sstevel@tonic-gate else if (strcmp(*line, "msgtime") == SAME) 354*7c478bd9Sstevel@tonic-gate setuint(msgtime, equals, MSGTIME); 355*7c478bd9Sstevel@tonic-gate else { 356*7c478bd9Sstevel@tonic-gate (void)sprintf(errformat,"unrecognized label %s",*line); 357*7c478bd9Sstevel@tonic-gate logent(errformat, "Sysfiles|Devconfig"); 358*7c478bd9Sstevel@tonic-gate } 359*7c478bd9Sstevel@tonic-gate } 360*7c478bd9Sstevel@tonic-gate return; 361*7c478bd9Sstevel@tonic-gate } 362*7c478bd9Sstevel@tonic-gate 363*7c478bd9Sstevel@tonic-gate /* 364*7c478bd9Sstevel@tonic-gate * given the list for a particular type (systems, devices,...) 365*7c478bd9Sstevel@tonic-gate * and a line of colon-separated files, add 'em to list 366*7c478bd9Sstevel@tonic-gate */ 367*7c478bd9Sstevel@tonic-gate 368*7c478bd9Sstevel@tonic-gate static void 369*7c478bd9Sstevel@tonic-gate setfile(type, line) 370*7c478bd9Sstevel@tonic-gate char **type, *line; 371*7c478bd9Sstevel@tonic-gate { char **tptr, *tok; 372*7c478bd9Sstevel@tonic-gate char expandpath[BUFSIZ]; 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate if (*line == 0) 375*7c478bd9Sstevel@tonic-gate return; 376*7c478bd9Sstevel@tonic-gate tptr = type; 377*7c478bd9Sstevel@tonic-gate while (*tptr) /* skip over existing entries to*/ 378*7c478bd9Sstevel@tonic-gate tptr++; /* concatenate multiple entries */ 379*7c478bd9Sstevel@tonic-gate 380*7c478bd9Sstevel@tonic-gate for (tok = strtok(line, ":"); tok != NULL; 381*7c478bd9Sstevel@tonic-gate tok = strtok((char *) NULL, ":")) { 382*7c478bd9Sstevel@tonic-gate expandpath[0] = '\0'; 383*7c478bd9Sstevel@tonic-gate if ( *tok != '/' ) 384*7c478bd9Sstevel@tonic-gate /* by default, file names are relative to SYSDIR */ 385*7c478bd9Sstevel@tonic-gate sprintf(expandpath, "%s/", SYSDIR); 386*7c478bd9Sstevel@tonic-gate strcat(expandpath, tok); 387*7c478bd9Sstevel@tonic-gate if (eaccess(expandpath, R_OK) != 0) 388*7c478bd9Sstevel@tonic-gate /* if we can't read it, no point in adding to list */ 389*7c478bd9Sstevel@tonic-gate continue; 390*7c478bd9Sstevel@tonic-gate *tptr = strsave(expandpath); 391*7c478bd9Sstevel@tonic-gate ASSERT(*tptr != NULL, Ct_ALLOCATE, "setfile: tptr", 0); 392*7c478bd9Sstevel@tonic-gate tptr++; 393*7c478bd9Sstevel@tonic-gate } 394*7c478bd9Sstevel@tonic-gate return; 395*7c478bd9Sstevel@tonic-gate } 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate /* 398*7c478bd9Sstevel@tonic-gate * given the list for a particular ioctl (push, pop) 399*7c478bd9Sstevel@tonic-gate * and a line of colon-separated modules, add 'em to list 400*7c478bd9Sstevel@tonic-gate */ 401*7c478bd9Sstevel@tonic-gate 402*7c478bd9Sstevel@tonic-gate static void 403*7c478bd9Sstevel@tonic-gate setioctl(type, line) 404*7c478bd9Sstevel@tonic-gate char **type, *line; 405*7c478bd9Sstevel@tonic-gate { char **tptr, *tok; 406*7c478bd9Sstevel@tonic-gate 407*7c478bd9Sstevel@tonic-gate if (*line == 0) 408*7c478bd9Sstevel@tonic-gate return; 409*7c478bd9Sstevel@tonic-gate tptr = type; 410*7c478bd9Sstevel@tonic-gate while (*tptr) /* skip over existing entries to*/ 411*7c478bd9Sstevel@tonic-gate tptr++; /* concatenate multiple entries */ 412*7c478bd9Sstevel@tonic-gate for (tok = strtok(line, ":"); tok != NULL; 413*7c478bd9Sstevel@tonic-gate tok = strtok((char *) NULL, ":")) { 414*7c478bd9Sstevel@tonic-gate *tptr = strsave(tok); 415*7c478bd9Sstevel@tonic-gate ASSERT(*tptr != NULL, Ct_ALLOCATE, "setioctl: tptr", 0); 416*7c478bd9Sstevel@tonic-gate tptr++; 417*7c478bd9Sstevel@tonic-gate } 418*7c478bd9Sstevel@tonic-gate return; 419*7c478bd9Sstevel@tonic-gate } 420*7c478bd9Sstevel@tonic-gate 421*7c478bd9Sstevel@tonic-gate /* 422*7c478bd9Sstevel@tonic-gate * reset Systems files 423*7c478bd9Sstevel@tonic-gate */ 424*7c478bd9Sstevel@tonic-gate GLOBAL void 425*7c478bd9Sstevel@tonic-gate sysreset() 426*7c478bd9Sstevel@tonic-gate { 427*7c478bd9Sstevel@tonic-gate if (fsystems) 428*7c478bd9Sstevel@tonic-gate fclose(fsystems); 429*7c478bd9Sstevel@tonic-gate fsystems = NULL; 430*7c478bd9Sstevel@tonic-gate nsystems = 0; 431*7c478bd9Sstevel@tonic-gate devreset(); 432*7c478bd9Sstevel@tonic-gate return; 433*7c478bd9Sstevel@tonic-gate } 434*7c478bd9Sstevel@tonic-gate 435*7c478bd9Sstevel@tonic-gate /* 436*7c478bd9Sstevel@tonic-gate * reset Devices files 437*7c478bd9Sstevel@tonic-gate */ 438*7c478bd9Sstevel@tonic-gate GLOBAL void 439*7c478bd9Sstevel@tonic-gate devreset() 440*7c478bd9Sstevel@tonic-gate { 441*7c478bd9Sstevel@tonic-gate if (fdevices) 442*7c478bd9Sstevel@tonic-gate fclose(fdevices); 443*7c478bd9Sstevel@tonic-gate fdevices = NULL; 444*7c478bd9Sstevel@tonic-gate ndevices = 0; 445*7c478bd9Sstevel@tonic-gate dialreset(); 446*7c478bd9Sstevel@tonic-gate return; 447*7c478bd9Sstevel@tonic-gate } 448*7c478bd9Sstevel@tonic-gate 449*7c478bd9Sstevel@tonic-gate /* 450*7c478bd9Sstevel@tonic-gate * reset Dialers files 451*7c478bd9Sstevel@tonic-gate */ 452*7c478bd9Sstevel@tonic-gate GLOBAL void 453*7c478bd9Sstevel@tonic-gate dialreset() 454*7c478bd9Sstevel@tonic-gate { 455*7c478bd9Sstevel@tonic-gate if (fdialers) 456*7c478bd9Sstevel@tonic-gate fclose(fdialers); 457*7c478bd9Sstevel@tonic-gate fdialers = NULL; 458*7c478bd9Sstevel@tonic-gate ndialers = 0; 459*7c478bd9Sstevel@tonic-gate return; 460*7c478bd9Sstevel@tonic-gate } 461*7c478bd9Sstevel@tonic-gate 462*7c478bd9Sstevel@tonic-gate /* 463*7c478bd9Sstevel@tonic-gate * get next line from Systems file 464*7c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 465*7c478bd9Sstevel@tonic-gate */ 466*7c478bd9Sstevel@tonic-gate GLOBAL int 467*7c478bd9Sstevel@tonic-gate getsysline(buf, len) 468*7c478bd9Sstevel@tonic-gate char *buf; 469*7c478bd9Sstevel@tonic-gate { 470*7c478bd9Sstevel@tonic-gate char *prev = _uu_setlocale(LC_ALL, "C"); 471*7c478bd9Sstevel@tonic-gate 472*7c478bd9Sstevel@tonic-gate if (Systems[0] == NULL) 473*7c478bd9Sstevel@tonic-gate /* not initialized via setservice() - use default */ 474*7c478bd9Sstevel@tonic-gate setservice("uucico"); 475*7c478bd9Sstevel@tonic-gate 476*7c478bd9Sstevel@tonic-gate /* initialize devices and dialers whenever a new line is read */ 477*7c478bd9Sstevel@tonic-gate /* from systems */ 478*7c478bd9Sstevel@tonic-gate devreset(); 479*7c478bd9Sstevel@tonic-gate if (fsystems == NULL) 480*7c478bd9Sstevel@tonic-gate if (nextsystems() == FALSE) { 481*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 482*7c478bd9Sstevel@tonic-gate return(FALSE); 483*7c478bd9Sstevel@tonic-gate } 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate ASSERT(len >= BUFSIZ, "BUFFER TOO SMALL", "getsysline", 0); 486*7c478bd9Sstevel@tonic-gate for(;;) { 487*7c478bd9Sstevel@tonic-gate while (getline(fsystems, buf) != NULL) 488*7c478bd9Sstevel@tonic-gate if ((*buf != '#') && (*buf != ' ') && 489*7c478bd9Sstevel@tonic-gate (*buf != '\t') && (*buf != '\n')) { 490*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 491*7c478bd9Sstevel@tonic-gate return(TRUE); 492*7c478bd9Sstevel@tonic-gate } 493*7c478bd9Sstevel@tonic-gate if (nextsystems() == FALSE) { 494*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 495*7c478bd9Sstevel@tonic-gate return(FALSE); 496*7c478bd9Sstevel@tonic-gate } 497*7c478bd9Sstevel@tonic-gate } 498*7c478bd9Sstevel@tonic-gate } 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate /* 501*7c478bd9Sstevel@tonic-gate * move to next systems file. return TRUE if successful, FALSE if not 502*7c478bd9Sstevel@tonic-gate */ 503*7c478bd9Sstevel@tonic-gate static int 504*7c478bd9Sstevel@tonic-gate nextsystems() 505*7c478bd9Sstevel@tonic-gate { 506*7c478bd9Sstevel@tonic-gate devreset(); 507*7c478bd9Sstevel@tonic-gate 508*7c478bd9Sstevel@tonic-gate if (fsystems != NULL) { 509*7c478bd9Sstevel@tonic-gate (void) fclose(fsystems); 510*7c478bd9Sstevel@tonic-gate nsystems++; 511*7c478bd9Sstevel@tonic-gate } else { 512*7c478bd9Sstevel@tonic-gate nsystems = 0; 513*7c478bd9Sstevel@tonic-gate } 514*7c478bd9Sstevel@tonic-gate for ( ; Systems[nsystems] != NULL; nsystems++) 515*7c478bd9Sstevel@tonic-gate if ((fsystems = fopen(Systems[nsystems], "r")) != NULL) 516*7c478bd9Sstevel@tonic-gate return(TRUE); 517*7c478bd9Sstevel@tonic-gate return(FALSE); 518*7c478bd9Sstevel@tonic-gate } 519*7c478bd9Sstevel@tonic-gate 520*7c478bd9Sstevel@tonic-gate /* 521*7c478bd9Sstevel@tonic-gate * get next line from Devices file 522*7c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 523*7c478bd9Sstevel@tonic-gate */ 524*7c478bd9Sstevel@tonic-gate GLOBAL int 525*7c478bd9Sstevel@tonic-gate getdevline(buf, len) 526*7c478bd9Sstevel@tonic-gate char *buf; 527*7c478bd9Sstevel@tonic-gate { 528*7c478bd9Sstevel@tonic-gate char *prev = _uu_setlocale(LC_ALL, "C"); 529*7c478bd9Sstevel@tonic-gate 530*7c478bd9Sstevel@tonic-gate if (Devices[0] == NULL) 531*7c478bd9Sstevel@tonic-gate /* not initialized via setservice() - use default */ 532*7c478bd9Sstevel@tonic-gate setservice("uucico"); 533*7c478bd9Sstevel@tonic-gate 534*7c478bd9Sstevel@tonic-gate if (fdevices == NULL) 535*7c478bd9Sstevel@tonic-gate if (nextdevices() == FALSE) { 536*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 537*7c478bd9Sstevel@tonic-gate return(FALSE); 538*7c478bd9Sstevel@tonic-gate } 539*7c478bd9Sstevel@tonic-gate for(;;) { 540*7c478bd9Sstevel@tonic-gate if (fgets(buf, len, fdevices) != NULL) { 541*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 542*7c478bd9Sstevel@tonic-gate return(TRUE); 543*7c478bd9Sstevel@tonic-gate } 544*7c478bd9Sstevel@tonic-gate if (nextdevices() == FALSE) { 545*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 546*7c478bd9Sstevel@tonic-gate return(FALSE); 547*7c478bd9Sstevel@tonic-gate } 548*7c478bd9Sstevel@tonic-gate } 549*7c478bd9Sstevel@tonic-gate } 550*7c478bd9Sstevel@tonic-gate 551*7c478bd9Sstevel@tonic-gate /* 552*7c478bd9Sstevel@tonic-gate * move to next devices file. return TRUE if successful, FALSE if not 553*7c478bd9Sstevel@tonic-gate */ 554*7c478bd9Sstevel@tonic-gate static int 555*7c478bd9Sstevel@tonic-gate nextdevices() 556*7c478bd9Sstevel@tonic-gate { 557*7c478bd9Sstevel@tonic-gate if (fdevices != NULL) { 558*7c478bd9Sstevel@tonic-gate (void) fclose(fdevices); 559*7c478bd9Sstevel@tonic-gate ndevices++; 560*7c478bd9Sstevel@tonic-gate } else { 561*7c478bd9Sstevel@tonic-gate ndevices = 0; 562*7c478bd9Sstevel@tonic-gate } 563*7c478bd9Sstevel@tonic-gate for ( ; Devices[ndevices] != NULL; ndevices++) 564*7c478bd9Sstevel@tonic-gate if ((fdevices = fopen(Devices[ndevices], "r")) != NULL) 565*7c478bd9Sstevel@tonic-gate return(TRUE); 566*7c478bd9Sstevel@tonic-gate return(FALSE); 567*7c478bd9Sstevel@tonic-gate } 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate 570*7c478bd9Sstevel@tonic-gate /* 571*7c478bd9Sstevel@tonic-gate * get next line from Dialers file 572*7c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 573*7c478bd9Sstevel@tonic-gate */ 574*7c478bd9Sstevel@tonic-gate 575*7c478bd9Sstevel@tonic-gate GLOBAL int 576*7c478bd9Sstevel@tonic-gate getdialline(buf, len) 577*7c478bd9Sstevel@tonic-gate char *buf; 578*7c478bd9Sstevel@tonic-gate { 579*7c478bd9Sstevel@tonic-gate char *prev = _uu_setlocale(LC_ALL, "C"); 580*7c478bd9Sstevel@tonic-gate 581*7c478bd9Sstevel@tonic-gate if (Dialers[0] == NULL) 582*7c478bd9Sstevel@tonic-gate /* not initialized via setservice() - use default */ 583*7c478bd9Sstevel@tonic-gate setservice("uucico"); 584*7c478bd9Sstevel@tonic-gate 585*7c478bd9Sstevel@tonic-gate if (fdialers == NULL) 586*7c478bd9Sstevel@tonic-gate if (nextdialers() == FALSE) { 587*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 588*7c478bd9Sstevel@tonic-gate return(FALSE); 589*7c478bd9Sstevel@tonic-gate } 590*7c478bd9Sstevel@tonic-gate for(;;) { 591*7c478bd9Sstevel@tonic-gate if (fgets(buf, len, fdialers) != NULL) { 592*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 593*7c478bd9Sstevel@tonic-gate return(TRUE); 594*7c478bd9Sstevel@tonic-gate } 595*7c478bd9Sstevel@tonic-gate if (nextdialers() == FALSE) { 596*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 597*7c478bd9Sstevel@tonic-gate return(FALSE); 598*7c478bd9Sstevel@tonic-gate } 599*7c478bd9Sstevel@tonic-gate } 600*7c478bd9Sstevel@tonic-gate } 601*7c478bd9Sstevel@tonic-gate 602*7c478bd9Sstevel@tonic-gate /* 603*7c478bd9Sstevel@tonic-gate * move to next dialers file. return TRUE if successful, FALSE if not 604*7c478bd9Sstevel@tonic-gate */ 605*7c478bd9Sstevel@tonic-gate static int 606*7c478bd9Sstevel@tonic-gate nextdialers() 607*7c478bd9Sstevel@tonic-gate { 608*7c478bd9Sstevel@tonic-gate if (fdialers) { 609*7c478bd9Sstevel@tonic-gate (void) fclose(fdialers); 610*7c478bd9Sstevel@tonic-gate ndialers++; 611*7c478bd9Sstevel@tonic-gate } else { 612*7c478bd9Sstevel@tonic-gate ndialers = 0; 613*7c478bd9Sstevel@tonic-gate } 614*7c478bd9Sstevel@tonic-gate 615*7c478bd9Sstevel@tonic-gate for ( ; Dialers[ndialers] != NULL; ndialers++) 616*7c478bd9Sstevel@tonic-gate if ((fdialers = fopen(Dialers[ndialers], "r")) != NULL) 617*7c478bd9Sstevel@tonic-gate return(TRUE); 618*7c478bd9Sstevel@tonic-gate return(FALSE); 619*7c478bd9Sstevel@tonic-gate } 620*7c478bd9Sstevel@tonic-gate 621*7c478bd9Sstevel@tonic-gate /* 622*7c478bd9Sstevel@tonic-gate * get next module to be popped 623*7c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 624*7c478bd9Sstevel@tonic-gate */ 625*7c478bd9Sstevel@tonic-gate static int 626*7c478bd9Sstevel@tonic-gate getpop(buf, len, optional) 627*7c478bd9Sstevel@tonic-gate char *buf; 628*7c478bd9Sstevel@tonic-gate int len, *optional; 629*7c478bd9Sstevel@tonic-gate { 630*7c478bd9Sstevel@tonic-gate int slen; 631*7c478bd9Sstevel@tonic-gate 632*7c478bd9Sstevel@tonic-gate if ( Pops[0] == NULL || Pops[npops] == NULL ) 633*7c478bd9Sstevel@tonic-gate return(FALSE); 634*7c478bd9Sstevel@tonic-gate 635*7c478bd9Sstevel@tonic-gate /* if the module name is enclosed in parentheses, */ 636*7c478bd9Sstevel@tonic-gate /* is optional. set flag & strip parens */ 637*7c478bd9Sstevel@tonic-gate slen = strlen(Pops[npops]) - 1; 638*7c478bd9Sstevel@tonic-gate if ( Pops[npops][0] == '(' && Pops[npops][slen] == ')' ) { 639*7c478bd9Sstevel@tonic-gate *optional = 1; 640*7c478bd9Sstevel@tonic-gate len = ( slen < len ? slen : len ); 641*7c478bd9Sstevel@tonic-gate strncpy(buf, &(Pops[npops++][1]), len); 642*7c478bd9Sstevel@tonic-gate } else { 643*7c478bd9Sstevel@tonic-gate *optional = 0; 644*7c478bd9Sstevel@tonic-gate strncpy(buf, Pops[npops++], len); 645*7c478bd9Sstevel@tonic-gate } 646*7c478bd9Sstevel@tonic-gate buf[len-1] = '\0'; 647*7c478bd9Sstevel@tonic-gate return(TRUE); 648*7c478bd9Sstevel@tonic-gate } 649*7c478bd9Sstevel@tonic-gate 650*7c478bd9Sstevel@tonic-gate /* 651*7c478bd9Sstevel@tonic-gate * get next module to be pushed 652*7c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 653*7c478bd9Sstevel@tonic-gate */ 654*7c478bd9Sstevel@tonic-gate static int 655*7c478bd9Sstevel@tonic-gate getpush(buf, len) 656*7c478bd9Sstevel@tonic-gate char *buf; 657*7c478bd9Sstevel@tonic-gate int len; 658*7c478bd9Sstevel@tonic-gate { 659*7c478bd9Sstevel@tonic-gate if ( Pushes[0] == NULL || Pushes[npushes] == NULL ) 660*7c478bd9Sstevel@tonic-gate return(FALSE); 661*7c478bd9Sstevel@tonic-gate strncpy(buf, Pushes[npushes++], len); 662*7c478bd9Sstevel@tonic-gate return(TRUE); 663*7c478bd9Sstevel@tonic-gate } 664*7c478bd9Sstevel@tonic-gate 665*7c478bd9Sstevel@tonic-gate /* 666*7c478bd9Sstevel@tonic-gate * pop/push requested modules 667*7c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 668*7c478bd9Sstevel@tonic-gate */ 669*7c478bd9Sstevel@tonic-gate GLOBAL int 670*7c478bd9Sstevel@tonic-gate pop_push(fd) 671*7c478bd9Sstevel@tonic-gate int fd; 672*7c478bd9Sstevel@tonic-gate { 673*7c478bd9Sstevel@tonic-gate char strmod[FMNAMESZ], onstream[FMNAMESZ]; 674*7c478bd9Sstevel@tonic-gate int optional; 675*7c478bd9Sstevel@tonic-gate char *prev = _uu_setlocale(LC_ALL, "C"); 676*7c478bd9Sstevel@tonic-gate 677*7c478bd9Sstevel@tonic-gate /* check for streams modules to pop */ 678*7c478bd9Sstevel@tonic-gate while ( getpop(strmod, sizeof(strmod), &optional) ) { 679*7c478bd9Sstevel@tonic-gate DEBUG(5, (optional ? "pop_push: optionally POPing %s\n" 680*7c478bd9Sstevel@tonic-gate : "pop_push: POPing %s\n" ), strmod); 681*7c478bd9Sstevel@tonic-gate if ( ioctl(fd, I_LOOK, onstream) == -1 ) { 682*7c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_LOOK on fd %d failed ", fd); 683*7c478bd9Sstevel@tonic-gate DEBUG(5, "errno %d\n", errno); 684*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 685*7c478bd9Sstevel@tonic-gate return(FALSE); 686*7c478bd9Sstevel@tonic-gate } 687*7c478bd9Sstevel@tonic-gate if ( strcmp(strmod, onstream) != SAME ) { 688*7c478bd9Sstevel@tonic-gate if ( optional ) 689*7c478bd9Sstevel@tonic-gate continue; 690*7c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_POP: %s not there\n", strmod); 691*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 692*7c478bd9Sstevel@tonic-gate return(FALSE); 693*7c478bd9Sstevel@tonic-gate } 694*7c478bd9Sstevel@tonic-gate if ( ioctl(fd, I_POP, 0) == -1 ) { 695*7c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_POP on fd %d failed ", fd); 696*7c478bd9Sstevel@tonic-gate DEBUG(5, "errno %d\n", errno); 697*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 698*7c478bd9Sstevel@tonic-gate return(FALSE); 699*7c478bd9Sstevel@tonic-gate } 700*7c478bd9Sstevel@tonic-gate } 701*7c478bd9Sstevel@tonic-gate 702*7c478bd9Sstevel@tonic-gate /* check for streams modules to push */ 703*7c478bd9Sstevel@tonic-gate while ( getpush(strmod, sizeof(strmod)) ) { 704*7c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: PUSHing %s\n", strmod); 705*7c478bd9Sstevel@tonic-gate if ( ioctl(fd, I_PUSH, strmod) == -1 ) { 706*7c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_PUSH on fd %d failed ", fd); 707*7c478bd9Sstevel@tonic-gate DEBUG(5, "errno %d\n", errno); 708*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 709*7c478bd9Sstevel@tonic-gate return(FALSE); 710*7c478bd9Sstevel@tonic-gate } 711*7c478bd9Sstevel@tonic-gate } 712*7c478bd9Sstevel@tonic-gate (void) _uu_resetlocale(LC_ALL, prev); 713*7c478bd9Sstevel@tonic-gate return(TRUE); 714*7c478bd9Sstevel@tonic-gate } 715*7c478bd9Sstevel@tonic-gate 716*7c478bd9Sstevel@tonic-gate /* 717*7c478bd9Sstevel@tonic-gate * return name of currently open Systems file 718*7c478bd9Sstevel@tonic-gate */ 719*7c478bd9Sstevel@tonic-gate GLOBAL char * 720*7c478bd9Sstevel@tonic-gate currsys() 721*7c478bd9Sstevel@tonic-gate { 722*7c478bd9Sstevel@tonic-gate return(Systems[nsystems]); 723*7c478bd9Sstevel@tonic-gate } 724*7c478bd9Sstevel@tonic-gate 725*7c478bd9Sstevel@tonic-gate /* 726*7c478bd9Sstevel@tonic-gate * return name of currently open Devices file 727*7c478bd9Sstevel@tonic-gate */ 728*7c478bd9Sstevel@tonic-gate GLOBAL char * 729*7c478bd9Sstevel@tonic-gate currdev() 730*7c478bd9Sstevel@tonic-gate { 731*7c478bd9Sstevel@tonic-gate return(Devices[ndevices]); 732*7c478bd9Sstevel@tonic-gate } 733*7c478bd9Sstevel@tonic-gate 734*7c478bd9Sstevel@tonic-gate /* 735*7c478bd9Sstevel@tonic-gate * return name of currently open Dialers file 736*7c478bd9Sstevel@tonic-gate */ 737*7c478bd9Sstevel@tonic-gate GLOBAL char * 738*7c478bd9Sstevel@tonic-gate currdial() 739*7c478bd9Sstevel@tonic-gate { 740*7c478bd9Sstevel@tonic-gate return(Dialers[ndialers]); 741*7c478bd9Sstevel@tonic-gate } 742*7c478bd9Sstevel@tonic-gate 743*7c478bd9Sstevel@tonic-gate /* 744*7c478bd9Sstevel@tonic-gate * set configuration parameters provided in Config file 745*7c478bd9Sstevel@tonic-gate */ 746*7c478bd9Sstevel@tonic-gate static void 747*7c478bd9Sstevel@tonic-gate setconfig() 748*7c478bd9Sstevel@tonic-gate { 749*7c478bd9Sstevel@tonic-gate FILE *f; 750*7c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 751*7c478bd9Sstevel@tonic-gate char *tok; 752*7c478bd9Sstevel@tonic-gate extern char _ProtoCfg[]; 753*7c478bd9Sstevel@tonic-gate 754*7c478bd9Sstevel@tonic-gate if ((f = fopen(CONFIG, "r")) != 0) { 755*7c478bd9Sstevel@tonic-gate while (getline(f, buf) > 0) { 756*7c478bd9Sstevel@tonic-gate /* got a (logical) line from Config file */ 757*7c478bd9Sstevel@tonic-gate tok = strtok(buf, " \t"); 758*7c478bd9Sstevel@tonic-gate if ( (tok != NULL) && (*tok != '#') ) { 759*7c478bd9Sstevel@tonic-gate /* got a token */ 760*7c478bd9Sstevel@tonic-gate 761*7c478bd9Sstevel@tonic-gate /* this probably should be table driven when 762*7c478bd9Sstevel@tonic-gate * the list of configurable parameters grows. 763*7c478bd9Sstevel@tonic-gate */ 764*7c478bd9Sstevel@tonic-gate if (strncmp("Protocol=", tok, strlen("Protocol=")) == SAME) { 765*7c478bd9Sstevel@tonic-gate tok += strlen("Protocol="); 766*7c478bd9Sstevel@tonic-gate if ( *tok != '\0' ) { 767*7c478bd9Sstevel@tonic-gate if ( _ProtoCfg[0] != '\0' ) { 768*7c478bd9Sstevel@tonic-gate DEBUG(7, "Protocol string %s ", tok); 769*7c478bd9Sstevel@tonic-gate DEBUG(7, "overrides %s\n", _ProtoCfg); 770*7c478bd9Sstevel@tonic-gate } 771*7c478bd9Sstevel@tonic-gate strcpy(_ProtoCfg, tok); 772*7c478bd9Sstevel@tonic-gate } 773*7c478bd9Sstevel@tonic-gate } else { 774*7c478bd9Sstevel@tonic-gate DEBUG(7, "Unknown configuration parameter %s\n", tok); 775*7c478bd9Sstevel@tonic-gate } 776*7c478bd9Sstevel@tonic-gate } 777*7c478bd9Sstevel@tonic-gate } 778*7c478bd9Sstevel@tonic-gate } 779*7c478bd9Sstevel@tonic-gate } 780