lc_utils.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) 1999-2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lastcomm.h"
/*
* lc_utils contains utility functions used by both the basic and extended
* accounting components of lastcomm. getdev(), on its first call, builds
* the set of tty device name to dev_t mappings.
*/
struct devhash {
char dev_name [PATHNAMLEN];
};
/*
*/
static char *def_srch_dirs[] = {
};
static char *raw_sf; /* buffer containing raw image of the search file */
#define SRCH_FILE_NAME "/etc/ttysrch"
/*
*/
#define COMMENT_CHAR '#'
#define EOLN '\n'
/*
*/
#define START_STATE 1
#define COMMENT_STATE 2
#define DIRNAME_STATE 3
/*
* The following 2 routines are modified version of get_pri_dirs
* and srch_dir in ttyname.c.
*/
static char **
{
int bcount = 0;
int c;
int sf_lines = 0; /* number of lines in search file */
int dirno = 0;
int state;
char **pri_dirs; /* priority search list */
char *sfp; /* pointer inside the raw image buffer */
return (def_srch_dirs);
return (def_srch_dirs);
}
*sfp++ = (char)c;
if (c == EOLN)
sf_lines++;
}
state = START_STATE;
while (--bcount) {
switch (state) {
case START_STATE:
if (*sfp == COMMENT_CHAR) {
}
break;
case COMMENT_STATE:
state = START_STATE;
break;
case DIRNAME_STATE:
*sfp = '\0';
state = START_STATE;
*sfp = '\0';
}
break;
} /* switch */
sfp++;
}
*sfp = '\0';
return (pri_dirs);
}
/*
* Build a chain of character devices in dev_chain, starting with the given
* path.
*/
static int
{
char file_name[PATHNAMLEN];
return (0);
return (0);
continue;
hashtab++;
if (--ndevs < 0)
return (-1);
}
}
return (1);
}
static void
{
int dirno = 0;
char **srch_dirs;
return;
}
srch_dirs = get_pri_dirs();
return;
dirno++;
}
dirno = 0;
/*
* Don't search /dev twice.
*/
return;
dirno++;
}
}
char *
{
char name[PATHNAMLEN];
static char *lastname;
static int init = 0;
return ("__");
return (lastname);
if (!init) {
setupdevs();
init++;
}
}
continue;
continue;
}
}
return ("??");
}
char *
flagbits(int f)
{
int i = 0;
static char flags[20];
flags[i] = '\0';
return (flags);
}
char *
{
return (uidname);
}
}