]> arthur.barton.de Git - netatalk.git/commitdiff
Move (unused) file gettok.c to libatalk
authorFrank Lahm <franklahm@googlemail.com>
Sun, 14 Oct 2012 10:05:12 +0000 (12:05 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Sun, 14 Oct 2012 10:05:12 +0000 (12:05 +0200)
etc/afpd/Makefile.am
etc/afpd/gettok.c [deleted file]
include/atalk/globals.h
include/atalk/util.h
libatalk/libatalk-3.0.1dev.abi
libatalk/util/Makefile.am
libatalk/util/gettok.c [new file with mode: 0644]

index 85b51dc86bdca8971ecb85ce94c66c1273c28e21..1cb8913ad872fd452a7b05d6e513ea12a888f6ee 100644 (file)
@@ -28,7 +28,6 @@ afpd_SOURCES = \
        file.c \
        filedir.c \
        fork.c \
-       gettok.c \
        hash.c \
        main.c \
        mangle.c \
diff --git a/etc/afpd/gettok.c b/etc/afpd/gettok.c
deleted file mode 100644 (file)
index fd48db6..0000000
+++ /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 <sys/param.h>
-#include <string.h>
-#include <ctype.h>
-#include <pwd.h>
-
-#include <atalk/globals.h>
-
-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 */
index b8412d15d7c7b300f8b90b3c94a58ddeb96e374b..36508e17cc470b1431ef549b1e398c1ce4e475a1 100644 (file)
@@ -151,10 +151,6 @@ extern void afp_options_free(struct afp_options *);
 extern void setmessage (const char *);
 extern void readmessage (AFPObj *);
 
-/* gettok.c */
-extern void initline   (int, char *);
-extern int  parseline  (int, char *);
-
 /* afp_util.c */
 extern const char *AfpNum2name (int );
 extern const char *AfpErr2name(int err);
index 9ff6813f9f36ca36c643e48bcc2ace9e34a99d9b..39237e7c62c43806e76463c570b47c6033aa62da 100644 (file)
@@ -190,4 +190,11 @@ extern char *realpath_safe(const char *path);
 
 extern bstring rel_path_in_vol(const char *path, const char *volpath);
 
+/******************************************************************
+ * cnid.c
+ *****************************************************************/
+
+extern void initline   (int, char *);
+extern int  parseline  (int, char *);
+
 #endif  /* _ATALK_UTIL_H */
index 645af2b1a6fb081fef6b134014890041ae0bdbb0..fd06b366579413bc28518d8de3fc53a2c19653dd 100644 (file)
@@ -309,6 +309,7 @@ iniparser_set: int (dictionary *, char *, char *, char *)
 iniparser_unset: void (dictionary *, char *, char *)
 _init: <text variable, no debug info>
 init_iconv: void (void)
+initline: void (int, char *)
 initvol_vfs: void (struct vol *)
 ipc_child_write: int (int, uint16_t, int, void *)
 ipc_client_uds: int (const char *)
@@ -356,6 +357,7 @@ netatalk_unlinkat: int (int, const char *)
 nftw: int (const char *, nftw_func_t, dir_notification_func_t, int, int)
 opendirat: DIR *(int, const char *)
 openflags2logstr: const char *(int)
+parseline: int (int, char *)
 posix_chmod: int (const char *, mode_t)
 posix_fchmod: int (int, mode_t)
 precompose_w: size_t (uint16_t *, size_t, uint16_t *, size_t *)
index 65ad1d6ca9704b8e535a1aa6e71d2d1b5847e7fd..201951664cd4d81b2da6445ca4ebeb866f99be8d 100644 (file)
@@ -9,6 +9,7 @@ libutil_la_SOURCES = \
        cnid.c          \
        fault.c         \
        getiface.c      \
+       gettok.c        \
        locking.c   \
        logger.c        \
        module.c        \
diff --git a/libatalk/util/gettok.c b/libatalk/util/gettok.c
new file mode 100644 (file)
index 0000000..fd48db6
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * $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 <sys/param.h>
+#include <string.h>
+#include <ctype.h>
+#include <pwd.h>
+
+#include <atalk/globals.h>
+
+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 */