sysfiles.c revision 004388ebfdfe2ed7dfd2d153a876dfcc22d2c006
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "mt.h"
#include "uucp.h"
#include <unistd.h>
#include <string.h>
#include "sysfiles.h"
/*
* manage systems files (Systems, Devices, and Dialcodes families).
*
* also manage new file Devconfig, allows per-device setup.
*
* TODO:
* call bsfix()?
* combine the 3 versions of everything (sys, dev, and dial) into one.
* allow arbitrary classes of service.
* need verifysys() for uucheck.
* nameserver interface?
* pass sysname (or 0) to getsysline(). (might want reg. exp. or
* NS processing)
*/
/* private variables */
static void tokenize(void);
static void nameparse(void);
static void setfile(char **, char *);
static void setioctl(char **, char *);
static void scansys(const char *);
static void scancfg(char *, char *);
static void setconfig(void);
static int nextdialers(void);
static int nextdevices(void);
static int nextsystems(void);
/* pointer arrays might be dynamically allocated */
static int nsystems; /* index into list of Systems files */
static int ndevices; /* index into list of Devices files */
static int ndialers; /* index into list of Dialers files */
static int npops; /* index into list of STREAMS modules */
/* to be popped */
static int npushes; /* index into list of STREAMS modules */
/* to be pushed */
static unsigned connecttime, expecttime;
/* this might be dynamically allocated */
#define NTOKENS 16
/* export these */
static void setservice(const char *service);
static void sysreset(void);
static void devreset(void);
static void dialreset(void);
static void setdevcfg(char *, char *);
static void setservice(const char *);
/* import these */
extern char *strsave(const char *);
/*
* setservice init's Systems, Devices, Dialers lists from Sysfiles
*/
static void
setservice(const char *service)
{
setconfig();
}
/*
* setdevcfg init's Pops, Pushes lists from Devconfig
*/
static void
{
}
/* administrative files access */
static int
{
switch (type) {
case ACCESS_SYSTEMS:
case ACCESS_DEVICES:
case ACCESS_DIALERS:
case EACCESS_SYSTEMS:
case EACCESS_DEVICES:
case EACCESS_DIALERS:
}
return (FAIL);
}
/*
* allow multiple entries for a given service, allow a service
* type to describe resources more than once, e.g., systems=foo:baz systems=bar.
*/
static void
{ FILE *f;
/* got a (logical) line from Sysfiles */
/* strtok's of this buf continue in tokenize() */
tokenize();
nameparse();
}
}
(void) fclose(f);
}
/* if didn't find entries in Sysfiles, use defaults */
0);
}
0);
}
0);
}
}
/*
* read Devconfig. allow multiple entries for a given service, allow a service
* type to describe resources more than once, e.g., push=foo:baz push=bar.
*/
static void
{ FILE *f;
/* (re)initialize device-specific information */
/* got a (logical) line from Devconfig */
/* strtok's of this buf continue in tokenize() */
tokenize();
nameparse();
}
}
}
(void) fclose(f);
}
return;
}
/*
* given a file pointer and buffer, construct logical line in buffer
* (i.e., concatenate lines ending in '\'). return length of line
* ASSUMES that buffer is BUFSIZ long!
*/
static int
/* empty buf or line too long! */
break;
continue;
break;
/* continuation */
}
}
/*
* given a label (e.g., "service=", "device="), a name ("cu", "uucico"),
* and a line: if line begins with the label and if the name appears
* in a colon-separated list of names following the label, return true;
* else return false
*/
static int
{
char *lend;
return (FALSE); /* probably a comment line */
if (*line == '\0')
return (FALSE);
/*
* can't use strtok() in the following because scansys(),
* scancfg() do an initializing call to strtok() before
* coming here and then CONTINUE calling strtok() in tokenize(),
* after returning from namematch().
*/
*lend = '\0';
return (TRUE);
}
}
/*
* tokenize() continues pulling tokens out of a buffer -- the
* initializing call to strtok must have been made before calling
* tokenize() -- and starts stuffing 'em into tokptr.
*/
static void
tokenize(void)
{
char *tok;
break;
}
}
/*
* look at top token in array: should be line of the form
* name=item1:item2:item3...
* if name is one we recognize, then call set[file|ioctl] to set up
* corresponding list. otherwise, log bad name.
*/
static void
nameparse(void)
{
int temp;
continue; /* may be meaningful someday? */
*equals = '\0';
/* ignore entry with empty rhs */
if (*++equals == '\0')
continue;
continue;
else {
"unrecognized label %s", *line);
}
}
}
/*
* given the list for a particular type (systems, devices,...)
* and a line of colon-separated files, add 'em to list
*/
static void
{
char expandpath[BUFSIZ];
if (*line == 0)
return;
while (*tptr) /* skip over existing entries to */
tptr++; /* concatenate multiple entries */
expandpath[0] = '\0';
if (*tok != '/')
/* by default, file names are relative to SYSDIR */
"%s/", SYSDIR);
/* if we can't read it, no point in adding to list */
continue;
tptr++;
}
}
/*
* given the list for a particular ioctl (push, pop)
* and a line of colon-separated modules, add 'em to list
*/
static void
{
if (*line == 0)
return;
while (*tptr) /* skip over existing entries to */
tptr++; /* concatenate multiple entries */
tptr++;
}
}
/*
* reset Systems files
*/
static void
sysreset(void)
{
if (fsystems)
nsystems = 0;
devreset();
}
/*
* reset Devices files
*/
static void
devreset(void)
{
if (fdevices)
ndevices = 0;
dialreset();
}
/*
* reset Dialers files
*/
static void
dialreset(void)
{
if (fdialers)
ndialers = 0;
}
/*
* get next line from Systems file
* return TRUE if successful, FALSE if not
*/
static int
{
/* not initialized via setservice() - use default */
setservice("uucico");
/* initialize devices and dialers whenever a new line is read */
/* from systems */
devreset();
if (nextsystems() == FALSE)
return (FALSE);
for (;;) {
return (TRUE);
if (nextsystems() == FALSE)
return (FALSE);
}
}
/*
* move to next systems file. return TRUE if successful, FALSE if not
*/
static int
nextsystems(void)
{
devreset();
nsystems++;
} else {
nsystems = 0;
}
return (TRUE);
return (FALSE);
}
/*
* get next line from Devices file
* return TRUE if successful, FALSE if not
*/
static int
{
/* not initialized via setservice() - use default */
setservice("uucico");
if (nextdevices() == FALSE)
return (FALSE);
for (;;) {
return (TRUE);
if (nextdevices() == FALSE)
return (FALSE);
}
}
/*
* move to next devices file. return TRUE if successful, FALSE if not
*/
static int
nextdevices(void)
{
ndevices++;
} else {
ndevices = 0;
}
return (TRUE);
return (FALSE);
}
/*
* get next line from Dialers file
* return TRUE if successful, FALSE if not
*/
static int
{
/* not initialized via setservice() - use default */
setservice("uucico");
if (nextdialers() == FALSE)
return (FALSE);
for (;;) {
return (TRUE);
if (nextdialers() == FALSE)
return (FALSE);
}
}
/*
* move to next dialers file. return TRUE if successful, FALSE if not
*/
static int
nextdialers(void)
{
if (fdialers) {
ndialers++;
} else {
ndialers = 0;
}
return (TRUE);
return (FALSE);
}
/*
* get next module to be popped
* return TRUE if successful, FALSE if not
*/
static int
{
int slen;
return (FALSE);
/* if the module name is enclosed in parentheses, */
/* is optional. set flag & strip parens */
*optional = 1;
} else {
*optional = 0;
}
return (TRUE);
}
/*
* get next module to be pushed
* return TRUE if successful, FALSE if not
*/
static int
{
return (FALSE);
return (TRUE);
}
/*
* return TRUE if successful, FALSE if not
*/
static int
{
int optional;
/* check for streams modules to pop */
(const char *)"pop_push: optionally POPing %s\n" :
(const char *)"pop_push: POPing %s\n"), strmod);
return (FALSE);
}
if (optional)
continue;
return (FALSE);
}
return (FALSE);
}
}
/* check for streams modules to push */
return (FALSE);
}
}
return (TRUE);
}
#ifndef SMALL
/*
* return name of currently open Systems file
*/
static char *
currsys(void)
{
}
/*
* return name of currently open Devices file
*/
static char *
currdev(void)
{
}
/*
* return name of currently open Dialers file
*/
static char *
currdial(void)
{
}
#endif
/*
* set configuration parameters provided in Config file
*/
static void
setconfig(void)
{
FILE *f;
char *tok;
extern char _ProtoCfg[];
/* got a (logical) line from Config file */
/* got a token */
/*
* this probably should be table driven when
* the list of configurable parameters grows.
*/
SAME) {
if (*tok != '\0') {
if (_ProtoCfg[0] != '\0') {
/*EMPTY*/
tok);
}
}
} else {
/*EMPTY*/
tok);
}
}
}
(void) fclose(f);
}
}