X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=etc%2Fafpd%2Fgettok.c;fp=etc%2Fafpd%2Fgettok.c;h=0000000000000000000000000000000000000000;hp=fd48db688e1a56b39ca2d817efe00a15c6cf9f06;hb=b6f259d1c2d472b1b97b77eb2ca1374f07f2d6c0;hpb=29ac6c817273cf860569a0735608e0b9410659d8 diff --git a/etc/afpd/gettok.c b/etc/afpd/gettok.c deleted file mode 100644 index fd48db68..00000000 --- a/etc/afpd/gettok.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * $Id: gettok.c,v 1.6 2009-10-13 22:55:37 didg Exp $ - * - * Copyright (c) 1990,1994 Regents of The University of Michigan. - * All Rights Reserved. See COPYRIGHT. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include -#include -#include -#include - -#include - -static char *l_curr; -static char *l_end; - -void initline( int len, char *line) -{ - l_curr = line; - l_end = line + len; -} - -#define ST_QUOTE 0 -#define ST_WORD 1 -#define ST_BEGIN 2 - -int -parseline(int len, char *token) -{ - char *p, *e; - int state; - - state = ST_BEGIN; - p = token; - e = token + len; - - for (;;) { - if ( l_curr > l_end ) { /* end of line */ - *token = '\0'; - return( -1 ); - } - - switch ( *l_curr ) { - case '"' : - if ( state == ST_QUOTE ) { - state = ST_WORD; - } else { - state = ST_QUOTE; - } - break; - - case '\0' : - case '\t' : - case '\n' : - case ' ' : - if ( state == ST_WORD ) { - *p = '\0'; - return( p - token ); - } - if ( state != ST_QUOTE ) { - break; - } - /* FALL THROUGH */ - - default : - if ( state == ST_BEGIN ) { - state = ST_WORD; - } - if ( p > e ) { /* end of token */ - *token = '\0'; - return( -1 ); - } - *p++ = *l_curr; - break; - } - - l_curr++; - } -} - -#ifdef notdef -void parseline(char *token, char *user) -{ - char *p = pos, *t = token, *u, *q, buf[ MAXPATHLEN ]; - struct passwd *pwent; - int quoted = 0; - - while ( isspace( *p )) { - p++; - } - - /* - * If we've reached the end of the line, or a comment, - * don't return any more tokens. - */ - if ( *p == '\0' || *p == '#' ) { - *token = '\0'; - return; - } - - if ( *p == '"' ) { - p++; - quoted = 1; - } - while ( *p != '\0' && ( quoted || !isspace( *p ))) { - if ( *p == '"' ) { - if ( quoted ) { - *t = '\0'; - break; - } - quoted = 1; - p++; - } else { - *t++ = *p++; - } - } - pos = p; - *t = '\0'; - - /* - * We got to the end of the line without closing an open quote - */ - if ( *p == '\0' && quoted ) { - *token = '\0'; - return; - } - - t = token; - if ( *t == '~' ) { - t++; - if ( *t == '\0' || *t == '/' ) { - u = user; - if ( *t == '/' ) { - t++; - } - } else { - u = t; - if (( q = strchr( t, '/' )) == NULL ) { - t = ""; - } else { - *q = '\0'; - t = q + 1; - } - } - if ( u == NULL || ( pwent = getpwnam( u )) == NULL ) { - *token = '\0'; - return; - } - strcpy( buf, pwent->pw_dir ); - if ( *t != '\0' ) { - strcat( buf, "/" ); - strcat( buf, t ); - } - strcpy( token, buf ); - } - return; -} -#endif /* notdef */