17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5004388ebScasper * Common Development and Distribution License (the "License"). 6004388ebScasper * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 2161961e0fSrobinson 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 237c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 26*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 277c478bd9Sstevel@tonic-gate * Use is subject to license terms. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 30e8031f0aSraf #include "mt.h" 317c478bd9Sstevel@tonic-gate #include "uucp.h" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <unistd.h> 3461961e0fSrobinson #include <string.h> 357c478bd9Sstevel@tonic-gate #include "sysfiles.h" 367c478bd9Sstevel@tonic-gate #include <sys/stropts.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * manage systems files (Systems, Devices, and Dialcodes families). 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * also manage new file Devconfig, allows per-device setup. 427c478bd9Sstevel@tonic-gate * present use is to specify what streams modules to push/pop for 437c478bd9Sstevel@tonic-gate * AT&T TLI/streams network. 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * TODO: 467c478bd9Sstevel@tonic-gate * call bsfix()? 477c478bd9Sstevel@tonic-gate * combine the 3 versions of everything (sys, dev, and dial) into one. 487c478bd9Sstevel@tonic-gate * allow arbitrary classes of service. 497c478bd9Sstevel@tonic-gate * need verifysys() for uucheck. 507c478bd9Sstevel@tonic-gate * nameserver interface? 5161961e0fSrobinson * pass sysname (or 0) to getsysline(). (might want reg. exp. or 5261961e0fSrobinson * NS processing) 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* private variables */ 5661961e0fSrobinson static void tokenize(void); 5761961e0fSrobinson static void nameparse(void); 5861961e0fSrobinson static void setfile(char **, char *); 5961961e0fSrobinson static void setioctl(char **, char *); 6061961e0fSrobinson static void scansys(const char *); 6161961e0fSrobinson static void scancfg(char *, char *); 6261961e0fSrobinson static void setconfig(void); 6361961e0fSrobinson static int namematch(const char *label, char *line, const char *name); 6461961e0fSrobinson static int nextdialers(void); 6561961e0fSrobinson static int nextdevices(void); 6661961e0fSrobinson static int nextsystems(void); 6761961e0fSrobinson static int getline(FILE *, char *); 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate /* pointer arrays might be dynamically allocated */ 707c478bd9Sstevel@tonic-gate static char *Systems[64]; /* list of Systems files */ 717c478bd9Sstevel@tonic-gate static char *Devices[64]; /* list of Devices files */ 727c478bd9Sstevel@tonic-gate static char *Dialers[64]; /* list of Dialers files */ 737c478bd9Sstevel@tonic-gate static char *Pops[64]; /* list of STREAMS modules to be popped */ 747c478bd9Sstevel@tonic-gate static char *Pushes[64]; /* list of STREAMS modules to be pushed */ 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate static int nsystems; /* index into list of Systems files */ 777c478bd9Sstevel@tonic-gate static int ndevices; /* index into list of Devices files */ 787c478bd9Sstevel@tonic-gate static int ndialers; /* index into list of Dialers files */ 797c478bd9Sstevel@tonic-gate static int npops; /* index into list of STREAMS modules */ 807c478bd9Sstevel@tonic-gate /* to be popped */ 817c478bd9Sstevel@tonic-gate static int npushes; /* index into list of STREAMS modules */ 827c478bd9Sstevel@tonic-gate /* to be pushed */ 837c478bd9Sstevel@tonic-gate 8461961e0fSrobinson static unsigned connecttime, expecttime; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate static FILE *fsystems; 877c478bd9Sstevel@tonic-gate static FILE *fdevices; 887c478bd9Sstevel@tonic-gate static FILE *fdialers; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* this might be dynamically allocated */ 917c478bd9Sstevel@tonic-gate #define NTOKENS 16 927c478bd9Sstevel@tonic-gate static char *tokens[NTOKENS], **tokptr; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* export these */ 9561961e0fSrobinson static void setservice(const char *service); 9661961e0fSrobinson static void sysreset(void); 9761961e0fSrobinson static void devreset(void); 9861961e0fSrobinson static void dialreset(void); 9961961e0fSrobinson static void setdevcfg(char *, char *); 10061961e0fSrobinson static void setservice(const char *); 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate /* import these */ 10361961e0fSrobinson extern char *strsave(const char *); 10461961e0fSrobinson static int eaccess(char *, mode_t); 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * setservice init's Systems, Devices, Dialers lists from Sysfiles 1087c478bd9Sstevel@tonic-gate */ 10961961e0fSrobinson static void 11061961e0fSrobinson setservice(const char *service) 1117c478bd9Sstevel@tonic-gate { 1127c478bd9Sstevel@tonic-gate setconfig(); 1137c478bd9Sstevel@tonic-gate scansys(service); 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * setdevcfg init's Pops, Pushes lists from Devconfig 1187c478bd9Sstevel@tonic-gate */ 1197c478bd9Sstevel@tonic-gate 12061961e0fSrobinson static void 12161961e0fSrobinson setdevcfg(char *service, char *device) 1227c478bd9Sstevel@tonic-gate { 1237c478bd9Sstevel@tonic-gate scancfg(service, device); 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* administrative files access */ 12761961e0fSrobinson static int 12861961e0fSrobinson sysaccess(int type) 1297c478bd9Sstevel@tonic-gate { 1307c478bd9Sstevel@tonic-gate char errformat[BUFSIZ]; 1317c478bd9Sstevel@tonic-gate 13261961e0fSrobinson switch (type) { 13361961e0fSrobinson case ACCESS_SYSTEMS: 13461961e0fSrobinson return (access(Systems[nsystems], R_OK)); 13561961e0fSrobinson case ACCESS_DEVICES: 13661961e0fSrobinson return (access(Devices[ndevices], R_OK)); 13761961e0fSrobinson case ACCESS_DIALERS: 13861961e0fSrobinson return (access(Dialers[ndialers], R_OK)); 13961961e0fSrobinson case EACCESS_SYSTEMS: 14061961e0fSrobinson return (eaccess(Systems[nsystems], R_OK)); 14161961e0fSrobinson case EACCESS_DEVICES: 14261961e0fSrobinson return (eaccess(Devices[ndevices], R_OK)); 14361961e0fSrobinson case EACCESS_DIALERS: 14461961e0fSrobinson return (eaccess(Dialers[ndialers], R_OK)); 14561961e0fSrobinson } 1467c478bd9Sstevel@tonic-gate (void) sprintf(errformat, "bad access type %d", type); 1477c478bd9Sstevel@tonic-gate logent(errformat, "sysaccess"); 1487c478bd9Sstevel@tonic-gate return (FAIL); 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * read Sysfiles, set up lists of Systems/Devices/Dialers file names. 1547c478bd9Sstevel@tonic-gate * allow multiple entries for a given service, allow a service 1557c478bd9Sstevel@tonic-gate * type to describe resources more than once, e.g., systems=foo:baz systems=bar. 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate static void 15861961e0fSrobinson scansys(const char *service) 1597c478bd9Sstevel@tonic-gate { FILE *f; 1607c478bd9Sstevel@tonic-gate char *tok, buf[BUFSIZ]; 161*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India char **tptr; 1627c478bd9Sstevel@tonic-gate 163*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India /* 164*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India * Release and Initialize previously allocated memory 165*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India * for Systems, Devices and Dialers. 166*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India */ 167*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India nsystems = 0; 168*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India tptr = Systems; 169*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India while (*tptr) { 170*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India free(*tptr); 171*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India *tptr = NULL; 172*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India tptr++; 173*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India } 174*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India 175*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India ndevices = 0; 176*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India tptr = Devices; 177*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India while (*tptr) { 178*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India free(*tptr); 179*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India *tptr = NULL; 180*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India tptr++; 181*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India } 182*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India 183*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India ndialers = 0; 184*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India tptr = Dialers; 185*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India while (*tptr) { 186*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India free(*tptr); 187*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India *tptr = NULL; 188*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India tptr++; 189*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India } 190*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India 191004388ebScasper if ((f = fopen(SYSFILES, "rF")) != 0) { 1927c478bd9Sstevel@tonic-gate while (getline(f, buf) > 0) { 1937c478bd9Sstevel@tonic-gate /* got a (logical) line from Sysfiles */ 1947c478bd9Sstevel@tonic-gate /* strtok's of this buf continue in tokenize() */ 1957c478bd9Sstevel@tonic-gate tok = strtok(buf, " \t"); 1967c478bd9Sstevel@tonic-gate if (namematch("service=", tok, service)) { 1977c478bd9Sstevel@tonic-gate tokenize(); 1987c478bd9Sstevel@tonic-gate nameparse(); 1997c478bd9Sstevel@tonic-gate } 2007c478bd9Sstevel@tonic-gate } 2017c478bd9Sstevel@tonic-gate (void) fclose(f); 2027c478bd9Sstevel@tonic-gate } 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* if didn't find entries in Sysfiles, use defaults */ 2057c478bd9Sstevel@tonic-gate if (Systems[0] == NULL) { 2067c478bd9Sstevel@tonic-gate Systems[0] = strsave(SYSTEMS); 20761961e0fSrobinson ASSERT(Systems[0] != NULL, "Ct_ALLOCATE", "scansys: Systems", 20861961e0fSrobinson 0); 2097c478bd9Sstevel@tonic-gate Systems[1] = NULL; 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate if (Devices[0] == NULL) { 2127c478bd9Sstevel@tonic-gate Devices[0] = strsave(DEVICES); 21361961e0fSrobinson ASSERT(Devices[0] != NULL, "Ct_ALLOCATE", "scansys: Devices", 21461961e0fSrobinson 0); 2157c478bd9Sstevel@tonic-gate Devices[1] = NULL; 2167c478bd9Sstevel@tonic-gate } 2177c478bd9Sstevel@tonic-gate if (Dialers[0] == NULL) { 2187c478bd9Sstevel@tonic-gate Dialers[0] = strsave(DIALERS); 21961961e0fSrobinson ASSERT(Dialers[0] != NULL, "Ct_ALLOCATE", "scansys: Dialers", 22061961e0fSrobinson 0); 2217c478bd9Sstevel@tonic-gate Dialers[1] = NULL; 2227c478bd9Sstevel@tonic-gate } 2237c478bd9Sstevel@tonic-gate } 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate /* 2277c478bd9Sstevel@tonic-gate * read Devconfig. allow multiple entries for a given service, allow a service 2287c478bd9Sstevel@tonic-gate * type to describe resources more than once, e.g., push=foo:baz push=bar. 2297c478bd9Sstevel@tonic-gate */ 2307c478bd9Sstevel@tonic-gate static void 23161961e0fSrobinson scancfg(char *service, char *device) 2327c478bd9Sstevel@tonic-gate { FILE *f; 2337c478bd9Sstevel@tonic-gate char *tok, buf[BUFSIZ]; 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* (re)initialize device-specific information */ 2367c478bd9Sstevel@tonic-gate npops = npushes = 0; 2377c478bd9Sstevel@tonic-gate Pops[0] = Pushes[0] = NULL; 2387c478bd9Sstevel@tonic-gate connecttime = CONNECTTIME; 2397c478bd9Sstevel@tonic-gate expecttime = EXPECTTIME; 2407c478bd9Sstevel@tonic-gate 241004388ebScasper if ((f = fopen(DEVCONFIG, "rF")) != 0) { 2427c478bd9Sstevel@tonic-gate while (getline(f, buf) > 0) { 2437c478bd9Sstevel@tonic-gate /* got a (logical) line from Devconfig */ 2447c478bd9Sstevel@tonic-gate /* strtok's of this buf continue in tokenize() */ 2457c478bd9Sstevel@tonic-gate tok = strtok(buf, " \t"); 2467c478bd9Sstevel@tonic-gate if (namematch("service=", tok, service)) { 2477c478bd9Sstevel@tonic-gate tok = strtok((char *)0, " \t"); 2487c478bd9Sstevel@tonic-gate if (namematch("device=", tok, device)) { 2497c478bd9Sstevel@tonic-gate tokenize(); 2507c478bd9Sstevel@tonic-gate nameparse(); 2517c478bd9Sstevel@tonic-gate } 2527c478bd9Sstevel@tonic-gate } 2537c478bd9Sstevel@tonic-gate } 2547c478bd9Sstevel@tonic-gate (void) fclose(f); 2557c478bd9Sstevel@tonic-gate } 2567c478bd9Sstevel@tonic-gate return; 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate } 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* 2617c478bd9Sstevel@tonic-gate * given a file pointer and buffer, construct logical line in buffer 2627c478bd9Sstevel@tonic-gate * (i.e., concatenate lines ending in '\'). return length of line 2637c478bd9Sstevel@tonic-gate * ASSUMES that buffer is BUFSIZ long! 2647c478bd9Sstevel@tonic-gate */ 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate static int 26761961e0fSrobinson getline(FILE *f, char *line) 2687c478bd9Sstevel@tonic-gate { char *lptr, *lend; 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate lptr = line; 2717c478bd9Sstevel@tonic-gate while (fgets(lptr, (line + BUFSIZ) - lptr, f) != NULL) { 2727c478bd9Sstevel@tonic-gate lend = lptr + strlen(lptr); 2737c478bd9Sstevel@tonic-gate if (lend == lptr || lend[-1] != '\n') 2747c478bd9Sstevel@tonic-gate /* empty buf or line too long! */ 2757c478bd9Sstevel@tonic-gate break; 2767c478bd9Sstevel@tonic-gate *--lend = '\0'; /* lop off ending '\n' */ 2777c478bd9Sstevel@tonic-gate if (lend == line) /* empty line - ignore */ 2787c478bd9Sstevel@tonic-gate continue; 2797c478bd9Sstevel@tonic-gate lptr = lend; 2807c478bd9Sstevel@tonic-gate if (lend[-1] != '\\') 2817c478bd9Sstevel@tonic-gate break; 2827c478bd9Sstevel@tonic-gate /* continuation */ 2837c478bd9Sstevel@tonic-gate lend[-1] = ' '; 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate return (lptr - line); 2867c478bd9Sstevel@tonic-gate } 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate /* 2897c478bd9Sstevel@tonic-gate * given a label (e.g., "service=", "device="), a name ("cu", "uucico"), 2907c478bd9Sstevel@tonic-gate * and a line: if line begins with the label and if the name appears 2917c478bd9Sstevel@tonic-gate * in a colon-separated list of names following the label, return true; 2927c478bd9Sstevel@tonic-gate * else return false 2937c478bd9Sstevel@tonic-gate */ 2947c478bd9Sstevel@tonic-gate static int 29561961e0fSrobinson namematch(const char *label, char *line, const char *name) 29661961e0fSrobinson { 29761961e0fSrobinson char *lend; 2987c478bd9Sstevel@tonic-gate 29961961e0fSrobinson if (strncmp(label, line, strlen(label)) != SAME) 3007c478bd9Sstevel@tonic-gate return (FALSE); /* probably a comment line */ 3017c478bd9Sstevel@tonic-gate line += strlen(label); 30261961e0fSrobinson if (*line == '\0') 3037c478bd9Sstevel@tonic-gate return (FALSE); 3047c478bd9Sstevel@tonic-gate /* 3057c478bd9Sstevel@tonic-gate * can't use strtok() in the following because scansys(), 3067c478bd9Sstevel@tonic-gate * scancfg() do an initializing call to strtok() before 3077c478bd9Sstevel@tonic-gate * coming here and then CONTINUE calling strtok() in tokenize(), 3087c478bd9Sstevel@tonic-gate * after returning from namematch(). 3097c478bd9Sstevel@tonic-gate */ 3107c478bd9Sstevel@tonic-gate while ((lend = strchr(line, ':')) != NULL) { 3117c478bd9Sstevel@tonic-gate *lend = '\0'; 31261961e0fSrobinson if (strcmp(line, name) == SAME) 3137c478bd9Sstevel@tonic-gate return (TRUE); 3147c478bd9Sstevel@tonic-gate line = lend+1; 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate return (strcmp(line, name) == SAME); 3177c478bd9Sstevel@tonic-gate } 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate /* 3207c478bd9Sstevel@tonic-gate * tokenize() continues pulling tokens out of a buffer -- the 3217c478bd9Sstevel@tonic-gate * initializing call to strtok must have been made before calling 3227c478bd9Sstevel@tonic-gate * tokenize() -- and starts stuffing 'em into tokptr. 3237c478bd9Sstevel@tonic-gate */ 3247c478bd9Sstevel@tonic-gate static void 32561961e0fSrobinson tokenize(void) 32661961e0fSrobinson { 32761961e0fSrobinson char *tok; 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate tokptr = tokens; 33061961e0fSrobinson while ((tok = strtok(NULL, " \t")) != NULL) { 3317c478bd9Sstevel@tonic-gate *tokptr++ = tok; 3327c478bd9Sstevel@tonic-gate if (tokptr - tokens >= NTOKENS) 3337c478bd9Sstevel@tonic-gate break; 3347c478bd9Sstevel@tonic-gate } 3357c478bd9Sstevel@tonic-gate *tokptr = NULL; 3367c478bd9Sstevel@tonic-gate } 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* 3397c478bd9Sstevel@tonic-gate * look at top token in array: should be line of the form 3407c478bd9Sstevel@tonic-gate * name=item1:item2:item3... 3417c478bd9Sstevel@tonic-gate * if name is one we recognize, then call set[file|ioctl] to set up 3427c478bd9Sstevel@tonic-gate * corresponding list. otherwise, log bad name. 3437c478bd9Sstevel@tonic-gate */ 3447c478bd9Sstevel@tonic-gate static void 34561961e0fSrobinson nameparse(void) 34661961e0fSrobinson { 34761961e0fSrobinson char **line, *equals; 3487c478bd9Sstevel@tonic-gate int temp; 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate #define setuint(a, b, c) a = (((temp = atoi(b)) <= 0) ? (c) : temp) 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate for (line = tokens; (line - tokens) < NTOKENS && *line; line++) { 3537c478bd9Sstevel@tonic-gate equals = strchr(*line, '='); 3547c478bd9Sstevel@tonic-gate if (equals == NULL) 3557c478bd9Sstevel@tonic-gate continue; /* may be meaningful someday? */ 3567c478bd9Sstevel@tonic-gate *equals = '\0'; 3577c478bd9Sstevel@tonic-gate /* ignore entry with empty rhs */ 3587c478bd9Sstevel@tonic-gate if (*++equals == '\0') 3597c478bd9Sstevel@tonic-gate continue; 3607c478bd9Sstevel@tonic-gate if (strcmp(*line, "systems") == SAME) 3617c478bd9Sstevel@tonic-gate setfile(Systems, equals); 3627c478bd9Sstevel@tonic-gate else if (strcmp(*line, "devices") == SAME) 3637c478bd9Sstevel@tonic-gate setfile(Devices, equals); 3647c478bd9Sstevel@tonic-gate else if (strcmp(*line, "dialers") == SAME) 3657c478bd9Sstevel@tonic-gate setfile(Dialers, equals); 3667c478bd9Sstevel@tonic-gate else if (strcmp(*line, "pop") == SAME) 3677c478bd9Sstevel@tonic-gate setioctl(Pops, equals); 3687c478bd9Sstevel@tonic-gate else if (strcmp(*line, "push") == SAME) 3697c478bd9Sstevel@tonic-gate setioctl(Pushes, equals); 3707c478bd9Sstevel@tonic-gate else if (strcmp(*line, "connecttime") == SAME) 3717c478bd9Sstevel@tonic-gate setuint(connecttime, equals, CONNECTTIME); 3727c478bd9Sstevel@tonic-gate else if (strcmp(*line, "expecttime") == SAME) 3737c478bd9Sstevel@tonic-gate setuint(expecttime, equals, EXPECTTIME); 3747c478bd9Sstevel@tonic-gate else if (strcmp(*line, "msgtime") == SAME) 37561961e0fSrobinson continue; 3767c478bd9Sstevel@tonic-gate else { 3777c478bd9Sstevel@tonic-gate char errformat[BUFSIZ]; 3787c478bd9Sstevel@tonic-gate 37961961e0fSrobinson (void) snprintf(errformat, sizeof (errformat), 38061961e0fSrobinson "unrecognized label %s", *line); 3817c478bd9Sstevel@tonic-gate logent(errformat, "Sysfiles|Devconfig"); 3827c478bd9Sstevel@tonic-gate } 3837c478bd9Sstevel@tonic-gate } 3847c478bd9Sstevel@tonic-gate } 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* 3877c478bd9Sstevel@tonic-gate * given the list for a particular type (systems, devices,...) 3887c478bd9Sstevel@tonic-gate * and a line of colon-separated files, add 'em to list 3897c478bd9Sstevel@tonic-gate */ 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate static void 39261961e0fSrobinson setfile(char **type, char *line) 39361961e0fSrobinson { 39461961e0fSrobinson char **tptr, *tok; 3957c478bd9Sstevel@tonic-gate char expandpath[BUFSIZ]; 3967c478bd9Sstevel@tonic-gate 39761961e0fSrobinson if (*line == 0) 3987c478bd9Sstevel@tonic-gate return; 3997c478bd9Sstevel@tonic-gate tptr = type; 4007c478bd9Sstevel@tonic-gate while (*tptr) /* skip over existing entries to */ 4017c478bd9Sstevel@tonic-gate tptr++; /* concatenate multiple entries */ 4027c478bd9Sstevel@tonic-gate 40361961e0fSrobinson for (tok = strtok(line, ":"); tok != NULL; tok = strtok(NULL, ":")) { 4047c478bd9Sstevel@tonic-gate expandpath[0] = '\0'; 4057c478bd9Sstevel@tonic-gate if (*tok != '/') 4067c478bd9Sstevel@tonic-gate /* by default, file names are relative to SYSDIR */ 40761961e0fSrobinson (void) snprintf(expandpath, sizeof (expandpath), 40861961e0fSrobinson "%s/", SYSDIR); 40961961e0fSrobinson (void) strcat(expandpath, tok); 4107c478bd9Sstevel@tonic-gate if (eaccess(expandpath, R_OK) != 0) 4117c478bd9Sstevel@tonic-gate /* if we can't read it, no point in adding to list */ 4127c478bd9Sstevel@tonic-gate continue; 4137c478bd9Sstevel@tonic-gate *tptr = strsave(expandpath); 4147c478bd9Sstevel@tonic-gate ASSERT(*tptr != NULL, "Ct_ALLOCATE", "setfile: tptr", 0); 4157c478bd9Sstevel@tonic-gate tptr++; 4167c478bd9Sstevel@tonic-gate } 417*56295bc8SSreedhar Chalamalasetti - Sun Microsystems - Bangalore India *tptr = NULL; 4187c478bd9Sstevel@tonic-gate } 4197c478bd9Sstevel@tonic-gate 4207c478bd9Sstevel@tonic-gate /* 4217c478bd9Sstevel@tonic-gate * given the list for a particular ioctl (push, pop) 4227c478bd9Sstevel@tonic-gate * and a line of colon-separated modules, add 'em to list 4237c478bd9Sstevel@tonic-gate */ 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate static void 42661961e0fSrobinson setioctl(char **type, char *line) 42761961e0fSrobinson { 42861961e0fSrobinson char **tptr, *tok; 4297c478bd9Sstevel@tonic-gate 43061961e0fSrobinson if (*line == 0) 4317c478bd9Sstevel@tonic-gate return; 4327c478bd9Sstevel@tonic-gate tptr = type; 4337c478bd9Sstevel@tonic-gate while (*tptr) /* skip over existing entries to */ 4347c478bd9Sstevel@tonic-gate tptr++; /* concatenate multiple entries */ 43561961e0fSrobinson for (tok = strtok(line, ":"); tok != NULL; tok = strtok(NULL, ":")) { 4367c478bd9Sstevel@tonic-gate *tptr = strsave(tok); 4377c478bd9Sstevel@tonic-gate ASSERT(*tptr != NULL, "Ct_ALLOCATE", "setioctl: tptr", 0); 4387c478bd9Sstevel@tonic-gate tptr++; 4397c478bd9Sstevel@tonic-gate } 4407c478bd9Sstevel@tonic-gate } 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate /* 4437c478bd9Sstevel@tonic-gate * reset Systems files 4447c478bd9Sstevel@tonic-gate */ 44561961e0fSrobinson static void 44661961e0fSrobinson sysreset(void) 4477c478bd9Sstevel@tonic-gate { 4487c478bd9Sstevel@tonic-gate if (fsystems) 44961961e0fSrobinson (void) fclose(fsystems); 4507c478bd9Sstevel@tonic-gate fsystems = NULL; 4517c478bd9Sstevel@tonic-gate nsystems = 0; 4527c478bd9Sstevel@tonic-gate devreset(); 4537c478bd9Sstevel@tonic-gate } 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate /* 4567c478bd9Sstevel@tonic-gate * reset Devices files 4577c478bd9Sstevel@tonic-gate */ 45861961e0fSrobinson static void 45961961e0fSrobinson devreset(void) 4607c478bd9Sstevel@tonic-gate { 4617c478bd9Sstevel@tonic-gate if (fdevices) 46261961e0fSrobinson (void) fclose(fdevices); 4637c478bd9Sstevel@tonic-gate fdevices = NULL; 4647c478bd9Sstevel@tonic-gate ndevices = 0; 4657c478bd9Sstevel@tonic-gate dialreset(); 4667c478bd9Sstevel@tonic-gate } 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate /* 4697c478bd9Sstevel@tonic-gate * reset Dialers files 4707c478bd9Sstevel@tonic-gate */ 47161961e0fSrobinson static void 47261961e0fSrobinson dialreset(void) 4737c478bd9Sstevel@tonic-gate { 4747c478bd9Sstevel@tonic-gate if (fdialers) 47561961e0fSrobinson (void) fclose(fdialers); 4767c478bd9Sstevel@tonic-gate fdialers = NULL; 4777c478bd9Sstevel@tonic-gate ndialers = 0; 4787c478bd9Sstevel@tonic-gate } 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* 4817c478bd9Sstevel@tonic-gate * get next line from Systems file 4827c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 4837c478bd9Sstevel@tonic-gate */ 48461961e0fSrobinson static int 4857c478bd9Sstevel@tonic-gate getsysline(char *buf, int len) 4867c478bd9Sstevel@tonic-gate { 4877c478bd9Sstevel@tonic-gate if (Systems[0] == NULL) 4887c478bd9Sstevel@tonic-gate /* not initialized via setservice() - use default */ 4897c478bd9Sstevel@tonic-gate setservice("uucico"); 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate /* initialize devices and dialers whenever a new line is read */ 4927c478bd9Sstevel@tonic-gate /* from systems */ 4937c478bd9Sstevel@tonic-gate devreset(); 4947c478bd9Sstevel@tonic-gate if (fsystems == NULL) 49561961e0fSrobinson if (nextsystems() == FALSE) 4967c478bd9Sstevel@tonic-gate return (FALSE); 4977c478bd9Sstevel@tonic-gate 4987c478bd9Sstevel@tonic-gate for (;;) { 4997c478bd9Sstevel@tonic-gate while (fgets(buf, len, fsystems) != NULL) 5007c478bd9Sstevel@tonic-gate if ((*buf != '#') && (*buf != ' ') && 50161961e0fSrobinson (*buf != '\t') && (*buf != '\n')) 5027c478bd9Sstevel@tonic-gate return (TRUE); 50361961e0fSrobinson if (nextsystems() == FALSE) 5047c478bd9Sstevel@tonic-gate return (FALSE); 5057c478bd9Sstevel@tonic-gate } 5067c478bd9Sstevel@tonic-gate } 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate /* 5097c478bd9Sstevel@tonic-gate * move to next systems file. return TRUE if successful, FALSE if not 5107c478bd9Sstevel@tonic-gate */ 5117c478bd9Sstevel@tonic-gate static int 51261961e0fSrobinson nextsystems(void) 5137c478bd9Sstevel@tonic-gate { 5147c478bd9Sstevel@tonic-gate devreset(); 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate if (fsystems != NULL) { 5177c478bd9Sstevel@tonic-gate (void) fclose(fsystems); 5187c478bd9Sstevel@tonic-gate nsystems++; 5197c478bd9Sstevel@tonic-gate } else { 5207c478bd9Sstevel@tonic-gate nsystems = 0; 5217c478bd9Sstevel@tonic-gate } 5227c478bd9Sstevel@tonic-gate for (; Systems[nsystems] != NULL; nsystems++) 523004388ebScasper if ((fsystems = fopen(Systems[nsystems], "rF")) != NULL) 5247c478bd9Sstevel@tonic-gate return (TRUE); 5257c478bd9Sstevel@tonic-gate return (FALSE); 5267c478bd9Sstevel@tonic-gate } 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate /* 5297c478bd9Sstevel@tonic-gate * get next line from Devices file 5307c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 5317c478bd9Sstevel@tonic-gate */ 53261961e0fSrobinson static int 5337c478bd9Sstevel@tonic-gate getdevline(char *buf, int len) 5347c478bd9Sstevel@tonic-gate { 5357c478bd9Sstevel@tonic-gate if (Devices[0] == NULL) 5367c478bd9Sstevel@tonic-gate /* not initialized via setservice() - use default */ 5377c478bd9Sstevel@tonic-gate setservice("uucico"); 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate if (fdevices == NULL) 54061961e0fSrobinson if (nextdevices() == FALSE) 5417c478bd9Sstevel@tonic-gate return (FALSE); 5427c478bd9Sstevel@tonic-gate for (;;) { 54361961e0fSrobinson if (fgets(buf, len, fdevices) != NULL) 5447c478bd9Sstevel@tonic-gate return (TRUE); 54561961e0fSrobinson if (nextdevices() == FALSE) 5467c478bd9Sstevel@tonic-gate return (FALSE); 5477c478bd9Sstevel@tonic-gate } 5487c478bd9Sstevel@tonic-gate } 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate /* 5517c478bd9Sstevel@tonic-gate * move to next devices file. return TRUE if successful, FALSE if not 5527c478bd9Sstevel@tonic-gate */ 5537c478bd9Sstevel@tonic-gate static int 55461961e0fSrobinson nextdevices(void) 5557c478bd9Sstevel@tonic-gate { 5567c478bd9Sstevel@tonic-gate if (fdevices != NULL) { 5577c478bd9Sstevel@tonic-gate (void) fclose(fdevices); 5587c478bd9Sstevel@tonic-gate ndevices++; 5597c478bd9Sstevel@tonic-gate } else { 5607c478bd9Sstevel@tonic-gate ndevices = 0; 5617c478bd9Sstevel@tonic-gate } 5627c478bd9Sstevel@tonic-gate for (; Devices[ndevices] != NULL; ndevices++) 563004388ebScasper if ((fdevices = fopen(Devices[ndevices], "rF")) != NULL) 5647c478bd9Sstevel@tonic-gate return (TRUE); 5657c478bd9Sstevel@tonic-gate return (FALSE); 5667c478bd9Sstevel@tonic-gate } 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate 5697c478bd9Sstevel@tonic-gate /* 5707c478bd9Sstevel@tonic-gate * get next line from Dialers file 5717c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 5727c478bd9Sstevel@tonic-gate */ 5737c478bd9Sstevel@tonic-gate 57461961e0fSrobinson static int 5757c478bd9Sstevel@tonic-gate getdialline(char *buf, int len) 5767c478bd9Sstevel@tonic-gate { 5777c478bd9Sstevel@tonic-gate if (Dialers[0] == NULL) 5787c478bd9Sstevel@tonic-gate /* not initialized via setservice() - use default */ 5797c478bd9Sstevel@tonic-gate setservice("uucico"); 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate if (fdialers == NULL) 58261961e0fSrobinson if (nextdialers() == FALSE) 5837c478bd9Sstevel@tonic-gate return (FALSE); 5847c478bd9Sstevel@tonic-gate for (;;) { 58561961e0fSrobinson if (fgets(buf, len, fdialers) != NULL) 5867c478bd9Sstevel@tonic-gate return (TRUE); 58761961e0fSrobinson if (nextdialers() == FALSE) 5887c478bd9Sstevel@tonic-gate return (FALSE); 5897c478bd9Sstevel@tonic-gate } 5907c478bd9Sstevel@tonic-gate } 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate /* 5937c478bd9Sstevel@tonic-gate * move to next dialers file. return TRUE if successful, FALSE if not 5947c478bd9Sstevel@tonic-gate */ 5957c478bd9Sstevel@tonic-gate static int 59661961e0fSrobinson nextdialers(void) 5977c478bd9Sstevel@tonic-gate { 5987c478bd9Sstevel@tonic-gate if (fdialers) { 5997c478bd9Sstevel@tonic-gate (void) fclose(fdialers); 6007c478bd9Sstevel@tonic-gate ndialers++; 6017c478bd9Sstevel@tonic-gate } else { 6027c478bd9Sstevel@tonic-gate ndialers = 0; 6037c478bd9Sstevel@tonic-gate } 6047c478bd9Sstevel@tonic-gate 6057c478bd9Sstevel@tonic-gate for (; Dialers[ndialers] != NULL; ndialers++) 606004388ebScasper if ((fdialers = fopen(Dialers[ndialers], "rF")) != NULL) 6077c478bd9Sstevel@tonic-gate return (TRUE); 6087c478bd9Sstevel@tonic-gate return (FALSE); 6097c478bd9Sstevel@tonic-gate } 6107c478bd9Sstevel@tonic-gate 6117c478bd9Sstevel@tonic-gate /* 6127c478bd9Sstevel@tonic-gate * get next module to be popped 6137c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 6147c478bd9Sstevel@tonic-gate */ 6157c478bd9Sstevel@tonic-gate static int 61661961e0fSrobinson getpop(char *buf, size_t len, int *optional) 6177c478bd9Sstevel@tonic-gate { 6187c478bd9Sstevel@tonic-gate int slen; 6197c478bd9Sstevel@tonic-gate 62061961e0fSrobinson if (Pops[0] == NULL || Pops[npops] == NULL) 6217c478bd9Sstevel@tonic-gate return (FALSE); 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate /* if the module name is enclosed in parentheses, */ 6247c478bd9Sstevel@tonic-gate /* is optional. set flag & strip parens */ 6257c478bd9Sstevel@tonic-gate slen = strlen(Pops[npops]) - 1; 6267c478bd9Sstevel@tonic-gate if (Pops[npops][0] == '(' && Pops[npops][slen] == ')') { 6277c478bd9Sstevel@tonic-gate *optional = 1; 6287c478bd9Sstevel@tonic-gate len = (slen < len ? slen : len); 62961961e0fSrobinson (void) strncpy(buf, &(Pops[npops++][1]), len); 6307c478bd9Sstevel@tonic-gate } else { 6317c478bd9Sstevel@tonic-gate *optional = 0; 63261961e0fSrobinson (void) strncpy(buf, Pops[npops++], len); 6337c478bd9Sstevel@tonic-gate } 6347c478bd9Sstevel@tonic-gate buf[len-1] = '\0'; 6357c478bd9Sstevel@tonic-gate return (TRUE); 6367c478bd9Sstevel@tonic-gate } 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate /* 6397c478bd9Sstevel@tonic-gate * get next module to be pushed 6407c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 6417c478bd9Sstevel@tonic-gate */ 6427c478bd9Sstevel@tonic-gate static int 64361961e0fSrobinson getpush(char *buf, size_t len) 6447c478bd9Sstevel@tonic-gate { 64561961e0fSrobinson if (Pushes[0] == NULL || Pushes[npushes] == NULL) 6467c478bd9Sstevel@tonic-gate return (FALSE); 64761961e0fSrobinson (void) strncpy(buf, Pushes[npushes++], len); 6487c478bd9Sstevel@tonic-gate return (TRUE); 6497c478bd9Sstevel@tonic-gate } 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate /* 6527c478bd9Sstevel@tonic-gate * pop/push requested modules 6537c478bd9Sstevel@tonic-gate * return TRUE if successful, FALSE if not 6547c478bd9Sstevel@tonic-gate */ 65561961e0fSrobinson static int 65661961e0fSrobinson pop_push(int fd) 6577c478bd9Sstevel@tonic-gate { 6587c478bd9Sstevel@tonic-gate char strmod[FMNAMESZ], onstream[FMNAMESZ]; 6597c478bd9Sstevel@tonic-gate int optional; 6607c478bd9Sstevel@tonic-gate 6617c478bd9Sstevel@tonic-gate /* check for streams modules to pop */ 6627c478bd9Sstevel@tonic-gate while (getpop(strmod, sizeof (strmod), &optional)) { 6637c478bd9Sstevel@tonic-gate DEBUG(5, (optional ? 66461961e0fSrobinson (const char *)"pop_push: optionally POPing %s\n" : 66561961e0fSrobinson (const char *)"pop_push: POPing %s\n"), strmod); 6667c478bd9Sstevel@tonic-gate if (ioctl(fd, I_LOOK, onstream) == -1) { 6677c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_LOOK on fd %d failed ", fd); 6687c478bd9Sstevel@tonic-gate DEBUG(5, "errno %d\n", errno); 6697c478bd9Sstevel@tonic-gate return (FALSE); 6707c478bd9Sstevel@tonic-gate } 6717c478bd9Sstevel@tonic-gate if (strcmp(strmod, onstream) != SAME) { 6727c478bd9Sstevel@tonic-gate if (optional) 6737c478bd9Sstevel@tonic-gate continue; 6747c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_POP: %s not there\n", strmod); 6757c478bd9Sstevel@tonic-gate return (FALSE); 6767c478bd9Sstevel@tonic-gate } 6777c478bd9Sstevel@tonic-gate if (ioctl(fd, I_POP, 0) == -1) { 6787c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_POP on fd %d failed ", fd); 6797c478bd9Sstevel@tonic-gate DEBUG(5, "errno %d\n", errno); 6807c478bd9Sstevel@tonic-gate return (FALSE); 6817c478bd9Sstevel@tonic-gate } 6827c478bd9Sstevel@tonic-gate } 6837c478bd9Sstevel@tonic-gate 6847c478bd9Sstevel@tonic-gate /* check for streams modules to push */ 6857c478bd9Sstevel@tonic-gate while (getpush(strmod, sizeof (strmod))) { 6867c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: PUSHing %s\n", strmod); 6877c478bd9Sstevel@tonic-gate if (ioctl(fd, I_PUSH, strmod) == -1) { 6887c478bd9Sstevel@tonic-gate DEBUG(5, "pop_push: I_PUSH on fd %d failed ", fd); 6897c478bd9Sstevel@tonic-gate DEBUG(5, "errno %d\n", errno); 6907c478bd9Sstevel@tonic-gate return (FALSE); 6917c478bd9Sstevel@tonic-gate } 6927c478bd9Sstevel@tonic-gate } 6937c478bd9Sstevel@tonic-gate return (TRUE); 6947c478bd9Sstevel@tonic-gate } 6957c478bd9Sstevel@tonic-gate 69661961e0fSrobinson #ifndef SMALL 6977c478bd9Sstevel@tonic-gate /* 6987c478bd9Sstevel@tonic-gate * return name of currently open Systems file 6997c478bd9Sstevel@tonic-gate */ 70061961e0fSrobinson static char * 70161961e0fSrobinson currsys(void) 7027c478bd9Sstevel@tonic-gate { 7037c478bd9Sstevel@tonic-gate return (Systems[nsystems]); 7047c478bd9Sstevel@tonic-gate } 7057c478bd9Sstevel@tonic-gate 7067c478bd9Sstevel@tonic-gate /* 7077c478bd9Sstevel@tonic-gate * return name of currently open Devices file 7087c478bd9Sstevel@tonic-gate */ 70961961e0fSrobinson static char * 71061961e0fSrobinson currdev(void) 7117c478bd9Sstevel@tonic-gate { 7127c478bd9Sstevel@tonic-gate return (Devices[ndevices]); 7137c478bd9Sstevel@tonic-gate } 7147c478bd9Sstevel@tonic-gate 7157c478bd9Sstevel@tonic-gate /* 7167c478bd9Sstevel@tonic-gate * return name of currently open Dialers file 7177c478bd9Sstevel@tonic-gate */ 71861961e0fSrobinson static char * 71961961e0fSrobinson currdial(void) 7207c478bd9Sstevel@tonic-gate { 7217c478bd9Sstevel@tonic-gate return (Dialers[ndialers]); 7227c478bd9Sstevel@tonic-gate } 72361961e0fSrobinson #endif 7247c478bd9Sstevel@tonic-gate 7257c478bd9Sstevel@tonic-gate /* 7267c478bd9Sstevel@tonic-gate * set configuration parameters provided in Config file 7277c478bd9Sstevel@tonic-gate */ 7287c478bd9Sstevel@tonic-gate static void 72961961e0fSrobinson setconfig(void) 7307c478bd9Sstevel@tonic-gate { 7317c478bd9Sstevel@tonic-gate FILE *f; 7327c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 7337c478bd9Sstevel@tonic-gate char *tok; 7347c478bd9Sstevel@tonic-gate extern char _ProtoCfg[]; 7357c478bd9Sstevel@tonic-gate 736004388ebScasper if ((f = fopen(CONFIG, "rF")) != 0) { 7377c478bd9Sstevel@tonic-gate while (getline(f, buf) > 0) { 7387c478bd9Sstevel@tonic-gate /* got a (logical) line from Config file */ 7397c478bd9Sstevel@tonic-gate tok = strtok(buf, " \t"); 7407c478bd9Sstevel@tonic-gate if ((tok != NULL) && (*tok != '#')) { 7417c478bd9Sstevel@tonic-gate /* got a token */ 74261961e0fSrobinson /* 74361961e0fSrobinson * this probably should be table driven when 7447c478bd9Sstevel@tonic-gate * the list of configurable parameters grows. 7457c478bd9Sstevel@tonic-gate */ 74661961e0fSrobinson if (strncmp("Protocol=", tok, strlen("Protocol=")) == 74761961e0fSrobinson SAME) { 7487c478bd9Sstevel@tonic-gate tok += strlen("Protocol="); 7497c478bd9Sstevel@tonic-gate if (*tok != '\0') { 7507c478bd9Sstevel@tonic-gate if (_ProtoCfg[0] != '\0') { 7517c478bd9Sstevel@tonic-gate /*EMPTY*/ 75261961e0fSrobinson DEBUG(7, "Protocol string %s ", 75361961e0fSrobinson tok); 75461961e0fSrobinson DEBUG(7, "overrides %s\n", 75561961e0fSrobinson _ProtoCfg); 7567c478bd9Sstevel@tonic-gate } 75761961e0fSrobinson (void) strcpy(_ProtoCfg, tok); 7587c478bd9Sstevel@tonic-gate } 7597c478bd9Sstevel@tonic-gate } else { 7607c478bd9Sstevel@tonic-gate /*EMPTY*/ 76161961e0fSrobinson DEBUG(7, "Unknown configuration parameter %s\n", 76261961e0fSrobinson tok); 7637c478bd9Sstevel@tonic-gate } 7647c478bd9Sstevel@tonic-gate } 7657c478bd9Sstevel@tonic-gate } 7667c478bd9Sstevel@tonic-gate (void) fclose(f); 7677c478bd9Sstevel@tonic-gate } 7687c478bd9Sstevel@tonic-gate } 769