2 * $Id: gettok.c,v 1.3 2001-06-20 18:33:04 rufustfirefly 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>
22 void initline( len, line )
35 parseline( len, token )
47 if ( l_curr > l_end ) { /* end of line */
54 if ( state == ST_QUOTE ) {
65 if ( state == ST_WORD ) {
69 if ( state != ST_QUOTE ) {
75 if ( state == ST_BEGIN ) {
78 if ( p > e ) { /* end of token */
91 void parseline( token, user )
94 char *p = pos, *t = token, *u, *q, buf[ MAXPATHLEN ];
98 while ( isspace( *p )) {
103 * If we've reached the end of the line, or a comment,
104 * don't return any more tokens.
106 if ( *p == '\0' || *p == '#' ) {
115 while ( *p != '\0' && ( quoted || !isspace( *p ))) {
131 * We got to the end of the line without closing an open quote
133 if ( *p == '\0' && quoted ) {
141 if ( *t == '\0' || *t == '/' ) {
148 if (( q = strchr( t, '/' )) == NULL ) {
155 if ( u == NULL || ( pwent = getpwnam( u )) == NULL ) {
159 strcpy( buf, pwent->pw_dir );
164 strcpy( token, buf );