2 * $Id: gettok.c,v 1.5 2001-12-03 05:03:38 jmarcus Exp $
4 * Copyright (c) 1990,1994 Regents of The University of Michigan.
5 * All Rights Reserved. See COPYRIGHT.
10 #endif /* HAVE_CONFIG_H */
12 #include <sys/param.h>
17 #else /* STDC_HEADERS */
21 #endif /* HAVE_STRCHR */
22 char *strchr (), *strrchr ();
24 #define memcpy(d,s,n) bcopy ((s), (d), (n))
25 #define memmove(d,s,n) bcopy ((s), (d), (n))
26 #endif /* ! HAVE_MEMCPY */
27 #endif /* STDC_HEADERS */
37 void initline( len, line )
50 parseline( len, token )
62 if ( l_curr > l_end ) { /* end of line */
69 if ( state == ST_QUOTE ) {
80 if ( state == ST_WORD ) {
84 if ( state != ST_QUOTE ) {
90 if ( state == ST_BEGIN ) {
93 if ( p > e ) { /* end of token */
106 void parseline( token, user )
109 char *p = pos, *t = token, *u, *q, buf[ MAXPATHLEN ];
110 struct passwd *pwent;
113 while ( isspace( *p )) {
118 * If we've reached the end of the line, or a comment,
119 * don't return any more tokens.
121 if ( *p == '\0' || *p == '#' ) {
130 while ( *p != '\0' && ( quoted || !isspace( *p ))) {
146 * We got to the end of the line without closing an open quote
148 if ( *p == '\0' && quoted ) {
156 if ( *t == '\0' || *t == '/' ) {
163 if (( q = strchr( t, '/' )) == NULL ) {
170 if ( u == NULL || ( pwent = getpwnam( u )) == NULL ) {
174 strcpy( buf, pwent->pw_dir );
179 strcpy( token, buf );