xref: /titanic_51/usr/src/lib/libnsl/dial/sysfiles.c (revision 61961e0f20c7637a3846bb39786bb9dffa91dfb9)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*61961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
247c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27*61961e0fSrobinson  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
287c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include "uucp.h"
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <unistd.h>
36*61961e0fSrobinson #include <string.h>
377c478bd9Sstevel@tonic-gate #include "sysfiles.h"
387c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  * manage systems files (Systems, Devices, and Dialcodes families).
427c478bd9Sstevel@tonic-gate  *
437c478bd9Sstevel@tonic-gate  * also manage new file Devconfig, allows per-device setup.
447c478bd9Sstevel@tonic-gate  * present use is to specify what streams modules to push/pop for
457c478bd9Sstevel@tonic-gate  * AT&T TLI/streams network.
467c478bd9Sstevel@tonic-gate  *
477c478bd9Sstevel@tonic-gate  * TODO:
487c478bd9Sstevel@tonic-gate  *	call bsfix()?
497c478bd9Sstevel@tonic-gate  *	combine the 3 versions of everything (sys, dev, and dial) into one.
507c478bd9Sstevel@tonic-gate  *	allow arbitrary classes of service.
517c478bd9Sstevel@tonic-gate  *	need verifysys() for uucheck.
527c478bd9Sstevel@tonic-gate  *	nameserver interface?
53*61961e0fSrobinson  *	pass sysname (or 0) to getsysline().  (might want reg. exp. or
54*61961e0fSrobinson  *		NS processing)
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* private variables */
58*61961e0fSrobinson static void tokenize(void);
59*61961e0fSrobinson static void nameparse(void);
60*61961e0fSrobinson static void setfile(char **, char *);
61*61961e0fSrobinson static void setioctl(char **, char *);
62*61961e0fSrobinson static void scansys(const char *);
63*61961e0fSrobinson static void scancfg(char *, char *);
64*61961e0fSrobinson static void setconfig(void);
65*61961e0fSrobinson static int namematch(const char *label, char *line, const char *name);
66*61961e0fSrobinson static int nextdialers(void);
67*61961e0fSrobinson static int nextdevices(void);
68*61961e0fSrobinson static int nextsystems(void);
69*61961e0fSrobinson static int getline(FILE *, char *);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /* pointer arrays might be dynamically allocated */
727c478bd9Sstevel@tonic-gate static char *Systems[64];	/* list of Systems files */
737c478bd9Sstevel@tonic-gate static char *Devices[64];	/* list of Devices files */
747c478bd9Sstevel@tonic-gate static char *Dialers[64];	/* list of Dialers files */
757c478bd9Sstevel@tonic-gate static char *Pops[64];		/* list of STREAMS modules to be popped */
767c478bd9Sstevel@tonic-gate static char *Pushes[64];	/* list of STREAMS modules to be pushed */
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate static int nsystems;		/* index into list of Systems files */
797c478bd9Sstevel@tonic-gate static int ndevices;		/* index into list of Devices files */
807c478bd9Sstevel@tonic-gate static int ndialers;		/* index into list of Dialers files */
817c478bd9Sstevel@tonic-gate static int npops;		/* index into list of STREAMS modules */
827c478bd9Sstevel@tonic-gate 							/* to be popped */
837c478bd9Sstevel@tonic-gate static int npushes;		/* index into list of STREAMS modules */
847c478bd9Sstevel@tonic-gate 							/* to be pushed */
857c478bd9Sstevel@tonic-gate 
86*61961e0fSrobinson static unsigned connecttime, expecttime;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate static FILE *fsystems;
897c478bd9Sstevel@tonic-gate static FILE *fdevices;
907c478bd9Sstevel@tonic-gate static FILE *fdialers;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /* this might be dynamically allocated */
937c478bd9Sstevel@tonic-gate #define	NTOKENS 16
947c478bd9Sstevel@tonic-gate static char *tokens[NTOKENS], **tokptr;
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /* export these */
97*61961e0fSrobinson static void setservice(const char *service);
98*61961e0fSrobinson static void sysreset(void);
99*61961e0fSrobinson static void devreset(void);
100*61961e0fSrobinson static void dialreset(void);
101*61961e0fSrobinson static void setdevcfg(char *, char *);
102*61961e0fSrobinson static void setservice(const char *);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /* import these */
105*61961e0fSrobinson extern char *strsave(const char *);
106*61961e0fSrobinson static int eaccess(char *, mode_t);
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * setservice init's Systems, Devices, Dialers lists from Sysfiles
1107c478bd9Sstevel@tonic-gate  */
111*61961e0fSrobinson static void
112*61961e0fSrobinson setservice(const char *service)
1137c478bd9Sstevel@tonic-gate {
1147c478bd9Sstevel@tonic-gate 	setconfig();
1157c478bd9Sstevel@tonic-gate 	scansys(service);
1167c478bd9Sstevel@tonic-gate }
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /*
1197c478bd9Sstevel@tonic-gate  * setdevcfg init's Pops, Pushes lists from Devconfig
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate 
122*61961e0fSrobinson static void
123*61961e0fSrobinson setdevcfg(char *service, char *device)
1247c478bd9Sstevel@tonic-gate {
1257c478bd9Sstevel@tonic-gate 	scancfg(service, device);
1267c478bd9Sstevel@tonic-gate }
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate /*	administrative files access */
129*61961e0fSrobinson static int
130*61961e0fSrobinson sysaccess(int type)
1317c478bd9Sstevel@tonic-gate {
1327c478bd9Sstevel@tonic-gate 	char errformat[BUFSIZ];
1337c478bd9Sstevel@tonic-gate 
134*61961e0fSrobinson 	switch (type) {
135*61961e0fSrobinson 	case ACCESS_SYSTEMS:
136*61961e0fSrobinson 		return (access(Systems[nsystems], R_OK));
137*61961e0fSrobinson 	case ACCESS_DEVICES:
138*61961e0fSrobinson 		return (access(Devices[ndevices], R_OK));
139*61961e0fSrobinson 	case ACCESS_DIALERS:
140*61961e0fSrobinson 		return (access(Dialers[ndialers], R_OK));
141*61961e0fSrobinson 	case EACCESS_SYSTEMS:
142*61961e0fSrobinson 		return (eaccess(Systems[nsystems], R_OK));
143*61961e0fSrobinson 	case EACCESS_DEVICES:
144*61961e0fSrobinson 		return (eaccess(Devices[ndevices], R_OK));
145*61961e0fSrobinson 	case EACCESS_DIALERS:
146*61961e0fSrobinson 		return (eaccess(Dialers[ndialers], R_OK));
147*61961e0fSrobinson 	}
1487c478bd9Sstevel@tonic-gate 	(void) sprintf(errformat, "bad access type %d", type);
1497c478bd9Sstevel@tonic-gate 	logent(errformat, "sysaccess");
1507c478bd9Sstevel@tonic-gate 	return (FAIL);
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * read Sysfiles, set up lists of Systems/Devices/Dialers file names.
1567c478bd9Sstevel@tonic-gate  * allow multiple entries for a given service, allow a service
1577c478bd9Sstevel@tonic-gate  * type to describe resources more than once, e.g., systems=foo:baz systems=bar.
1587c478bd9Sstevel@tonic-gate  */
1597c478bd9Sstevel@tonic-gate static void
160*61961e0fSrobinson scansys(const char *service)
1617c478bd9Sstevel@tonic-gate {	FILE *f;
1627c478bd9Sstevel@tonic-gate 	char *tok, buf[BUFSIZ];
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 	Systems[0] = Devices[0] = Dialers[0] = NULL;
1657c478bd9Sstevel@tonic-gate 	if ((f = fopen(SYSFILES, "r")) != 0) {
1667c478bd9Sstevel@tonic-gate 		while (getline(f, buf) > 0) {
1677c478bd9Sstevel@tonic-gate 			/* got a (logical) line from Sysfiles */
1687c478bd9Sstevel@tonic-gate 			/* strtok's of this buf continue in tokenize() */
1697c478bd9Sstevel@tonic-gate 			tok = strtok(buf, " \t");
1707c478bd9Sstevel@tonic-gate 			if (namematch("service=", tok, service)) {
1717c478bd9Sstevel@tonic-gate 				tokenize();
1727c478bd9Sstevel@tonic-gate 				nameparse();
1737c478bd9Sstevel@tonic-gate 			}
1747c478bd9Sstevel@tonic-gate 		}
1757c478bd9Sstevel@tonic-gate 		(void) fclose(f);
1767c478bd9Sstevel@tonic-gate 	}
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	/* if didn't find entries in Sysfiles, use defaults */
1797c478bd9Sstevel@tonic-gate 	if (Systems[0] == NULL) {
1807c478bd9Sstevel@tonic-gate 		Systems[0] = strsave(SYSTEMS);
181*61961e0fSrobinson 		ASSERT(Systems[0] != NULL, "Ct_ALLOCATE", "scansys: Systems",
182*61961e0fSrobinson 									0);
1837c478bd9Sstevel@tonic-gate 		Systems[1] = NULL;
1847c478bd9Sstevel@tonic-gate 	}
1857c478bd9Sstevel@tonic-gate 	if (Devices[0] == NULL) {
1867c478bd9Sstevel@tonic-gate 		Devices[0] = strsave(DEVICES);
187*61961e0fSrobinson 		ASSERT(Devices[0] != NULL, "Ct_ALLOCATE", "scansys: Devices",
188*61961e0fSrobinson 									0);
1897c478bd9Sstevel@tonic-gate 		Devices[1] = NULL;
1907c478bd9Sstevel@tonic-gate 	}
1917c478bd9Sstevel@tonic-gate 	if (Dialers[0] == NULL) {
1927c478bd9Sstevel@tonic-gate 		Dialers[0] = strsave(DIALERS);
193*61961e0fSrobinson 		ASSERT(Dialers[0] != NULL, "Ct_ALLOCATE", "scansys: Dialers",
194*61961e0fSrobinson 									0);
1957c478bd9Sstevel@tonic-gate 		Dialers[1] = NULL;
1967c478bd9Sstevel@tonic-gate 	}
1977c478bd9Sstevel@tonic-gate }
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * read Devconfig.  allow multiple entries for a given service, allow a service
2027c478bd9Sstevel@tonic-gate  * type to describe resources more than once, e.g., push=foo:baz push=bar.
2037c478bd9Sstevel@tonic-gate  */
2047c478bd9Sstevel@tonic-gate static void
205*61961e0fSrobinson scancfg(char *service, char *device)
2067c478bd9Sstevel@tonic-gate {	FILE *f;
2077c478bd9Sstevel@tonic-gate 	char *tok, buf[BUFSIZ];
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 	/* (re)initialize device-specific information */
2107c478bd9Sstevel@tonic-gate 	npops = npushes = 0;
2117c478bd9Sstevel@tonic-gate 	Pops[0] = Pushes[0] = NULL;
2127c478bd9Sstevel@tonic-gate 	connecttime = CONNECTTIME;
2137c478bd9Sstevel@tonic-gate 	expecttime = EXPECTTIME;
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate 	if ((f = fopen(DEVCONFIG, "r")) != 0) {
2167c478bd9Sstevel@tonic-gate 		while (getline(f, buf) > 0) {
2177c478bd9Sstevel@tonic-gate 			/* got a (logical) line from Devconfig */
2187c478bd9Sstevel@tonic-gate 			/* strtok's of this buf continue in tokenize() */
2197c478bd9Sstevel@tonic-gate 			tok = strtok(buf, " \t");
2207c478bd9Sstevel@tonic-gate 			if (namematch("service=", tok, service)) {
2217c478bd9Sstevel@tonic-gate 				tok = strtok((char *)0, " \t");
2227c478bd9Sstevel@tonic-gate 				if (namematch("device=", tok, device)) {
2237c478bd9Sstevel@tonic-gate 					tokenize();
2247c478bd9Sstevel@tonic-gate 					nameparse();
2257c478bd9Sstevel@tonic-gate 				}
2267c478bd9Sstevel@tonic-gate 			}
2277c478bd9Sstevel@tonic-gate 		}
2287c478bd9Sstevel@tonic-gate 		(void) fclose(f);
2297c478bd9Sstevel@tonic-gate 	}
2307c478bd9Sstevel@tonic-gate 	return;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate /*
2357c478bd9Sstevel@tonic-gate  *  given a file pointer and buffer, construct logical line in buffer
2367c478bd9Sstevel@tonic-gate  *  (i.e., concatenate lines ending in '\').  return length of line
2377c478bd9Sstevel@tonic-gate  *  ASSUMES that buffer is BUFSIZ long!
2387c478bd9Sstevel@tonic-gate  */
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate static int
241*61961e0fSrobinson getline(FILE *f, char *line)
2427c478bd9Sstevel@tonic-gate {	char *lptr, *lend;
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 	lptr = line;
2457c478bd9Sstevel@tonic-gate 	while (fgets(lptr, (line + BUFSIZ) - lptr, f) != NULL) {
2467c478bd9Sstevel@tonic-gate 		lend = lptr + strlen(lptr);
2477c478bd9Sstevel@tonic-gate 		if (lend == lptr || lend[-1] != '\n')
2487c478bd9Sstevel@tonic-gate 			/* empty buf or line too long! */
2497c478bd9Sstevel@tonic-gate 			break;
2507c478bd9Sstevel@tonic-gate 		*--lend = '\0'; /* lop off ending '\n' */
2517c478bd9Sstevel@tonic-gate 		if (lend == line) /* empty line - ignore */
2527c478bd9Sstevel@tonic-gate 			continue;
2537c478bd9Sstevel@tonic-gate 		lptr = lend;
2547c478bd9Sstevel@tonic-gate 		if (lend[-1] != '\\')
2557c478bd9Sstevel@tonic-gate 			break;
2567c478bd9Sstevel@tonic-gate 		/* continuation */
2577c478bd9Sstevel@tonic-gate 		lend[-1] = ' ';
2587c478bd9Sstevel@tonic-gate 	}
2597c478bd9Sstevel@tonic-gate 	return (lptr - line);
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate /*
2637c478bd9Sstevel@tonic-gate  * given a label (e.g., "service=", "device="), a name ("cu", "uucico"),
2647c478bd9Sstevel@tonic-gate  *  and a line:  if line begins with the label and if the name appears
2657c478bd9Sstevel@tonic-gate  * in a colon-separated list of names following the label, return true;
2667c478bd9Sstevel@tonic-gate  * else return false
2677c478bd9Sstevel@tonic-gate  */
2687c478bd9Sstevel@tonic-gate static int
269*61961e0fSrobinson namematch(const char *label, char *line, const char *name)
270*61961e0fSrobinson {
271*61961e0fSrobinson 	char *lend;
2727c478bd9Sstevel@tonic-gate 
273*61961e0fSrobinson 	if (strncmp(label, line, strlen(label)) != SAME)
2747c478bd9Sstevel@tonic-gate 		return (FALSE);	/* probably a comment line */
2757c478bd9Sstevel@tonic-gate 	line += strlen(label);
276*61961e0fSrobinson 	if (*line == '\0')
2777c478bd9Sstevel@tonic-gate 		return (FALSE);
2787c478bd9Sstevel@tonic-gate 	/*
2797c478bd9Sstevel@tonic-gate 	 * can't use strtok() in the following because scansys(),
2807c478bd9Sstevel@tonic-gate 	 * scancfg() do an initializing call to strtok() before
2817c478bd9Sstevel@tonic-gate 	 * coming here and then CONTINUE calling strtok() in tokenize(),
2827c478bd9Sstevel@tonic-gate 	 * after returning from namematch().
2837c478bd9Sstevel@tonic-gate 	 */
2847c478bd9Sstevel@tonic-gate 	while ((lend = strchr(line, ':')) != NULL) {
2857c478bd9Sstevel@tonic-gate 		*lend = '\0';
286*61961e0fSrobinson 		if (strcmp(line, name) == SAME)
2877c478bd9Sstevel@tonic-gate 			return (TRUE);
2887c478bd9Sstevel@tonic-gate 		line = lend+1;
2897c478bd9Sstevel@tonic-gate 	}
2907c478bd9Sstevel@tonic-gate 	return (strcmp(line, name) == SAME);
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate /*
2947c478bd9Sstevel@tonic-gate  * tokenize() continues pulling tokens out of a buffer -- the
2957c478bd9Sstevel@tonic-gate  * initializing call to strtok must have been made before calling
2967c478bd9Sstevel@tonic-gate  * tokenize() -- and starts stuffing 'em into tokptr.
2977c478bd9Sstevel@tonic-gate  */
2987c478bd9Sstevel@tonic-gate static void
299*61961e0fSrobinson tokenize(void)
300*61961e0fSrobinson {
301*61961e0fSrobinson 	char *tok;
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 	tokptr = tokens;
304*61961e0fSrobinson 	while ((tok = strtok(NULL, " \t")) != NULL) {
3057c478bd9Sstevel@tonic-gate 		*tokptr++ = tok;
3067c478bd9Sstevel@tonic-gate 		if (tokptr - tokens >= NTOKENS)
3077c478bd9Sstevel@tonic-gate 			break;
3087c478bd9Sstevel@tonic-gate 	}
3097c478bd9Sstevel@tonic-gate 	*tokptr = NULL;
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate /*
3137c478bd9Sstevel@tonic-gate  * look at top token in array: should be line of the form
3147c478bd9Sstevel@tonic-gate  *	name=item1:item2:item3...
3157c478bd9Sstevel@tonic-gate  * if name is one we recognize, then call set[file|ioctl] to set up
3167c478bd9Sstevel@tonic-gate  * corresponding list.  otherwise, log bad name.
3177c478bd9Sstevel@tonic-gate  */
3187c478bd9Sstevel@tonic-gate static void
319*61961e0fSrobinson nameparse(void)
320*61961e0fSrobinson {
321*61961e0fSrobinson 	char **line, *equals;
3227c478bd9Sstevel@tonic-gate 	int temp;
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate #define	setuint(a, b, c) a = (((temp = atoi(b)) <= 0) ? (c) : temp)
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate 	for (line = tokens; (line - tokens) < NTOKENS && *line; line++) {
3277c478bd9Sstevel@tonic-gate 		equals = strchr(*line, '=');
3287c478bd9Sstevel@tonic-gate 		if (equals == NULL)
3297c478bd9Sstevel@tonic-gate 			continue;	/* may be meaningful someday? */
3307c478bd9Sstevel@tonic-gate 		*equals = '\0';
3317c478bd9Sstevel@tonic-gate 		/* ignore entry with empty rhs */
3327c478bd9Sstevel@tonic-gate 		if (*++equals == '\0')
3337c478bd9Sstevel@tonic-gate 			continue;
3347c478bd9Sstevel@tonic-gate 		if (strcmp(*line, "systems") == SAME)
3357c478bd9Sstevel@tonic-gate 			setfile(Systems, equals);
3367c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "devices") == SAME)
3377c478bd9Sstevel@tonic-gate 			setfile(Devices, equals);
3387c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "dialers") == SAME)
3397c478bd9Sstevel@tonic-gate 			setfile(Dialers, equals);
3407c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "pop") == SAME)
3417c478bd9Sstevel@tonic-gate 			setioctl(Pops, equals);
3427c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "push") == SAME)
3437c478bd9Sstevel@tonic-gate 			setioctl(Pushes, equals);
3447c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "connecttime") == SAME)
3457c478bd9Sstevel@tonic-gate 			setuint(connecttime, equals, CONNECTTIME);
3467c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "expecttime") == SAME)
3477c478bd9Sstevel@tonic-gate 			setuint(expecttime, equals, EXPECTTIME);
3487c478bd9Sstevel@tonic-gate 		else if (strcmp(*line, "msgtime") == SAME)
349*61961e0fSrobinson 			continue;
3507c478bd9Sstevel@tonic-gate 		else {
3517c478bd9Sstevel@tonic-gate 			char errformat[BUFSIZ];
3527c478bd9Sstevel@tonic-gate 
353*61961e0fSrobinson 			(void) snprintf(errformat, sizeof (errformat),
354*61961e0fSrobinson 						"unrecognized label %s", *line);
3557c478bd9Sstevel@tonic-gate 			logent(errformat, "Sysfiles|Devconfig");
3567c478bd9Sstevel@tonic-gate 		}
3577c478bd9Sstevel@tonic-gate 	}
3587c478bd9Sstevel@tonic-gate }
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate /*
3617c478bd9Sstevel@tonic-gate  * given the list for a particular type (systems, devices,...)
3627c478bd9Sstevel@tonic-gate  * and a line of colon-separated files, add 'em to list
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate static void
366*61961e0fSrobinson setfile(char **type, char *line)
367*61961e0fSrobinson {
368*61961e0fSrobinson 	char **tptr, *tok;
3697c478bd9Sstevel@tonic-gate 	char expandpath[BUFSIZ];
3707c478bd9Sstevel@tonic-gate 
371*61961e0fSrobinson 	if (*line == 0)
3727c478bd9Sstevel@tonic-gate 		return;
3737c478bd9Sstevel@tonic-gate 	tptr = type;
3747c478bd9Sstevel@tonic-gate 	while (*tptr)		/* skip over existing entries to */
3757c478bd9Sstevel@tonic-gate 		tptr++;		/* concatenate multiple entries */
3767c478bd9Sstevel@tonic-gate 
377*61961e0fSrobinson 	for (tok = strtok(line, ":"); tok != NULL; tok = strtok(NULL, ":")) {
3787c478bd9Sstevel@tonic-gate 		expandpath[0] = '\0';
3797c478bd9Sstevel@tonic-gate 		if (*tok != '/')
3807c478bd9Sstevel@tonic-gate 			/* by default, file names are relative to SYSDIR */
381*61961e0fSrobinson 			(void) snprintf(expandpath, sizeof (expandpath),
382*61961e0fSrobinson 								"%s/", SYSDIR);
383*61961e0fSrobinson 		(void) strcat(expandpath, tok);
3847c478bd9Sstevel@tonic-gate 		if (eaccess(expandpath, R_OK) != 0)
3857c478bd9Sstevel@tonic-gate 			/* if we can't read it, no point in adding to list */
3867c478bd9Sstevel@tonic-gate 			continue;
3877c478bd9Sstevel@tonic-gate 		*tptr = strsave(expandpath);
3887c478bd9Sstevel@tonic-gate 		ASSERT(*tptr != NULL, "Ct_ALLOCATE", "setfile: tptr", 0);
3897c478bd9Sstevel@tonic-gate 		tptr++;
3907c478bd9Sstevel@tonic-gate 	}
3917c478bd9Sstevel@tonic-gate }
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate /*
3947c478bd9Sstevel@tonic-gate  * given the list for a particular ioctl (push, pop)
3957c478bd9Sstevel@tonic-gate  * and a line of colon-separated modules, add 'em to list
3967c478bd9Sstevel@tonic-gate  */
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate static void
399*61961e0fSrobinson setioctl(char **type, char *line)
400*61961e0fSrobinson {
401*61961e0fSrobinson 	char **tptr, *tok;
4027c478bd9Sstevel@tonic-gate 
403*61961e0fSrobinson 	if (*line == 0)
4047c478bd9Sstevel@tonic-gate 		return;
4057c478bd9Sstevel@tonic-gate 	tptr = type;
4067c478bd9Sstevel@tonic-gate 	while (*tptr)		/* skip over existing entries to */
4077c478bd9Sstevel@tonic-gate 		tptr++;		/* concatenate multiple entries */
408*61961e0fSrobinson 	for (tok = strtok(line, ":"); tok != NULL; tok = strtok(NULL, ":")) {
4097c478bd9Sstevel@tonic-gate 		*tptr = strsave(tok);
4107c478bd9Sstevel@tonic-gate 		ASSERT(*tptr != NULL, "Ct_ALLOCATE", "setioctl: tptr", 0);
4117c478bd9Sstevel@tonic-gate 		tptr++;
4127c478bd9Sstevel@tonic-gate 	}
4137c478bd9Sstevel@tonic-gate }
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate /*
4167c478bd9Sstevel@tonic-gate  * reset Systems files
4177c478bd9Sstevel@tonic-gate  */
418*61961e0fSrobinson static void
419*61961e0fSrobinson sysreset(void)
4207c478bd9Sstevel@tonic-gate {
4217c478bd9Sstevel@tonic-gate 	if (fsystems)
422*61961e0fSrobinson 		(void) fclose(fsystems);
4237c478bd9Sstevel@tonic-gate 	fsystems = NULL;
4247c478bd9Sstevel@tonic-gate 	nsystems = 0;
4257c478bd9Sstevel@tonic-gate 	devreset();
4267c478bd9Sstevel@tonic-gate }
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate /*
4297c478bd9Sstevel@tonic-gate  * reset Devices files
4307c478bd9Sstevel@tonic-gate  */
431*61961e0fSrobinson static void
432*61961e0fSrobinson devreset(void)
4337c478bd9Sstevel@tonic-gate {
4347c478bd9Sstevel@tonic-gate 	if (fdevices)
435*61961e0fSrobinson 		(void) fclose(fdevices);
4367c478bd9Sstevel@tonic-gate 	fdevices = NULL;
4377c478bd9Sstevel@tonic-gate 	ndevices = 0;
4387c478bd9Sstevel@tonic-gate 	dialreset();
4397c478bd9Sstevel@tonic-gate }
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate /*
4427c478bd9Sstevel@tonic-gate  * reset Dialers files
4437c478bd9Sstevel@tonic-gate  */
444*61961e0fSrobinson static void
445*61961e0fSrobinson dialreset(void)
4467c478bd9Sstevel@tonic-gate {
4477c478bd9Sstevel@tonic-gate 	if (fdialers)
448*61961e0fSrobinson 		(void) fclose(fdialers);
4497c478bd9Sstevel@tonic-gate 	fdialers = NULL;
4507c478bd9Sstevel@tonic-gate 	ndialers = 0;
4517c478bd9Sstevel@tonic-gate }
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate /*
4547c478bd9Sstevel@tonic-gate  * get next line from Systems file
4557c478bd9Sstevel@tonic-gate  * return TRUE if successful, FALSE if not
4567c478bd9Sstevel@tonic-gate  */
457*61961e0fSrobinson static int
4587c478bd9Sstevel@tonic-gate getsysline(char *buf, int len)
4597c478bd9Sstevel@tonic-gate {
4607c478bd9Sstevel@tonic-gate 	if (Systems[0] == NULL)
4617c478bd9Sstevel@tonic-gate 		/* not initialized via setservice() - use default */
4627c478bd9Sstevel@tonic-gate 		setservice("uucico");
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate 	/* initialize devices and dialers whenever a new line is read */
4657c478bd9Sstevel@tonic-gate 	/* from systems */
4667c478bd9Sstevel@tonic-gate 	devreset();
4677c478bd9Sstevel@tonic-gate 	if (fsystems == NULL)
468*61961e0fSrobinson 		if (nextsystems() == FALSE)
4697c478bd9Sstevel@tonic-gate 			return (FALSE);
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate 	for (;;) {
4727c478bd9Sstevel@tonic-gate 		while (fgets(buf, len, fsystems) != NULL)
4737c478bd9Sstevel@tonic-gate 			if ((*buf != '#') && (*buf != ' ') &&
474*61961e0fSrobinson 				(*buf != '\t') && (*buf != '\n'))
4757c478bd9Sstevel@tonic-gate 			return (TRUE);
476*61961e0fSrobinson 		if (nextsystems() == FALSE)
4777c478bd9Sstevel@tonic-gate 			return (FALSE);
4787c478bd9Sstevel@tonic-gate 	}
4797c478bd9Sstevel@tonic-gate }
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate /*
4827c478bd9Sstevel@tonic-gate  * move to next systems file.  return TRUE if successful, FALSE if not
4837c478bd9Sstevel@tonic-gate  */
4847c478bd9Sstevel@tonic-gate static int
485*61961e0fSrobinson nextsystems(void)
4867c478bd9Sstevel@tonic-gate {
4877c478bd9Sstevel@tonic-gate 	devreset();
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate 	if (fsystems != NULL) {
4907c478bd9Sstevel@tonic-gate 		(void) fclose(fsystems);
4917c478bd9Sstevel@tonic-gate 		nsystems++;
4927c478bd9Sstevel@tonic-gate 	} else {
4937c478bd9Sstevel@tonic-gate 		nsystems = 0;
4947c478bd9Sstevel@tonic-gate 	}
4957c478bd9Sstevel@tonic-gate 	for (; Systems[nsystems] != NULL; nsystems++)
496*61961e0fSrobinson 		if ((fsystems = fopen(Systems[nsystems], "r")) != NULL)
4977c478bd9Sstevel@tonic-gate 			return (TRUE);
4987c478bd9Sstevel@tonic-gate 	return (FALSE);
4997c478bd9Sstevel@tonic-gate }
5007c478bd9Sstevel@tonic-gate 
5017c478bd9Sstevel@tonic-gate /*
5027c478bd9Sstevel@tonic-gate  * get next line from Devices file
5037c478bd9Sstevel@tonic-gate  * return TRUE if successful, FALSE if not
5047c478bd9Sstevel@tonic-gate  */
505*61961e0fSrobinson static int
5067c478bd9Sstevel@tonic-gate getdevline(char *buf, int len)
5077c478bd9Sstevel@tonic-gate {
5087c478bd9Sstevel@tonic-gate 	if (Devices[0] == NULL)
5097c478bd9Sstevel@tonic-gate 		/* not initialized via setservice() - use default */
5107c478bd9Sstevel@tonic-gate 		setservice("uucico");
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate 	if (fdevices == NULL)
513*61961e0fSrobinson 		if (nextdevices() == FALSE)
5147c478bd9Sstevel@tonic-gate 			return (FALSE);
5157c478bd9Sstevel@tonic-gate 	for (;;) {
516*61961e0fSrobinson 		if (fgets(buf, len, fdevices) != NULL)
5177c478bd9Sstevel@tonic-gate 			return (TRUE);
518*61961e0fSrobinson 		if (nextdevices() == FALSE)
5197c478bd9Sstevel@tonic-gate 			return (FALSE);
5207c478bd9Sstevel@tonic-gate 	}
5217c478bd9Sstevel@tonic-gate }
5227c478bd9Sstevel@tonic-gate 
5237c478bd9Sstevel@tonic-gate /*
5247c478bd9Sstevel@tonic-gate  * move to next devices file.  return TRUE if successful, FALSE if not
5257c478bd9Sstevel@tonic-gate  */
5267c478bd9Sstevel@tonic-gate static int
527*61961e0fSrobinson nextdevices(void)
5287c478bd9Sstevel@tonic-gate {
5297c478bd9Sstevel@tonic-gate 	if (fdevices != NULL) {
5307c478bd9Sstevel@tonic-gate 		(void) fclose(fdevices);
5317c478bd9Sstevel@tonic-gate 		ndevices++;
5327c478bd9Sstevel@tonic-gate 	} else {
5337c478bd9Sstevel@tonic-gate 		ndevices = 0;
5347c478bd9Sstevel@tonic-gate 	}
5357c478bd9Sstevel@tonic-gate 	for (; Devices[ndevices] != NULL; ndevices++)
536*61961e0fSrobinson 		if ((fdevices = fopen(Devices[ndevices], "r")) != NULL)
5377c478bd9Sstevel@tonic-gate 			return (TRUE);
5387c478bd9Sstevel@tonic-gate 	return (FALSE);
5397c478bd9Sstevel@tonic-gate }
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate /*
5437c478bd9Sstevel@tonic-gate  * get next line from Dialers file
5447c478bd9Sstevel@tonic-gate  * return TRUE if successful, FALSE if not
5457c478bd9Sstevel@tonic-gate  */
5467c478bd9Sstevel@tonic-gate 
547*61961e0fSrobinson static int
5487c478bd9Sstevel@tonic-gate getdialline(char *buf, int len)
5497c478bd9Sstevel@tonic-gate {
5507c478bd9Sstevel@tonic-gate 	if (Dialers[0] == NULL)
5517c478bd9Sstevel@tonic-gate 		/* not initialized via setservice() - use default */
5527c478bd9Sstevel@tonic-gate 		setservice("uucico");
5537c478bd9Sstevel@tonic-gate 
5547c478bd9Sstevel@tonic-gate 	if (fdialers == NULL)
555*61961e0fSrobinson 		if (nextdialers() == FALSE)
5567c478bd9Sstevel@tonic-gate 			return (FALSE);
5577c478bd9Sstevel@tonic-gate 	for (;;) {
558*61961e0fSrobinson 		if (fgets(buf, len, fdialers) != NULL)
5597c478bd9Sstevel@tonic-gate 			return (TRUE);
560*61961e0fSrobinson 		if (nextdialers() == FALSE)
5617c478bd9Sstevel@tonic-gate 			return (FALSE);
5627c478bd9Sstevel@tonic-gate 	}
5637c478bd9Sstevel@tonic-gate }
5647c478bd9Sstevel@tonic-gate 
5657c478bd9Sstevel@tonic-gate /*
5667c478bd9Sstevel@tonic-gate  * move to next dialers file.  return TRUE if successful, FALSE if not
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate static int
569*61961e0fSrobinson nextdialers(void)
5707c478bd9Sstevel@tonic-gate {
5717c478bd9Sstevel@tonic-gate 	if (fdialers) {
5727c478bd9Sstevel@tonic-gate 		(void) fclose(fdialers);
5737c478bd9Sstevel@tonic-gate 		ndialers++;
5747c478bd9Sstevel@tonic-gate 	} else {
5757c478bd9Sstevel@tonic-gate 		ndialers = 0;
5767c478bd9Sstevel@tonic-gate 	}
5777c478bd9Sstevel@tonic-gate 
5787c478bd9Sstevel@tonic-gate 	for (; Dialers[ndialers] != NULL; ndialers++)
579*61961e0fSrobinson 		if ((fdialers = fopen(Dialers[ndialers], "r")) != NULL)
5807c478bd9Sstevel@tonic-gate 			return (TRUE);
5817c478bd9Sstevel@tonic-gate 	return (FALSE);
5827c478bd9Sstevel@tonic-gate }
5837c478bd9Sstevel@tonic-gate 
5847c478bd9Sstevel@tonic-gate /*
5857c478bd9Sstevel@tonic-gate  * get next module to be popped
5867c478bd9Sstevel@tonic-gate  * return TRUE if successful, FALSE if not
5877c478bd9Sstevel@tonic-gate  */
5887c478bd9Sstevel@tonic-gate static int
589*61961e0fSrobinson getpop(char *buf, size_t len, int *optional)
5907c478bd9Sstevel@tonic-gate {
5917c478bd9Sstevel@tonic-gate 	int slen;
5927c478bd9Sstevel@tonic-gate 
593*61961e0fSrobinson 	if (Pops[0] == NULL || Pops[npops] == NULL)
5947c478bd9Sstevel@tonic-gate 		return (FALSE);
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate 	/*	if the module name is enclosed in parentheses,	*/
5977c478bd9Sstevel@tonic-gate 	/*	is optional. set flag & strip parens		*/
5987c478bd9Sstevel@tonic-gate 	slen = strlen(Pops[npops]) - 1;
5997c478bd9Sstevel@tonic-gate 	if (Pops[npops][0] == '(' && Pops[npops][slen] == ')') {
6007c478bd9Sstevel@tonic-gate 		*optional = 1;
6017c478bd9Sstevel@tonic-gate 		len = (slen < len ? slen : len);
602*61961e0fSrobinson 		(void) strncpy(buf, &(Pops[npops++][1]), len);
6037c478bd9Sstevel@tonic-gate 	} else {
6047c478bd9Sstevel@tonic-gate 		*optional = 0;
605*61961e0fSrobinson 		(void) strncpy(buf, Pops[npops++], len);
6067c478bd9Sstevel@tonic-gate 	}
6077c478bd9Sstevel@tonic-gate 	buf[len-1] = '\0';
6087c478bd9Sstevel@tonic-gate 	return (TRUE);
6097c478bd9Sstevel@tonic-gate }
6107c478bd9Sstevel@tonic-gate 
6117c478bd9Sstevel@tonic-gate /*
6127c478bd9Sstevel@tonic-gate  * get next module to be pushed
6137c478bd9Sstevel@tonic-gate  * return TRUE if successful, FALSE if not
6147c478bd9Sstevel@tonic-gate  */
6157c478bd9Sstevel@tonic-gate static int
616*61961e0fSrobinson getpush(char *buf, size_t len)
6177c478bd9Sstevel@tonic-gate {
618*61961e0fSrobinson 	if (Pushes[0] == NULL || Pushes[npushes] == NULL)
6197c478bd9Sstevel@tonic-gate 		return (FALSE);
620*61961e0fSrobinson 	(void) strncpy(buf, Pushes[npushes++], len);
6217c478bd9Sstevel@tonic-gate 	return (TRUE);
6227c478bd9Sstevel@tonic-gate }
6237c478bd9Sstevel@tonic-gate 
6247c478bd9Sstevel@tonic-gate /*
6257c478bd9Sstevel@tonic-gate  * pop/push requested modules
6267c478bd9Sstevel@tonic-gate  * return TRUE if successful, FALSE if not
6277c478bd9Sstevel@tonic-gate  */
628*61961e0fSrobinson static int
629*61961e0fSrobinson pop_push(int fd)
6307c478bd9Sstevel@tonic-gate {
6317c478bd9Sstevel@tonic-gate 	char	strmod[FMNAMESZ], onstream[FMNAMESZ];
6327c478bd9Sstevel@tonic-gate 	int		optional;
6337c478bd9Sstevel@tonic-gate 
6347c478bd9Sstevel@tonic-gate 	/*	check for streams modules to pop	*/
6357c478bd9Sstevel@tonic-gate 	while (getpop(strmod, sizeof (strmod), &optional)) {
6367c478bd9Sstevel@tonic-gate 		DEBUG(5, (optional ?
637*61961e0fSrobinson 			(const char *)"pop_push: optionally POPing %s\n" :
638*61961e0fSrobinson 			(const char *)"pop_push: POPing %s\n"), strmod);
6397c478bd9Sstevel@tonic-gate 		if (ioctl(fd, I_LOOK, onstream) == -1) {
6407c478bd9Sstevel@tonic-gate 			DEBUG(5, "pop_push: I_LOOK on fd %d failed ", fd);
6417c478bd9Sstevel@tonic-gate 			DEBUG(5, "errno %d\n", errno);
6427c478bd9Sstevel@tonic-gate 			return (FALSE);
6437c478bd9Sstevel@tonic-gate 		}
6447c478bd9Sstevel@tonic-gate 		if (strcmp(strmod, onstream) != SAME) {
6457c478bd9Sstevel@tonic-gate 			if (optional)
6467c478bd9Sstevel@tonic-gate 				continue;
6477c478bd9Sstevel@tonic-gate 			DEBUG(5, "pop_push: I_POP: %s not there\n", strmod);
6487c478bd9Sstevel@tonic-gate 			return (FALSE);
6497c478bd9Sstevel@tonic-gate 		}
6507c478bd9Sstevel@tonic-gate 		if (ioctl(fd, I_POP, 0) == -1) {
6517c478bd9Sstevel@tonic-gate 			DEBUG(5, "pop_push: I_POP on fd %d failed ", fd);
6527c478bd9Sstevel@tonic-gate 			DEBUG(5, "errno %d\n", errno);
6537c478bd9Sstevel@tonic-gate 			return (FALSE);
6547c478bd9Sstevel@tonic-gate 		}
6557c478bd9Sstevel@tonic-gate 	}
6567c478bd9Sstevel@tonic-gate 
6577c478bd9Sstevel@tonic-gate 	/*	check for streams modules to push	*/
6587c478bd9Sstevel@tonic-gate 	while (getpush(strmod, sizeof (strmod))) {
6597c478bd9Sstevel@tonic-gate 		DEBUG(5, "pop_push: PUSHing %s\n", strmod);
6607c478bd9Sstevel@tonic-gate 		if (ioctl(fd, I_PUSH, strmod) == -1) {
6617c478bd9Sstevel@tonic-gate 			DEBUG(5, "pop_push: I_PUSH on fd %d failed ", fd);
6627c478bd9Sstevel@tonic-gate 			DEBUG(5, "errno %d\n", errno);
6637c478bd9Sstevel@tonic-gate 			return (FALSE);
6647c478bd9Sstevel@tonic-gate 		}
6657c478bd9Sstevel@tonic-gate 	}
6667c478bd9Sstevel@tonic-gate 	return (TRUE);
6677c478bd9Sstevel@tonic-gate }
6687c478bd9Sstevel@tonic-gate 
669*61961e0fSrobinson #ifndef SMALL
6707c478bd9Sstevel@tonic-gate /*
6717c478bd9Sstevel@tonic-gate  *	return name of currently open Systems file
6727c478bd9Sstevel@tonic-gate  */
673*61961e0fSrobinson static char *
674*61961e0fSrobinson currsys(void)
6757c478bd9Sstevel@tonic-gate {
6767c478bd9Sstevel@tonic-gate 	return (Systems[nsystems]);
6777c478bd9Sstevel@tonic-gate }
6787c478bd9Sstevel@tonic-gate 
6797c478bd9Sstevel@tonic-gate /*
6807c478bd9Sstevel@tonic-gate  *	return name of currently open Devices file
6817c478bd9Sstevel@tonic-gate  */
682*61961e0fSrobinson static char *
683*61961e0fSrobinson currdev(void)
6847c478bd9Sstevel@tonic-gate {
6857c478bd9Sstevel@tonic-gate 	return (Devices[ndevices]);
6867c478bd9Sstevel@tonic-gate }
6877c478bd9Sstevel@tonic-gate 
6887c478bd9Sstevel@tonic-gate /*
6897c478bd9Sstevel@tonic-gate  *	return name of currently open Dialers file
6907c478bd9Sstevel@tonic-gate  */
691*61961e0fSrobinson static char *
692*61961e0fSrobinson currdial(void)
6937c478bd9Sstevel@tonic-gate {
6947c478bd9Sstevel@tonic-gate 	return (Dialers[ndialers]);
6957c478bd9Sstevel@tonic-gate }
696*61961e0fSrobinson #endif
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate /*
6997c478bd9Sstevel@tonic-gate  * set configuration parameters provided in Config file
7007c478bd9Sstevel@tonic-gate  */
7017c478bd9Sstevel@tonic-gate static void
702*61961e0fSrobinson setconfig(void)
7037c478bd9Sstevel@tonic-gate {
7047c478bd9Sstevel@tonic-gate 	FILE *f;
7057c478bd9Sstevel@tonic-gate 	char buf[BUFSIZ];
7067c478bd9Sstevel@tonic-gate 	char *tok;
7077c478bd9Sstevel@tonic-gate 	extern char _ProtoCfg[];
7087c478bd9Sstevel@tonic-gate 
7097c478bd9Sstevel@tonic-gate 	if ((f = fopen(CONFIG, "r")) != 0) {
7107c478bd9Sstevel@tonic-gate 	while (getline(f, buf) > 0) {
7117c478bd9Sstevel@tonic-gate 		/* got a (logical) line from Config file */
7127c478bd9Sstevel@tonic-gate 		tok = strtok(buf, " \t");
7137c478bd9Sstevel@tonic-gate 		if ((tok != NULL) && (*tok != '#')) {
7147c478bd9Sstevel@tonic-gate 			/* got a token */
715*61961e0fSrobinson 			/*
716*61961e0fSrobinson 			 * this probably should be table driven when
7177c478bd9Sstevel@tonic-gate 			 * the list of configurable parameters grows.
7187c478bd9Sstevel@tonic-gate 			 */
719*61961e0fSrobinson 			if (strncmp("Protocol=", tok, strlen("Protocol=")) ==
720*61961e0fSrobinson 								SAME) {
7217c478bd9Sstevel@tonic-gate 				tok += strlen("Protocol=");
7227c478bd9Sstevel@tonic-gate 				if (*tok != '\0') {
7237c478bd9Sstevel@tonic-gate 					if (_ProtoCfg[0] != '\0') {
7247c478bd9Sstevel@tonic-gate 						/*EMPTY*/
725*61961e0fSrobinson 						DEBUG(7, "Protocol string %s ",
726*61961e0fSrobinson 								tok);
727*61961e0fSrobinson 						DEBUG(7, "overrides %s\n",
728*61961e0fSrobinson 								_ProtoCfg);
7297c478bd9Sstevel@tonic-gate 					}
730*61961e0fSrobinson 					(void) strcpy(_ProtoCfg, tok);
7317c478bd9Sstevel@tonic-gate 				}
7327c478bd9Sstevel@tonic-gate 			} else {
7337c478bd9Sstevel@tonic-gate 				/*EMPTY*/
734*61961e0fSrobinson 				DEBUG(7, "Unknown configuration parameter %s\n",
735*61961e0fSrobinson 								tok);
7367c478bd9Sstevel@tonic-gate 			}
7377c478bd9Sstevel@tonic-gate 		}
7387c478bd9Sstevel@tonic-gate 	}
7397c478bd9Sstevel@tonic-gate 	(void) fclose(f);
7407c478bd9Sstevel@tonic-gate 	}
7417c478bd9Sstevel@tonic-gate }
742