2 * $Id: gettok.c,v 1.6 2009-10-13 22:55:37 didg 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 #include <atalk/globals.h>
22 void initline( int len, char *line)
33 parseline(int len, char *token)
43 if ( l_curr > l_end ) { /* end of line */
50 if ( state == ST_QUOTE ) {
61 if ( state == ST_WORD ) {
65 if ( state != ST_QUOTE ) {
71 if ( state == ST_BEGIN ) {
74 if ( p > e ) { /* end of token */
87 void parseline(char *token, char *user)
89 char *p = pos, *t = token, *u, *q, buf[ MAXPATHLEN ];
93 while ( isspace( *p )) {
98 * If we've reached the end of the line, or a comment,
99 * don't return any more tokens.
101 if ( *p == '\0' || *p == '#' ) {
110 while ( *p != '\0' && ( quoted || !isspace( *p ))) {
126 * We got to the end of the line without closing an open quote
128 if ( *p == '\0' && quoted ) {
136 if ( *t == '\0' || *t == '/' ) {
143 if (( q = strchr( t, '/' )) == NULL ) {
150 if ( u == NULL || ( pwent = getpwnam( u )) == NULL ) {
154 strcpy( buf, pwent->pw_dir );
159 strcpy( token, buf );