sysfiles.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "uucp.h"
#include <unistd.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 */
#if defined(__STDC__)
#else
static int namematch();
#endif
/* 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 */
/* this might be dynamically allocated */
#define NTOKENS 16
/* export these */
#if defined(__STDC__)
#else
EXTERN void setservice();
#endif
/* import these */
/*
* setservice init's Systems, Devices, Dialers lists from Sysfiles
*/
GLOBAL void
#if defined(__STDC__)
const char *service;
#else
char *service;
#endif
{
trace1(TR_setservice, 0);
setconfig();
return;
}
/*
* setdevcfg init's Pops, Pushes lists from Devconfig
*/
GLOBAL void
{
trace1(TR_setdevcfg, 0);
return;
}
/* administrative files access */
GLOBAL int
int type;
{
int dummy;
switch (type) {
case ACCESS_SYSTEMS:
case ACCESS_DEVICES:
case ACCESS_DIALERS:
case EACCESS_SYSTEMS:
return (dummy);
case EACCESS_DEVICES:
return (dummy);
case EACCESS_DIALERS:
return (dummy);
default: {
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
char *service;
{ FILE *f;
trace1(TR_scansys, 0);
/* 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 */
}
}
}
return;
}
/*
* 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 */
trace1(TR_scancfg, 0);
/* 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
FILE *f;
char *line;
trace1(TR_getline, 0);
/* 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
*/
#if defined(__STDC__)
static int
#else
static int
#endif
{ char *lend;
trace1(TR_namematch, 0);
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()
{ char *tok;
trace1(TR_tokenize, 0);
break;
}
return;
}
/*
* 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
int temp;
trace1(TR_nameparse, 0);
continue; /* may be meaningful someday? */
*equals = '\0';
/* ignore entry with empty rhs */
if (*++equals == '\0')
continue;
else {
}
}
return;
}
/*
* 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];
trace1(TR_setfile, 0);
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 */
/* if we can't read it, no point in adding to list */
continue;
tptr++;
}
return;
}
/*
* given the list for a particular ioctl (push, pop)
* and a line of colon-separated modules, add 'em to list
*/
static void
trace1(TR_setioctl, 0);
if (*line == 0) {
return;
}
while (*tptr) /* skip over existing entries to*/
tptr++; /* concatenate multiple entries */
tptr++;
}
return;
}
/*
* reset Systems files
*/
GLOBAL void
sysreset()
{
trace1(TR_sysreset, 0);
if (fsystems)
nsystems = 0;
devreset();
return;
}
/*
* reset Devices files
*/
GLOBAL void
devreset()
{
trace1(TR_devreset, 0);
if (fdevices)
ndevices = 0;
dialreset();
return;
}
/*
* reset Dialers files
*/
GLOBAL void
{
trace1(TR_dialreset, 0);
if (fdialers)
ndialers = 0;
return;
}
/*
* get next line from Systems file
* return TRUE if successful, FALSE if not
*/
GLOBAL 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
{
trace1(TR_nextsystems, 0);
devreset();
nsystems++;
} else {
nsystems = 0;
}
return (TRUE);
}
return (FALSE);
}
/*
* get next line from Devices file
* return TRUE if successful, FALSE if not
*/
GLOBAL 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
{
trace1(TR_nextdevices, 0);
ndevices++;
} else {
ndevices = 0;
}
return (TRUE);
}
return (FALSE);
}
/*
* get next line from Dialers file
* return TRUE if successful, FALSE if not
*/
GLOBAL 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
{
trace1(TR_nextdialers, 0);
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
char *buf;
int *optional;
{
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
char *buf;
{
return (FALSE);
}
return (TRUE);
}
/*
* return TRUE if successful, FALSE if not
*/
GLOBAL int
int fd;
{
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);
}
/*
* return name of currently open Systems file
*/
GLOBAL char *
currsys()
{
trace1(TR_currsys, 0);
}
/*
* return name of currently open Devices file
*/
GLOBAL char *
currdev()
{
trace1(TR_currdev, 0);
}
/*
* return name of currently open Dialers file
*/
GLOBAL char *
currdial()
{
trace1(TR_currdial, 0);
}
/*
* set configuration parameters provided in Config file
*/
static void
{
FILE *f;
char *tok;
extern char _ProtoCfg[];
trace1(TR_setconfig, 0);
/* got a (logical) line from Config file */
/* got a token */
/* this probably should be table driven when
* the list of configurable parameters grows.
*/
if (*tok != '\0') {
if (_ProtoCfg[0] != '\0') {
/*EMPTY*/
}
}
} else {
/*EMPTY*/
}
}
}
(void) fclose(f);
}
}