From 6ee7ecd6892a1750128dcced1410e76b5e166874 Mon Sep 17 00:00:00 2001 From: franklahm Date: Mon, 1 Feb 2010 10:56:08 +0000 Subject: [PATCH] commit dircache rewrite. ---------------------------------------------------------------------- Modified Files: Tag: branch-dircache-rewrite Makefile.am configure.in etc/afpd/Makefile.am etc/afpd/afp_dsi.c etc/afpd/appl.c etc/afpd/catsearch.c etc/afpd/desktop.c etc/afpd/directory.c etc/afpd/directory.h etc/afpd/enumerate.c etc/afpd/file.c etc/afpd/file.h etc/afpd/filedir.c etc/afpd/globals.h etc/afpd/mangle.c etc/afpd/ofork.c etc/afpd/volume.c include/atalk/Makefile.am include/atalk/directory.h include/atalk/volume.h libatalk/Makefile.am libatalk/util/Makefile.am Added Files: Tag: branch-dircache-rewrite etc/afpd/dircache.c etc/afpd/dircache.h include/atalk/bstradd.h include/atalk/bstrlib.h include/atalk/queue.h libatalk/bstring/.cvsignore libatalk/bstring/Makefile.am libatalk/bstring/bstradd.c libatalk/bstring/bstrlib.c libatalk/util/queue.c test/.cvsignore test/Makefile.am test/afpd/.cvsignore test/afpd/Makefile test/afpd/Makefile.am test/afpd/Makefile.in test/afpd/afpfunc_helpers.c test/afpd/afpfunc_helpers.h test/afpd/subtests.c test/afpd/subtests.h test/afpd/test.c test/afpd/test.h test/afpd/test.sh ---------------------------------------------------------------------- --- Makefile.am | 2 +- configure.in | 7 +- etc/afpd/Makefile.am | 5 +- etc/afpd/afp_dsi.c | 6 +- etc/afpd/appl.c | 69 +- etc/afpd/catsearch.c | 13 +- etc/afpd/desktop.c | 7 +- etc/afpd/dircache.c | 440 +++++ etc/afpd/dircache.h | 34 + etc/afpd/directory.c | 2209 ++++++++++--------------- etc/afpd/directory.h | 71 +- etc/afpd/enumerate.c | 24 +- etc/afpd/file.c | 4 +- etc/afpd/file.h | 4 +- etc/afpd/filedir.c | 243 ++- etc/afpd/globals.h | 5 +- etc/afpd/mangle.c | 12 +- etc/afpd/ofork.c | 41 +- etc/afpd/volume.c | 38 +- include/atalk/Makefile.am | 2 +- include/atalk/bstradd.h | 41 + include/atalk/bstrlib.h | 300 ++++ include/atalk/directory.h | 44 +- include/atalk/queue.h | 40 + include/atalk/volume.h | 6 +- libatalk/Makefile.am | 4 +- libatalk/bstring/.cvsignore | 6 + libatalk/bstring/Makefile.am | 6 + libatalk/bstring/bstradd.c | 208 +++ libatalk/bstring/bstrlib.c | 2956 ++++++++++++++++++++++++++++++++++ libatalk/util/Makefile.am | 1 + libatalk/util/queue.c | 98 ++ test/.cvsignore | 2 + test/Makefile.am | 1 + test/afpd/.cvsignore | 6 + test/afpd/Makefile | 1115 +++++++++++++ test/afpd/Makefile.am | 52 + test/afpd/Makefile.in | 1115 +++++++++++++ test/afpd/afpfunc_helpers.c | 237 +++ test/afpd/afpfunc_helpers.h | 57 + test/afpd/subtests.c | 71 + test/afpd/subtests.h | 45 + test/afpd/test.c | 124 ++ test/afpd/test.h | 77 + test/afpd/test.sh | 24 + 45 files changed, 8263 insertions(+), 1609 deletions(-) create mode 100644 etc/afpd/dircache.c create mode 100644 etc/afpd/dircache.h create mode 100644 include/atalk/bstradd.h create mode 100755 include/atalk/bstrlib.h create mode 100644 include/atalk/queue.h create mode 100644 libatalk/bstring/.cvsignore create mode 100644 libatalk/bstring/Makefile.am create mode 100644 libatalk/bstring/bstradd.c create mode 100755 libatalk/bstring/bstrlib.c create mode 100644 libatalk/util/queue.c create mode 100644 test/.cvsignore create mode 100644 test/Makefile.am create mode 100644 test/afpd/.cvsignore create mode 100644 test/afpd/Makefile create mode 100644 test/afpd/Makefile.am create mode 100644 test/afpd/Makefile.in create mode 100644 test/afpd/afpfunc_helpers.c create mode 100644 test/afpd/afpfunc_helpers.h create mode 100644 test/afpd/subtests.c create mode 100644 test/afpd/subtests.h create mode 100644 test/afpd/test.c create mode 100644 test/afpd/test.h create mode 100755 test/afpd/test.sh diff --git a/Makefile.am b/Makefile.am index 44ac0453..45abaa1b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # Makefile.am for top level of netatalk package -SUBDIRS = libatalk bin config etc man contrib distrib include sys doc macros +SUBDIRS = libatalk bin config etc man contrib distrib include sys doc macros test EXTRA_DIST = CONTRIBUTORS COPYRIGHT COPYING NEWS\ TODO VERSION services.atalk diff --git a/configure.in b/configure.in index eaa9488f..a68111bf 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.237 2010-01-26 18:13:48 franklahm Exp $ +dnl $Id: configure.in,v 1.237.2.1 2010-02-01 10:56:08 franklahm Exp $ dnl configure.in for netatalk AC_INIT(etc/afpd/main.c) @@ -278,9 +278,11 @@ AC_ARG_ENABLE(debug, AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) + AC_DEFINE(NDEBUG, 1, [Disable assertions]) fi ],[ AC_MSG_RESULT([no]) + AC_DEFINE(NDEBUG, 1, [Disable assertions]) ] ) @@ -1241,6 +1243,7 @@ AC_OUTPUT([Makefile libatalk/adouble/Makefile libatalk/asp/Makefile libatalk/atp/Makefile + libatalk/bstring/Makefile libatalk/cnid/Makefile libatalk/cnid/cdb/Makefile libatalk/cnid/last/Makefile @@ -1272,6 +1275,8 @@ AC_OUTPUT([Makefile sys/solaris/Makefile sys/sunos/Makefile sys/ultrix/Makefile + test/Makefile + test/afpd/Makefile ], [chmod a+x distrib/config/netatalk-config contrib/shell_utils/apple_*] ) diff --git a/etc/afpd/Makefile.am b/etc/afpd/Makefile.am index 9cab23c4..ae937ecc 100644 --- a/etc/afpd/Makefile.am +++ b/etc/afpd/Makefile.am @@ -9,7 +9,7 @@ afpd_SOURCES = unix.c ofork.c main.c switch.c auth.c volume.c directory.c \ file.c enumerate.c desktop.c filedir.c fork.c appl.c gettok.c \ mangle.c status.c afp_options.c afp_asp.c afp_dsi.c messages.c \ afp_config.c nfsquota.c quota.c uam.c afs.c uid.c afp_util.c \ - catsearch.c afprun.c hash.c extattrs.c + catsearch.c afprun.c hash.c extattrs.c dircache.c if USE_NFSv4_ACLS afpd_SOURCES += acls.c @@ -30,7 +30,8 @@ afpd_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/sys \ noinst_HEADERS = auth.h afp_config.h desktop.h directory.h file.h \ filedir.h fork.h globals.h icon.h mangle.h misc.h status.h switch.h \ - uam_auth.h uid.h unix.h volume.h hash.h acls.h acl_mappings.h extattrs.h + uam_auth.h uid.h unix.h volume.h hash.h acls.h acl_mappings.h extattrs.h \ + dircache.h hash_SOURCES = hash.c hash_CFLAGS = -DKAZLIB_TEST_MAIN -I$(top_srcdir)/include diff --git a/etc/afpd/afp_dsi.c b/etc/afpd/afp_dsi.c index 041db2ce..22ef5fc7 100644 --- a/etc/afpd/afp_dsi.c +++ b/etc/afpd/afp_dsi.c @@ -1,5 +1,5 @@ /* - * $Id: afp_dsi.c,v 1.49 2010-01-18 12:55:28 franklahm Exp $ + * $Id: afp_dsi.c,v 1.49.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu) * Copyright (c) 1990,1993 Regents of The University of Michigan. @@ -37,6 +37,7 @@ #include "switch.h" #include "auth.h" #include "fork.h" +#include "dircache.h" #ifdef FORCE_UIDGID #warning UIDGID @@ -337,6 +338,9 @@ void afp_over_dsi(AFPObj *obj) } #endif /* DEBUGGING */ + if (dircache_init(0) != 0) + afp_dsi_die(EXITERR_SYS); + /* get stuck here until the end */ while ((cmd = dsi_receive(dsi))) { child.tickle = 0; diff --git a/etc/afpd/appl.c b/etc/afpd/appl.c index 37850f62..d7e72f23 100644 --- a/etc/afpd/appl.c +++ b/etc/afpd/appl.c @@ -1,5 +1,5 @@ /* - * $Id: appl.c,v 1.18 2009-10-15 10:43:13 didg Exp $ + * $Id: appl.c,v 1.18.4.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -20,6 +20,8 @@ #include #include +#include +#include #include "volume.h" #include "globals.h" @@ -122,7 +124,7 @@ static int copyapplfile(int sfd, int dfd, char *mpath, u_short mplen) * See afp_getappl() for the backward compatiblity code. */ static char * -makemacpath(char *mpath, int mpathlen, struct dir *dir, char *path) +makemacpath(const struct vol *vol, char *mpath, int mpathlen, struct dir *dir, char *path) { char *p; @@ -130,16 +132,65 @@ makemacpath(char *mpath, int mpathlen, struct dir *dir, char *path) p -= strlen( path ); memcpy( p, path, strlen( path )); - while ( dir->d_parent != NULL ) { - p -= strlen( dir->d_m_name ) + 1; + while ( dir->d_did != DIRDID_ROOT ) { + p -= blength(dir->d_m_name) + 1; if (p < mpath) { /* FIXME: pathname too long */ return NULL; } - strcpy( p, dir->d_m_name ); - dir = dir->d_parent; + memcpy(p, cfrombstring(dir->d_m_name), blength(dir->d_m_name) + 1); + if ((dir = dirlookup(vol, dir->d_pdid)) == NULL) + return NULL; } return( p ); + + +#if 0 + char buffer[12 + MAXPATHLEN + 1]; + int buflen = 12 + MAXPATHLEN + 1; + char *ret = mpath; + char *path = name; + char *uname = NULL; + struct bstrList *pathlist = NULL; + cnid_t cnid = dir->d_pdid; + + /* Create list for path elements, request 16 list elements for now*/ + if ((pathlist = bstListCreateMin(16)) == NULL) { + LOG(log_error, logtype_afpd, "makemacpath: OOM: %s", strerror(errno)); + return NULL; + } + + while ( cnid != DIRDID_ROOT ) { + + /* construct path, copy already found uname to path element list*/ + if ((bstrListPush(pathlist, bfromcstr(path))) != BSTR_OK) { + afp_errno = AFPERR_MISC; + ret = NULL; + goto exit; + } + + /* next part */ + if ((uname = cnid_resolve(vol->v_cdb, &cnid, buffer, buflen)) == NULL ) { + afp_errno = AFPERR_NOOBJ; + ret = NULL; + goto exit; + } + + if ((path = utompath(vol, uname, cnid, utf8_encoding())) == NULL) { + afp_errno = AFPERR_MISC; + ret = NULL; + goto exit; + } + } + + + +exit: + if (pathlist) + bstrListDestroy(pathlist); + + return(ret); +#endif } @@ -197,7 +248,7 @@ int afp_addappl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, siz return( AFPERR_PARAM ); } mpath = obj->newtmp; - mp = makemacpath( mpath, AFPOBJ_TMPSIZ, curdir, path->m_name ); + mp = makemacpath( vol, mpath, AFPOBJ_TMPSIZ, curdir, path->m_name ); if (!mp) { return AFPERR_PARAM; } @@ -280,7 +331,7 @@ int afp_rmvappl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, siz return( AFPERR_PARAM ); } mpath = obj->newtmp; - mp = makemacpath( mpath, AFPOBJ_TMPSIZ, curdir, path->m_name ); + mp = makemacpath( vol, mpath, AFPOBJ_TMPSIZ, curdir, path->m_name ); if (!mp) { return AFPERR_PARAM ; } @@ -418,7 +469,7 @@ int afp_getappl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t memcpy( q, p, len ); q = cbuf; - if (( path = cname( vol, vol->v_dir, &q )) == NULL ) { + if (( path = cname( vol, vol->v_root, &q )) == NULL ) { *rbuflen = 0; return( AFPERR_NOITEM ); } diff --git a/etc/afpd/catsearch.c b/etc/afpd/catsearch.c index ccbdd80f..24094c8d 100644 --- a/etc/afpd/catsearch.c +++ b/etc/afpd/catsearch.c @@ -51,6 +51,7 @@ #endif /* CNID_DB */ #include "desktop.h" #include "directory.h" +#include "dircache.h" #include "file.h" #include "volume.h" #include "globals.h" @@ -537,7 +538,8 @@ static int catsearch(struct vol *vol, struct dir *dir, cached = 1; if (dirpos == NULL) { dirpos = opendir(dstack[cidx].path); - cached = (dstack[cidx].dir->d_child != NULL); +// FIXME dircache rewrite +// cached = (dstack[cidx].dir->d_child != NULL); } if (dirpos == NULL) { switch (errno) { @@ -588,18 +590,19 @@ static int catsearch(struct vol *vol, struct dir *dir, ie if in the same loop the parent dir wasn't in the cache ALL dirsearch_byname will fail. */ + int unlen = strlen(path.u_name); if (cached) - path.d_dir = dirsearch_byname(vol, dstack[cidx].dir, path.u_name); + path.d_dir = dircache_search_by_name(vol, dstack[cidx].dir->d_did, path.u_name, unlen); else path.d_dir = NULL; if (!path.d_dir) { /* path.m_name is set by adddir */ - if (NULL == (path.d_dir = adddir( vol, dstack[cidx].dir, &path) ) ) { + if (NULL == (path.d_dir = dir_add( vol, dstack[cidx].dir, &path, unlen) ) ) { result = AFPERR_MISC; goto catsearch_end; } } - path.m_name = path.d_dir->d_m_name; + path.m_name = (char *)path.d_dir->d_m_name->data; if (addstack(path.u_name, path.d_dir, cidx) == -1) { result = AFPERR_MISC; @@ -863,7 +866,7 @@ static int catsearch_afp(AFPObj *obj _U_, char *ibuf, size_t ibuflen, /* Call search */ *rbuflen = 24; - ret = catsearch(vol, vol->v_dir, rmatches, &catpos[0], rbuf+24, &nrecs, &rsize, ext); + ret = catsearch(vol, vol->v_root, rmatches, &catpos[0], rbuf+24, &nrecs, &rsize, ext); memcpy(rbuf, catpos, sizeof(catpos)); rbuf += sizeof(catpos); diff --git a/etc/afpd/desktop.c b/etc/afpd/desktop.c index 5db36f71..9f105e13 100644 --- a/etc/afpd/desktop.c +++ b/etc/afpd/desktop.c @@ -1,5 +1,5 @@ /* - * $Id: desktop.c,v 1.50 2010-01-22 04:40:38 didg Exp $ + * $Id: desktop.c,v 1.50.2.1 2010-02-01 10:56:08 franklahm Exp $ * * See COPYRIGHT. * @@ -600,7 +600,8 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8) u_int16_t flags; if ( *mpath == '\0' ) { - return( "." ); + strcpy(upath, "."); + return upath; } /* set conversion flags */ @@ -700,7 +701,7 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf) if (ad_getentryoff(adp, ADEID_COMMENT)) { if ( (ad_get_MD_flags( adp ) & O_CREAT) ) { if ( *path->m_name == '\0' ) { - name = curdir->d_m_name; + name = (char *)curdir->d_m_name->data; } else { name = path->m_name; } diff --git a/etc/afpd/dircache.c b/etc/afpd/dircache.c new file mode 100644 index 00000000..6e4f2242 --- /dev/null +++ b/etc/afpd/dircache.c @@ -0,0 +1,440 @@ +/* + $Id: dircache.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dircache.h" +#include "directory.h" +#include "hash.h" +#include "globals.h" + +/* + * Dircache and indexes + * ==================== + * The maximum dircache size is: + * max(DEFAULT_MAX_DIRCACHE_SIZE, min(size, MAX_POSSIBLE_DIRCACHE_SIZE)). + * It is a hashtable which we use to store "struct dir"s in. If the cache get full, oldest + * entries are evicted in chunks of DIRCACHE_FREE. + * We have/need two indexes: + * - a DID/name index on the main dircache, another hashtable + * - a queue index on the dircache, for evicting the oldest entries + */ + +/******************************************************** + * Local funcs and variables + ********************************************************/ + +/***************************** + * THE dircache */ + +/* Maximum size of the dircache hashtable */ +#define DEFAULT_MAX_DIRCACHE_SIZE 8192 /* FIXME: make it a afpd.conf option */ +#define MAX_POSSIBLE_DIRCACHE_SIZE 131072 + +static hash_t *dircache; /* The actual cache */ +static unsigned int dircache_maxsize; /* cache maximum size */ + +/* FNV 1a */ +static hash_val_t hash_vid_did(const void *key) +{ + const struct dir *k = (const struct dir *)key; + hash_val_t hash = 2166136261; + + hash ^= k->d_vid >> 8; + hash *= 16777619; + hash ^= k->d_vid; + hash *= 16777619; + + hash ^= k->d_did >> 24; + hash *= 16777619; + hash ^= (k->d_did >> 16) & 0xff; + hash *= 16777619; + hash ^= (k->d_did >> 8) & 0xff; + hash *= 16777619; + hash ^= (k->d_did >> 0) & 0xff; + hash *= 16777619; + + return hash; +} + +static int hash_comp_vid_did(const void *key1, const void *key2) +{ + const struct dir *k1 = key1; + const struct dir *k2 = key2; + + return !(k1->d_did == k2->d_did && k1->d_vid == k2->d_vid); +} + +/************************************************** + * DID/name index on dircache (another hashtable) */ + +static hash_t *index_didname; + +#undef get16bits +#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ + || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) +#define get16bits(d) (*((const uint16_t *) (d))) +#endif + +#if !defined (get16bits) +#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ + +(uint32_t)(((const uint8_t *)(d))[0]) ) +#endif + +static hash_val_t hash_didname(const void *p) +{ + const struct dir *key = (const struct dir *)p; + const unsigned char *data = key->d_u_name->data; + int len = key->d_u_name->slen; + hash_val_t hash = key->d_pdid + key->d_vid; + hash_val_t tmp; + + int rem = len & 3; + len >>= 2; + + /* Main loop */ + for (;len > 0; len--) { + hash += get16bits (data); + tmp = (get16bits (data+2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + data += 2*sizeof (uint16_t); + hash += hash >> 11; + } + + /* Handle end cases */ + switch (rem) { + case 3: hash += get16bits (data); + hash ^= hash << 16; + hash ^= data[sizeof (uint16_t)] << 18; + hash += hash >> 11; + break; + case 2: hash += get16bits (data); + hash ^= hash << 11; + hash += hash >> 17; + break; + case 1: hash += *data; + hash ^= hash << 10; + hash += hash >> 1; + } + + /* Force "avalanching" of final 127 bits */ + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + + return hash; +} + +static int hash_comp_didname(const void *k1, const void *k2) +{ + const struct dir *key1 = (const struct dir *)k1; + const struct dir *key2 = (const struct dir *)k2; + + return ! (key1->d_vid == key2->d_vid + && key1->d_pdid == key2->d_pdid + && (bstrcmp(key1->d_u_name, key2->d_u_name) == 0) ); +} + +/*************************** + * queue index on dircache */ + +static queue_t *index_queue; /* the index itself */ +static unsigned int queue_count; +static const int dircache_free_quantum = 256; /* number of entries to free */ + +/*! + * @brief Remove a fixed number of (oldest) entries from the cache and indexes + * + * The default is to remove the 256 oldest entries from the cache. + * 1. Get the oldest entry + * 2. If it's in use ie open forks reference it, requeue it, dont remove it + * 3. Remove the dir from the main cache and the didname index + * 4. Free the struct dir structure and all its members + */ +static void dircache_evict(void) +{ + int i = dircache_free_quantum; + struct dir *dir; + + while (i--) { + if ((dir = (struct dir *)dequeue(index_queue)) == NULL) { /* 1 */ + dircache_dump(); + exit(EXITERR_SYS); + } + queue_count--; + + if (dir->d_ofork) { /* 2 */ + if ((dir->qidx_node = enqueue(index_queue, dir)) == NULL) { + dircache_dump(); + exit(EXITERR_SYS); + } + queue_count++; + continue; + } + + dircache_remove(NULL, dir, DIRCACHE | DIDNAME_INDEX); /* 3 */ + dir_free(dir); /* 4 */ + } + + assert(queue_count == dircache->hash_nodecount); + assert(queue_count + dircache_free_quantum <= dircache_maxsize); +} + + +/******************************************************** + * Interface + ********************************************************/ + +/*! + * @brief Search the dircache via a DID + * + * @param vol (r) pointer to struct vol + * @param did (r) CNID of the directory + * + * @returns Pointer to struct dir if found, else NULL + */ +struct dir *dircache_search_by_did(const struct vol *vol, cnid_t did) +{ + struct dir *cdir = NULL; + struct dir key; + hnode_t *hn; + + assert(vol); + assert(ntohl(did) >= CNID_START); + + key.d_vid = vol->v_vid; + key.d_did = did; + if ((hn = hash_lookup(dircache, &key))) + cdir = hnode_get(hn); + + if (cdir) + LOG(log_debug, logtype_afpd, "dircache(did:%u): {cached: path:'%s'}", ntohl(did), cfrombstring(cdir->d_fullpath)); + else + LOG(log_debug, logtype_afpd, "dircache(did:%u): {not in cache}", ntohl(did)); + + return cdir; +} + +/*! + * @brief Search the cache via did/name hashtable + * + * @param vol (r) volume + * @param did (r) directory CNID + * @param name (r) name (server side encoding) + * @parma len (r) strlen of name + * + * @returns pointer to struct dir if found in cache, else NULL + */ +struct dir *dircache_search_by_name(const struct vol *vol, cnid_t did, char *name, int len) +{ + struct dir *cdir = NULL; + struct dir key; + hnode_t *hn; + static_bstring uname = {-1, len, (unsigned char *)name}; + + assert(vol != NULL && name != NULL && len && len < 256); + + if ((did && did != DIRDID_ROOT_PARENT)) { + key.d_vid = vol->v_vid; + key.d_pdid = did; + key.d_u_name = &uname; + + if ((hn = hash_lookup(index_didname, &key))) + cdir = hnode_get(hn); + } + + if (cdir) + LOG(log_debug, logtype_afpd, "dircache(did:%u,'%s'): {cached: path:'%s'}", ntohl(did), name, cfrombstring(cdir->d_fullpath)); + else + LOG(log_debug, logtype_afpd, "dircache(did:%u,'%s'): {not in cache}", ntohl(did), name); + + return cdir; +} + +/*! + * @brief create struct dir from struct path + * + * Add a struct dir to the cache and its indexes. + * + * @param dir (r) pointer to parrent directory + * + * @returns 0 on success, -1 on error which should result in an abort + */ +int dircache_add(struct dir *dir) +{ + assert(dir != NULL + && ntohl(dir->d_pdid) >= 2 + && ntohl(dir->d_did) >= CNID_START + && dir->d_fullpath != NULL + && dir->d_u_name != NULL + && dir->d_vid != 0 + && dircache->hash_nodecount <= dircache_maxsize); + + /* Check if cache is full */ + if (dircache->hash_nodecount == dircache_maxsize) + dircache_evict(); + + /* Add it to the main dircache */ + if (hash_alloc_insert(dircache, dir, dir) == 0) { + dircache_dump(); + exit(EXITERR_SYS); + } + + /* Add it to the did/name index */ + if (hash_alloc_insert(index_didname, dir, dir) == 0) { + dircache_dump(); + exit(EXITERR_SYS); + } + + /* Add it to the fifo queue index */ + if ((dir->qidx_node = enqueue(index_queue, dir)) == NULL) { + dircache_dump(); + exit(EXITERR_SYS); + } else { + queue_count++; + } + + assert(queue_count == index_didname->hash_nodecount + && queue_count == dircache->hash_nodecount); + + return 0; +} + +/*! + * @brief Remove an entry from the dircache + * + * FIXME what about opened forks with refs to it? + * it's an afp specs violation because you can't delete + * an opened forks. Now afpd doesn't care about forks opened by other + * process. It's fixable within afpd if fnctl_lock, doable with smb and + * next to impossible for nfs and local filesystem access. + */ +void dircache_remove(const struct vol *vol _U_, struct dir *dir, int flags) +{ + hnode_t *hn; + + assert(dir); + assert((flags & ~(QUEUE_INDEX | DIDNAME_INDEX | DIRCACHE)) == 0); + + if (flags & QUEUE_INDEX) { + /* remove it from the queue index */ + dequeue(dir->qidx_node->prev); /* this effectively deletes the dequeued node */ + queue_count--; + } + + if (flags & DIDNAME_INDEX) { + if ((hn = hash_lookup(index_didname, dir)) == NULL) { + LOG(log_error, logtype_default, "dircache_remove(%u,%s): not in didname index", + ntohl(dir->d_did), cfrombstring(dir->d_fullpath)); + dircache_dump(); + exit(EXITERR_SYS); + } + hash_delete(index_didname, hn); + } + + if (flags & DIRCACHE) { + if ((hn = hash_lookup(dircache, dir)) == NULL) { + LOG(log_error, logtype_default, "dircache_remove(%u,%s): not in dircache", + ntohl(dir->d_did), cfrombstring(dir->d_fullpath)); + dircache_dump(); + exit(EXITERR_SYS); + } + hash_delete(dircache, hn); + } + + assert(queue_count == index_didname->hash_nodecount + && queue_count == dircache->hash_nodecount); +} + +/*! + * @brief Initialize the dircache and indexes + * + * This is called in child afpd initialisation. The maximum cache size will be + * max(DEFAULT_MAX_DIRCACHE_SIZE, min(size, MAX_POSSIBLE_DIRCACHE_SIZE)). + * It initializes a hashtable which we use to store a directory cache in. + * It also initializes two indexes: + * - a DID/name index on the main dircache + * - a queue index on the dircache + * + * @param size (r) requested maximum size from afpd.conf + * + * @return 0 on success, -1 on error + */ +int dircache_init(int reqsize) +{ + dircache_maxsize = DEFAULT_MAX_DIRCACHE_SIZE; + + /* Initialize the main dircache */ + if (reqsize > DEFAULT_MAX_DIRCACHE_SIZE && reqsize < MAX_POSSIBLE_DIRCACHE_SIZE) { + while ((dircache_maxsize < MAX_POSSIBLE_DIRCACHE_SIZE) && (dircache_maxsize < reqsize)) + dircache_maxsize *= 2; + } + if ((dircache = hash_create(dircache_maxsize, hash_comp_vid_did, hash_vid_did)) == NULL) + return -1; + + LOG(log_debug, logtype_afpd, "dircache_init: done. max dircache size: %u", dircache_maxsize); + + /* Initialize did/name index hashtable */ + if ((index_didname = hash_create(dircache_maxsize, hash_comp_didname, hash_didname)) == NULL) + return -1; + + /* Initialize index queue */ + if ((index_queue = queue_init()) == NULL) + return -1; + else + queue_count = 0; + + /* As long as directory.c hasn't got its own initializer call, we do it for it */ + rootParent.d_did = DIRDID_ROOT_PARENT; + rootParent.d_fullpath = bfromcstr(""); + rootParent.d_u_name = bfromcstr(""); + rootParent.d_m_name = bfromcstr(""); + + return 0; +} + +/*! + + FIXME: TO DO !!! + + * @brief Dump dircache to /tmp/dircache.PID + + */ +void dircache_dump(void) +{ + LOG(log_error, logtype_afpd, "Fatal directory cache corruption. Dumping...\n"); + + return; +} diff --git a/etc/afpd/dircache.h b/etc/afpd/dircache.h new file mode 100644 index 00000000..88c15f2a --- /dev/null +++ b/etc/afpd/dircache.h @@ -0,0 +1,34 @@ +/* + $Id: dircache.h,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + */ + +#ifndef DIRCACHE_H +#define DIRCACHE_H + +#include +#include + +/* flags for dircache_remove */ +#define DIRCACHE (1 << 0) +#define DIDNAME_INDEX (1 << 1) +#define QUEUE_INDEX (1 << 2) + +extern int dircache_init(int reqsize); +extern int dircache_add(struct dir *); +extern void dircache_remove(const struct vol *, struct dir *, int flag); +extern struct dir *dircache_search_by_did(const struct vol *vol, cnid_t did); +extern struct dir *dircache_search_by_name(const struct vol *, cnid_t did, char *name, int len); +extern void dircache_dump(void); + +#endif /* DIRCACHE_H */ diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 11c6de7e..4bdd6bee 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,42 +1,24 @@ /* - * $Id: directory.c,v 1.131 2010-01-26 20:39:52 didg Exp $ + * $Id: directory.c,v 1.131.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. - * - * 19 jan 2000 implemented red-black trees for directory lookups - * (asun@cobalt.com). */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ -/* STDC check */ -#if STDC_HEADERS #include -#else /* STDC_HEADERS */ -#ifndef HAVE_STRCHR -#define strchr index -#define strrchr index -#endif /* HAVE_STRCHR */ -char *strchr (), *strrchr (); -#ifndef HAVE_MEMCPY -#define memcpy(d,s,n) bcopy ((s), (d), (n)) -#define memmove(d,s,n) bcopy ((s), (d), (n)) -#endif /* ! HAVE_MEMCPY */ -#endif /* STDC_HEADERS */ -#ifdef HAVE_STRINGS_H -#include -#endif #include #include - #include #include #include +#include #include #include +#include #include #include @@ -46,8 +28,11 @@ char *strchr (), *strrchr (); #include #include #include +#include +#include #include "directory.h" +#include "dircache.h" #include "desktop.h" #include "volume.h" #include "fork.h" @@ -62,579 +47,530 @@ char *strchr (), *strrchr (); extern void addir_inherit_acl(const struct vol *vol); #endif -/* - * Directory caches - * ================ - * - * There are currently two cache structures where afpd caches directory information - * a) a DID/dirname cache in a hashtable - * b) a (red-black) tree with CNIDs as key - * - * a) is for searching by DID/dirname - * b) is for searching by CNID - * - * Through additional parent, child, previous and next pointers, b) is also used to - * represent the on-disk layout of the filesystem. parent and child point to parent - * and child directory respectively, linking 2 or more subdirectories in one - * directory with previous and next pointers. - * - * Usage examples, highlighting the main functions: - * - * a) is eg used in enumerate(): - * if IS_DIR - * dir = dirsearch_byname() // search in cache - * if (dir == NULL) // not found - * dir = adddir() // add to cache - * getdirparams() - * - * b) is eg used in afp_getfildirparams() - * dirlookup() // wrapper for cache and db search - * => dir = dirsearch() // search in cache - * if (dir) // found - * return - * else // not found, - * cnid_resolve() // resolve with CNID database - * cname() // add to cache - */ - -struct dir *curdir; -int afp_errno; - -#define SENTINEL (&sentinel) -static struct dir sentinel = { SENTINEL, SENTINEL, NULL, /* left, right, back */ - DIRTREE_COLOR_BLACK, /* color */ - NULL, NULL, /* parent, child */ - NULL, NULL, /* previous, next */ - NULL, 0, 0, /* oforks, did, flags */ - 0, 0, /* ctime, offcnt */ - NULL, NULL, NULL}; /* mname, uname, ucs2-name */ -static struct dir rootpar = { SENTINEL, SENTINEL, NULL, - 0, - NULL, NULL, - NULL, NULL, - NULL, 0, 0, - 0, 0, - NULL, NULL, NULL}; - -/* (from IM: Toolbox Essentials) - * dirFinderInfo (DInfo) fields: - * field bytes - * frRect 8 folder's window rectangle - * frFlags 2 flags - * frLocation 4 folder's location in window - * frView 2 folder's view (default == closedView (256)) - * - * extended dirFinderInfo (DXInfo) fields: - * frScroll 4 scroll position - * frOpenChain: 4 directory ID chain of open folders - * frScript: 1 script flag and code - * frXFlags: 1 reserved - * frComment: 2 comment ID - * frPutAway: 4 home directory ID +/* + * FIXMEs, loose ends after the dircache rewrite: + * o case-insensitivity is gone + * o setdirparams doesn't change parent mdate anymore + * o catsearch doesn't work, see FIXMEs in catsearch.c + * o curdir per volume caching is gone */ -static struct dir * -vol_tree_root(const struct vol *vol, u_int32_t did) -{ - struct dir *dir; - if (vol->v_curdir && vol->v_curdir->d_did == did) { - dir = vol->v_curdir; - } - else { - dir = vol->v_root; - } - return dir; -} +/******************************************************************************************* + * Globals + ******************************************************************************************/ -/* - * redid did assignment for directories. now we use red-black trees. - * how exciting. - */ -struct dir * -dirsearch(const struct vol *vol, u_int32_t did) -{ - struct dir *dir; +int afp_errno; +struct dir rootParent = { + NULL, NULL, NULL, NULL, /* path, d_m_name, d_u_name, d_m_name_ucs2 */ + NULL, NULL, 0, 0, /* qidx_node, d_ofork, ctime, d_flags */ + 0, 0, 0, 0 /* pdid, did, offcnt, d_vid */ +}; +struct dir *curdir = &rootParent; +struct path Cur_Path = { + 0, + "", /* mac name */ + ".", /* unix name */ + 0, /* id */ + NULL,/* struct dir */ + 0, /* stat is not set */ +}; - /* check for 0 did */ - if (!did) { - afp_errno = AFPERR_PARAM; - return NULL; - } - if ( did == DIRDID_ROOT_PARENT ) { - if (!rootpar.d_did) - rootpar.d_did = DIRDID_ROOT_PARENT; - rootpar.d_child = vol->v_dir; - return( &rootpar ); - } +/******************************************************************************************* + * Locals + ******************************************************************************************/ - dir = vol_tree_root(vol, did); - afp_errno = AFPERR_NOOBJ; - while ( dir != SENTINEL ) { - if (dir->d_did == did) - return dir->d_m_name ? dir : NULL; - dir = (dir->d_did > did) ? dir->d_left : dir->d_right; +/* ------------------------- + appledouble mkdir afp error code. +*/ +static int netatalk_mkdir(const char *name) +{ + if (ad_mkdir(name, DIRBITS | 0777) < 0) { + switch ( errno ) { + case ENOENT : + return( AFPERR_NOOBJ ); + case EROFS : + return( AFPERR_VLOCK ); + case EPERM: + case EACCES : + return( AFPERR_ACCESS ); + case EEXIST : + return( AFPERR_EXIST ); + case ENOSPC : + case EDQUOT : + return( AFPERR_DFULL ); + default : + return( AFPERR_PARAM ); + } } - return NULL; + return AFP_OK; } /* ------------------- */ -int get_afp_errno(const int param) +static int deletedir(char *dir) { - if (afp_errno != AFPERR_DID1) - return afp_errno; - return param; -} + char path[MAXPATHLEN + 1]; + DIR *dp; + struct dirent *de; + struct stat st; + size_t len; + int err = AFP_OK; + size_t remain; -/* ------------------- */ -struct dir * -dirsearch_byname( const struct vol *vol, struct dir *cdir, char *name) -{ - struct dir *dir = NULL; + if ((len = strlen(dir)) +2 > sizeof(path)) + return AFPERR_PARAM; + + /* already gone */ + if ((dp = opendir(dir)) == NULL) + return AFP_OK; - if ((cdir->d_did != DIRDID_ROOT_PARENT) && (cdir->d_child)) { - struct dir key; - hnode_t *hn; + strcpy(path, dir); + strcat(path, "/"); + len++; + remain = sizeof(path) -len -1; + while ((de = readdir(dp)) && err == AFP_OK) { + /* skip this and previous directory */ + if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) + continue; - key.d_parent = cdir; - key.d_u_name = name; - hn = hash_lookup(vol->v_hash, &key); - if (hn) { - dir = hnode_get(hn); + if (strlen(de->d_name) > remain) { + err = AFPERR_PARAM; + break; + } + strcpy(path + len, de->d_name); + if (stat(path, &st)) { + continue; + } + if (S_ISDIR(st.st_mode)) { + err = deletedir(path); + } else { + err = netatalk_unlink(path); } } - return dir; + closedir(dp); + + /* okay. the directory is empty. delete it. note: we already got rid + of .AppleDouble. */ + if (err == AFP_OK) { + err = netatalk_rmdir(dir); + } + return err; } -/* ----------------------------------------- - * if did is not in the cache resolve it with cnid - * - * FIXME - * OSX call it with bogus id, ie file ID not folder ID, - * and we are really bad in this case. - */ -struct dir * -dirlookup( struct vol *vol, u_int32_t did) +/* do a recursive copy. */ +static int copydir(const struct vol *vol, char *src, char *dst) { - struct dir *ret; - char *upath; - cnid_t id, cnid; - static char path[MAXPATHLEN + 1]; - size_t len, pathlen; - char *ptr; - static char buffer[12 + MAXPATHLEN + 1]; - int buflen = 12 + MAXPATHLEN + 1; - char *mpath; - int utf8; - size_t maxpath; + char spath[MAXPATHLEN + 1], dpath[MAXPATHLEN + 1]; + DIR *dp; + struct dirent *de; + struct stat st; + struct utimbuf ut; + size_t slen, dlen; + size_t srem, drem; + int err; - ret = dirsearch(vol, did); - if (ret != NULL || afp_errno == AFPERR_PARAM) - return ret; + /* doesn't exist or the path is too long. */ + if (((slen = strlen(src)) > sizeof(spath) - 2) || + ((dlen = strlen(dst)) > sizeof(dpath) - 2) || + ((dp = opendir(src)) == NULL)) + return AFPERR_PARAM; - utf8 = utf8_encoding(); - maxpath = (utf8)?MAXPATHLEN -7:255; - id = did; - if (NULL == (upath = cnid_resolve(vol->v_cdb, &id, buffer, buflen)) ) { - afp_errno = AFPERR_NOOBJ; - return NULL; - } - ptr = path + MAXPATHLEN; - if (NULL == ( mpath = utompath(vol, upath, did, utf8) ) ) { - afp_errno = AFPERR_NOOBJ; - return NULL; + /* try to create the destination directory */ + if (AFP_OK != (err = netatalk_mkdir(dst)) ) { + closedir(dp); + return err; } - len = strlen(mpath); - pathlen = len; /* no 0 in the last part */ - len++; - strcpy(ptr - len, mpath); - ptr -= len; - while (1) { - ret = dirsearch(vol,id); - if (ret != NULL) { - break; - } - cnid = id; - if ( NULL == (upath = cnid_resolve(vol->v_cdb, &id, buffer, buflen)) - || - NULL == (mpath = utompath(vol, upath, cnid, utf8)) - ) { - afp_errno = AFPERR_NOOBJ; - return NULL; - } - len = strlen(mpath) + 1; - pathlen += len; - if (pathlen > maxpath) { - afp_errno = AFPERR_PARAM; - return NULL; + /* set things up to copy */ + strcpy(spath, src); + strcat(spath, "/"); + slen++; + srem = sizeof(spath) - slen -1; + + strcpy(dpath, dst); + strcat(dpath, "/"); + dlen++; + drem = sizeof(dpath) - dlen -1; + + err = AFP_OK; + while ((de = readdir(dp))) { + /* skip this and previous directory */ + if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) + continue; + + if (strlen(de->d_name) > srem) { + err = AFPERR_PARAM; + break; } - strcpy(ptr - len, mpath); - ptr -= len; - } + strcpy(spath + slen, de->d_name); - /* fill the cache, another place where we know about the path type */ - if (utf8) { - u_int16_t temp16; - u_int32_t temp; + if (stat(spath, &st) == 0) { + if (strlen(de->d_name) > drem) { + err = AFPERR_PARAM; + break; + } + strcpy(dpath + dlen, de->d_name); - ptr -= 2; - temp16 = htons(pathlen); - memcpy(ptr, &temp16, sizeof(temp16)); + if (S_ISDIR(st.st_mode)) { + if (AFP_OK != (err = copydir(vol, spath, dpath))) + goto copydir_done; + } else if (AFP_OK != (err = copyfile(vol, vol, spath, dpath, NULL, NULL))) { + goto copydir_done; - temp = htonl(kTextEncodingUTF8); - ptr -= 4; - memcpy(ptr, &temp, sizeof(temp)); - ptr--; - *ptr = 3; + } else { + /* keep the same time stamp. */ + ut.actime = ut.modtime = st.st_mtime; + utime(dpath, &ut); + } + } } - else { - ptr--; - *ptr = (unsigned char)pathlen; - ptr--; - *ptr = 2; + + /* keep the same time stamp. */ + if (stat(src, &st) == 0) { + ut.actime = ut.modtime = st.st_mtime; + utime(dst, &ut); } - /* cname is not efficient */ - if (cname( vol, ret, &ptr ) == NULL ) - return NULL; - return dirsearch(vol, did); +copydir_done: + closedir(dp); + return err; } -/* child addition/removal */ -static void dirchildadd(const struct vol *vol, struct dir *a, struct dir *b) +/* --------------------- + * is our cached offspring count valid? + */ +static int diroffcnt(struct dir *dir, struct stat *st) { - if (!a->d_child) - a->d_child = b; - else { - b->d_next = a->d_child; - b->d_prev = b->d_next->d_prev; - b->d_next->d_prev = b; - b->d_prev->d_next = b; - } - if (!hash_alloc_insert(vol->v_hash, b, b)) { - LOG(log_error, logtype_afpd, "dirchildadd: can't hash %s", b->d_u_name); - } + return st->st_ctime == dir->ctime; } -static void dirchildremove(struct dir *a,struct dir *b) +/* --------------------- */ +static int invisible_dots(const struct vol *vol, const char *name) { - if (a->d_child == b) - a->d_child = (b == b->d_next) ? NULL : b->d_next; - b->d_next->d_prev = b->d_prev; - b->d_prev->d_next = b->d_next; - b->d_next = b->d_prev = b; + return vol_inv_dots(vol) && *name == '.' && strcmp(name, ".") && strcmp(name, ".."); } -/* --------------------------- */ -/* rotate the tree to the left */ -static void dir_leftrotate(struct vol *vol, struct dir *dir) +/* ------------------ */ +static int set_dir_errors(struct path *path, const char *where, int err) { - struct dir *right = dir->d_right; - - /* whee. move the right's left tree into dir's right tree */ - dir->d_right = right->d_left; - if (right->d_left != SENTINEL) - right->d_left->d_back = dir; - - if (right != SENTINEL) { - right->d_back = dir->d_back; - right->d_left = dir; + switch ( err ) { + case EPERM : + case EACCES : + return AFPERR_ACCESS; + case EROFS : + return AFPERR_VLOCK; } - - if (!dir->d_back) /* no parent. move the right tree to the top. */ - vol->v_root = right; - else if (dir == dir->d_back->d_left) /* we were on the left */ - dir->d_back->d_left = right; - else - dir->d_back->d_right = right; /* we were on the right */ - - /* re-insert dir on the left tree */ - if (dir != SENTINEL) - dir->d_back = right; + LOG(log_error, logtype_afpd, "setdirparam(%s): %s: %s", fullpathname(path->u_name), where, strerror(err) ); + return AFPERR_PARAM; } - - -/* rotate the tree to the right */ -static void dir_rightrotate(struct vol *vol, struct dir *dir) +/*! + * @brief Convert name in client encoding to server encoding + * + * Convert ret->m_name to ret->u_name from client encoding to server encoding. + * This only gets called from cname(). + * + * @returns 0 on success, -1 on error + * + * @note If the passed ret->m_name is mangled, we'll demangle it + */ +static int cname_mtouname(const struct vol *vol, const struct dir *dir, struct path *ret, int toUTF8) { - struct dir *left = dir->d_left; + static char temp[ MAXPATHLEN + 1]; + char *t; + cnid_t fileid; + + if (afp_version >= 30) { + if (toUTF8) { + if (dir->d_did == DIRDID_ROOT_PARENT) { + /* + * With uft8 volume name is utf8-mac, but requested path may be a mangled longname. See #2611981. + * So we compare it with the longname from the current volume and if they match + * we overwrite the requested path with the utf8 volume name so that the following + * strcmp can match. + */ + ucs2_to_charset(vol->v_maccharset, vol->v_macname, temp, AFPVOL_MACNAMELEN + 1); + if (strcasecmp(ret->m_name, temp) == 0) + ucs2_to_charset(CH_UTF8_MAC, vol->v_u8mname, ret->m_name, AFPVOL_U8MNAMELEN); + } else { + /* toUTF8 */ + if (mtoUTF8(vol, ret->m_name, strlen(ret->m_name), temp, MAXPATHLEN) == (size_t)-1) { + afp_errno = AFPERR_PARAM; + return -1; + } + strcpy(ret->m_name, temp); + } + } - /* whee. move the left's right tree into dir's left tree */ - dir->d_left = left->d_right; - if (left->d_right != SENTINEL) - left->d_right->d_back = dir; + /* check for OS X mangled filename :( */ + t = demangle_osx(vol, ret->m_name, dir->d_did, &fileid); + if (t != ret->m_name) { + ret->u_name = t; + /* duplicate work but we can't reuse all convert_char we did in demangle_osx + * flags weren't the same + */ + if ( (t = utompath(vol, ret->u_name, fileid, utf8_encoding())) ) { + /* at last got our view of mac name */ + strcpy(ret->m_name, t); + } + } + } /* afp_version >= 30 */ - if (left != SENTINEL) { - left->d_back = dir->d_back; - left->d_right = dir; + /* If we haven't got it by now, get it */ + if (ret->u_name == NULL) { + if ((ret->u_name = mtoupath(vol, ret->m_name, dir->d_did, utf8_encoding())) == NULL) { + afp_errno = AFPERR_PARAM; + return -1; + } } - if (!dir->d_back) /* no parent. move the left tree to the top. */ - vol->v_root = left; - else if (dir == dir->d_back->d_right) /* we were on the right */ - dir->d_back->d_right = left; - else - dir->d_back->d_left = left; /* we were on the left */ - - /* re-insert dir on the right tree */ - if (dir != SENTINEL) - dir->d_back = left; + return 0; } -#if 0 -/* recolor after a removal */ -static struct dir *dir_rmrecolor(struct vol *vol, struct dir *dir) +/*! + * @brief Build struct path from struct dir + * + * The final movecwd in cname failed, possibly with EPERM or ENOENT. We: + * 1. move cwd into parent dir (we're often already there, but not always) + */ +static struct path *path_from_dir(struct vol *vol, struct dir *dir, struct path *ret) { - struct dir *leaf; - - while ((dir != vol->v_root) && (dir->d_color == DIRTREE_COLOR_BLACK)) { - /* are we on the left tree? */ - if (dir == dir->d_back->d_left) { - leaf = dir->d_back->d_right; /* get right side */ - if (leaf->d_color == DIRTREE_COLOR_RED) { - /* we're red. we need to change to black. */ - leaf->d_color = DIRTREE_COLOR_BLACK; - dir->d_back->d_color = DIRTREE_COLOR_RED; - dir_leftrotate(vol, dir->d_back); - leaf = dir->d_back->d_right; - } + /* + * it's tricky: movecwd failed some of dir path are not there anymore. + * FIXME: Is it true with other errors? + */ + if (dir->d_did == DIRDID_ROOT_PARENT || dir->d_did == DIRDID_ROOT) + return NULL; - /* right leaf has black end nodes */ - if ((leaf->d_left->d_color == DIRTREE_COLOR_BLACK) && - (leaf->d_right->d_color = DIRTREE_COLOR_BLACK)) { - leaf->d_color = DIRTREE_COLOR_RED; /* recolor leaf as red */ - dir = dir->d_back; /* ascend */ - } else { - if (leaf->d_right->d_color == DIRTREE_COLOR_BLACK) { - leaf->d_left->d_color = DIRTREE_COLOR_BLACK; - leaf->d_color = DIRTREE_COLOR_RED; - dir_rightrotate(vol, leaf); - leaf = dir->d_back->d_right; - } - leaf->d_color = dir->d_back->d_color; - dir->d_back->d_color = DIRTREE_COLOR_BLACK; - leaf->d_right->d_color = DIRTREE_COLOR_BLACK; - dir_leftrotate(vol, dir->d_back); - dir = vol->v_root; - } - } else { /* right tree */ - leaf = dir->d_back->d_left; /* left tree */ - if (leaf->d_color == DIRTREE_COLOR_RED) { - leaf->d_color = DIRTREE_COLOR_BLACK; - dir->d_back->d_color = DIRTREE_COLOR_RED; - dir_rightrotate(vol, dir->d_back); - leaf = dir->d_back->d_left; - } + switch (afp_errno) { - /* left leaf has black end nodes */ - if ((leaf->d_right->d_color == DIRTREE_COLOR_BLACK) && - (leaf->d_left->d_color = DIRTREE_COLOR_BLACK)) { - leaf->d_color = DIRTREE_COLOR_RED; /* recolor leaf as red */ - dir = dir->d_back; /* ascend */ - } else { - if (leaf->d_left->d_color == DIRTREE_COLOR_BLACK) { - leaf->d_right->d_color = DIRTREE_COLOR_BLACK; - leaf->d_color = DIRTREE_COLOR_RED; - dir_leftrotate(vol, leaf); - leaf = dir->d_back->d_left; - } - leaf->d_color = dir->d_back->d_color; - dir->d_back->d_color = DIRTREE_COLOR_BLACK; - leaf->d_left->d_color = DIRTREE_COLOR_BLACK; - dir_rightrotate(vol, dir->d_back); - dir = vol->v_root; - } + case AFPERR_ACCESS: + if (movecwd( vol, dirlookup(vol, dir->d_pdid)) < 0 ) + return NULL; + + memcpy(ret->m_name, cfrombstring(dir->d_m_name), blength(dir->d_m_name) + 1); + if (dir->d_m_name == dir->d_u_name) { + ret->u_name = ret->m_name; + } else { + ret->u_name = ret->m_name + blength(dir->d_m_name) + 1; + memcpy(ret->u_name, cfrombstring(dir->d_u_name), blength(dir->d_u_name) + 1); } - } - dir->d_color = DIRTREE_COLOR_BLACK; - return dir; -} -#endif /* 0 */ + ret->d_dir = dir; + ret->st_valid = 1; + ret->st_errno = EACCES; + return ret; -/* --------------------- */ -static void dir_hash_del(const struct vol *vol, struct dir *dir) -{ - hnode_t *hn; + case AFPERR_NOOBJ: + if (movecwd(vol, dirlookup(vol, dir->d_pdid)) < 0 ) + return NULL; - hn = hash_lookup(vol->v_hash, dir); - if (!hn) { - LOG(log_error, logtype_afpd, "dir_hash_del: %s not hashed", dir->d_u_name); - } - else { - hash_delete(vol->v_hash, hn); + memcpy(ret->m_name, cfrombstring(dir->d_m_name), blength(dir->d_m_name) + 1); + if (dir->d_m_name == dir->d_u_name) { + ret->u_name = ret->m_name; + } else { + ret->u_name = ret->m_name + blength(dir->d_m_name) + 1; + memcpy(ret->u_name, cfrombstring(dir->d_u_name), blength(dir->d_u_name) + 1); + } + + ret->st_valid = 1; + ret->st_errno = ENOENT; + ret->d_dir = NULL; + dir_remove(vol, dir); + return ret; + + default: + return NULL; } + + /* DEADC0DE: never get here */ + return NULL; } -/* remove the node from the tree. this is just like insertion, but - * different. actually, it has to worry about a bunch of things that - * insertion doesn't care about. */ -static void dir_remove( struct vol *vol, struct dir *dir) +/********************************************************************************************* + * Interface + ********************************************************************************************/ + +int get_afp_errno(const int param) { -#ifdef REMOVE_NODES - struct ofork *of, *last; - struct dir *node, *leaf; -#endif /* REMOVE_NODES */ - - if (!dir || (dir == SENTINEL)) - return; - - /* i'm not sure if it really helps to delete stuff. */ - dir_hash_del(vol, dir); - vol->v_curdir = NULL; -#ifndef REMOVE_NODES - dirfreename(dir); - dir->d_m_name = NULL; - dir->d_u_name = NULL; - dir->d_m_name_ucs2 = NULL; -#else /* ! REMOVE_NODES */ - - /* go searching for a node with at most one child */ - if ((dir->d_left == SENTINEL) || (dir->d_right == SENTINEL)) { - node = dir; - } else { - node = dir->d_right; - while (node->d_left != SENTINEL) - node = node->d_left; + if (afp_errno != AFPERR_DID1) + return afp_errno; + return param; +} + +/*! + * @brief Resolve a DID + * + * Resolve a DID, allocate a struct dir for it + * 1. Check for special CNIDs 0 (invalid), 1 and 2. + * 2. Check if the DID is in the cache. + * 3. If it's not in the cache resolve it via the database. + * 4. Build complete server-side path to the dir. + * 5. Check if it exists and is a directory. + * 6. Create the struct dir and populate it. + * 7. Add it to the cache. + * + * @param vol (r) pointer to struct vol + * @param did (r) DID to resolve + * + * @returns pointer to struct dir + * + * @note FIXME: OSX calls it with bogus id, ie file ID not folder ID, + * and we are really bad in this case. + */ +struct dir *dirlookup(const struct vol *vol, cnid_t did) +{ + static char buffer[12 + MAXPATHLEN + 1]; + struct bstrList *pathlist = NULL; + bstring fullpath = NULL; + struct stat st; + struct dir *ret = NULL; + char *upath, *mpath; + cnid_t cnid, pdid; + size_t maxpath; + int buflen = 12 + MAXPATHLEN + 1; + int utf8; + int err = 0; + + LOG(log_debug, logtype_afpd, "dirlookup(did: %u)", ntohl(did)); + + /* check for did 0, 1 and 2 */ + if (did == 0 || vol == NULL) { /* 1 */ + afp_errno = AFPERR_PARAM; + return NULL; + } else if (did == DIRDID_ROOT_PARENT) { + rootParent.d_vid = vol->v_vid; + return (&rootParent); + } else if (did == DIRDID_ROOT) { + return vol->v_root; } - /* get that child */ - leaf = (node->d_left != SENTINEL) ? node->d_left : node->d_right; + /* Search the cache */ + if ((ret = dircache_search_by_did(vol, did)) != NULL) { /* 2 */ + return ret; + } - /* detach node */ - leaf->d_back = node->d_back; - if (!node->d_back) { - vol->v_root = leaf; - } else if (node == node->d_back->d_left) { /* left tree */ - node->d_back->d_left = leaf; - } else { - node->d_back->d_right = leaf; + utf8 = utf8_encoding(); + maxpath = (utf8) ? MAXPATHLEN - 7 : 255; + + /* Create list for path elements, request 16 list elements for now*/ + if ((pathlist = bstListCreateMin(16)) == NULL) { /* 4 */ + LOG(log_error, logtype_afpd, "dirlookup(did: %u): OOM: %s", ntohl(did), strerror(errno)); + return NULL; } - /* we want to free node, but we also want to free the data in dir. - * currently, that's d_name and the directory traversal bits. - * we just copy the necessary bits and then fix up all the - * various pointers to the directory. needless to say, there are - * a bunch of places that store the directory struct. */ - if (node != dir) { - struct dir save, *tmp; + /* Get it from the database */ + cnid = did; + if ( (upath = cnid_resolve(vol->v_cdb, &cnid, buffer, buflen)) == NULL ) { /* 3 */ + afp_errno = AFPERR_NOOBJ; + err = 1; + goto exit; + } + pdid = cnid; - memcpy(&save, dir, sizeof(save)); - memcpy(dir, node, sizeof(struct dir)); + LOG(log_debug, logtype_afpd, "dirlookup(did: %u) {%u, %s}", ntohl(did), ntohl(pdid), upath); - /* restore the red-black bits */ - dir->d_left = save.d_left; - dir->d_right = save.d_right; - dir->d_back = save.d_back; - dir->d_color = save.d_color; + /* The stuff that follows is for building the full path to the directory */ - if (node == vol->v_dir) {/* we may need to fix up this pointer */ - vol->v_dir = dir; - rootpar.d_child = vol->v_dir; - } else { - /* if we aren't the root directory, we have parents and - * siblings to worry about */ - if (dir->d_parent->d_child == node) - dir->d_parent->d_child = dir; - dir->d_next->d_prev = dir; - dir->d_prev->d_next = dir; + /* work upwards until we reach volume root */ + while (cnid != DIRDID_ROOT) { + /* construct path, copy already found uname to path element list*/ + if ((bstrListPush(pathlist, bfromcstr(upath))) != BSTR_OK) { /* 4 */ + afp_errno = AFPERR_MISC; + err = 1; + goto exit; } - /* fix up children. */ - tmp = dir->d_child; - while (tmp) { - tmp->d_parent = dir; - tmp = (tmp == dir->d_child->d_prev) ? NULL : tmp->d_next; + /* next part */ + if ((upath = cnid_resolve(vol->v_cdb, &cnid, buffer, buflen)) == NULL ) { /* 3 */ + afp_errno = AFPERR_NOOBJ; + err = 1; + goto exit; } + } - if (node == curdir) /* another pointer to fixup */ - curdir = dir; + if ((bstrListPush(pathlist, bfromcstr(vol->v_path))) != BSTR_OK) { /* 4 */ + afp_errno = AFPERR_MISC; + err = 1; + goto exit; + } - /* we also need to fix up oforks. bleah */ - if ((of = dir->d_ofork)) { - last = of->of_d_prev; - while (of) { - of->of_dir = dir; - of = (last == of) ? NULL : of->of_d_next; - } - } + if ((fullpath = bjoinInv(pathlist, bfromcstr("/"))) == NULL) { /* 4 */ + afp_errno = AFPERR_MISC; + err = 1; + goto exit; + } + /* Finished building the fullpath */ - /* set the node's d_name */ - node->d_m_name = save.d_m_name; - node->d_u_name = save.d_u_name; - node->d_m_name_ucs2 = save.d_m_name_ucs2; + /* stat it and check if it's a dir*/ + if (stat(cfrombstring(fullpath), &st) != 0) { /* 5a */ + switch (errno) { + case ENOENT: + afp_errno = AFPERR_NOOBJ; + err = 1; + goto exit; + case EPERM: + afp_errno = AFPERR_ACCESS; + err = 1; + goto exit; + default: + afp_errno = AFPERR_MISC; + err = 1; + goto exit; + } + } else { + if ( ! S_ISDIR(st.st_mode)) { /* 5b */ + afp_errno = AFPERR_BADTYPE; + err = 1; + goto exit; + } } - if (node->d_color == DIRTREE_COLOR_BLACK) - dir_rmrecolor(vol, leaf); + /* Get macname from unix name */ + if ( (mpath = utompath(vol, upath, did, utf8)) == NULL ) { + afp_errno = AFPERR_NOOBJ; + err = 1; + goto exit; + } - if (node->d_m_name_ucs2) - free(node->d_u_name_ucs2); - if (node->d_u_name != node->d_m_name) { - free(node->d_u_name); + /* Create struct dir */ + if ((ret = dir_new(mpath, upath, vol, pdid, did, fullpath)) == NULL) { /* 6 */ + LOG(log_error, logtype_afpd, "dirlookup(did: %u) {%s, %s}: %s", ntohl(did), mpath, upath, strerror(errno)); + err = 1; + goto exit; } - free(node->d_m_name); - free(node); -#endif /* ! REMOVE_NODES */ -} -/* --------------------------------------- - * remove the node and its childs from the tree - * - * FIXME what about opened forks with refs to it? - * it's an afp specs violation because you can't delete - * an opened forks. Now afpd doesn't care about forks opened by other - * process. It's fixable within afpd if fnctl_lock, doable with smb and - * next to impossible for nfs and local filesystem access. - */ -static void dir_invalidate( struct vol *vol, struct dir *dir) -{ - if (curdir == dir) { - /* v_root can't be deleted */ - if (movecwd(vol, vol->v_root) < 0) { - LOG(log_error, logtype_afpd, "cname can't chdir to : %s", vol->v_root); - } + /* Add it to the cache */ + if (dircache_add(ret) != 0) { /* 7 */ + err = 1; + goto exit; } - /* FIXME */ - dirchildremove(dir->d_parent, dir); - dir_remove( vol, dir ); -} -/* ------------------------------------ */ -static struct dir *dir_insert(const struct vol *vol, struct dir *dir) -{ - struct dir *pdir; - - pdir = vol_tree_root(vol, dir->d_did); - while (pdir->d_did != dir->d_did ) { - if ( pdir->d_did > dir->d_did ) { - if ( pdir->d_left == SENTINEL ) { - pdir->d_left = dir; - dir->d_back = pdir; - return NULL; - } - pdir = pdir->d_left; - } else { - if ( pdir->d_right == SENTINEL ) { - pdir->d_right = dir; - dir->d_back = pdir; - return NULL; - } - pdir = pdir->d_right; + LOG(log_debug, logtype_afpd, "dirlookup(did: %u) {%u, %s}", + ntohl(pdid), ntohl(did), ret->d_fullpath); + +exit: + if (pathlist) + bstrListDestroy(pathlist); + + if (err) { + LOG(log_error, logtype_afpd, "dirlookup(did: %u)", ntohl(did)); + if (fullpath) + bdestroy(fullpath); + if (ret) { + dir_free(ret); + ret = NULL; } } - return pdir; + return ret; } #define ENUMVETO "./../Network Trash Folder/TheVolumeSettingsFolder/TheFindByContentFolder/:2eDS_Store/Contents/Desktop Folder/Trash/Benutzer/" -int -caseenumerate(const struct vol *vol, struct path *path, struct dir *dir) +int caseenumerate(const struct vol *vol, struct path *path, struct dir *dir) { DIR *dp; struct dirent *de; @@ -714,584 +650,304 @@ caseenumerate(const struct vol *vol, struct path *path, struct dir *dir) } -/* - * attempt to extend the current dir. tree to include path - * as a side-effect, movecwd to that point and return the new dir +/*! + * @brief Construct struct dir + * + * Construct struct dir from parameters. + * + * @param m_name (r) directory name in UTF8-dec + * @param u_name (r) directory name in server side encoding + * @param vol (r) pointer to struct vol + * @param pdid (r) Parent CNID + * @param did (r) CNID + * @param fullpath (r) Full unix path to dir + * + * @returns pointer to new struct dir or NULL on error + * + * @note Most of the time mac name and unix name are the same. */ -static struct dir * -extenddir(struct vol *vol, struct dir *dir, struct path *path) +struct dir *dir_new(const char *m_name, + const char *u_name, + const struct vol *vol, + cnid_t pdid, + cnid_t did, + bstring path) { - path->d_dir = NULL; + struct dir *dir; - if ( path->u_name == NULL) { - afp_errno = AFPERR_PARAM; + dir = (struct dir *) calloc(1, sizeof( struct dir )); + if (!dir) return NULL; - } - if (check_name(vol, path->u_name)) { - /* the name is illegal */ - LOG(log_info, logtype_afpd, "extenddir: illegal path: '%s'", path->u_name); - path->u_name = NULL; - afp_errno = AFPERR_PARAM; + if ((dir->d_m_name = bfromcstr(m_name)) == NULL) { + free(dir); return NULL; } - if (of_stat( path ) != 0 ) { - if (!(vol->v_flags & AFPVOL_CASEINSEN)) - return NULL; - else if(caseenumerate(vol, path, dir) != 0) - return(NULL); - } - - if (!S_ISDIR(path->st.st_mode)) { - return( NULL ); - } - - /* mac name is always with the right encoding (from cname()) */ - if (( dir = adddir( vol, dir, path)) == NULL ) { - return( NULL ); - } - - path->d_dir = dir; - if ( movecwd( vol, dir ) < 0 ) { - return( NULL ); - } - - return( dir ); -} - -/* ------------------------- - appledouble mkdir afp error code. -*/ -static int netatalk_mkdir(const char *name) -{ - if (ad_mkdir(name, DIRBITS | 0777) < 0) { - switch ( errno ) { - case ENOENT : - return( AFPERR_NOOBJ ); - case EROFS : - return( AFPERR_VLOCK ); - case EPERM: - case EACCES : - return( AFPERR_ACCESS ); - case EEXIST : - return( AFPERR_EXIST ); - case ENOSPC : - case EDQUOT : - return( AFPERR_DFULL ); - default : - return( AFPERR_PARAM ); - } - } - return AFP_OK; -} - -/* ------------------- */ -static int deletedir(char *dir) -{ - char path[MAXPATHLEN + 1]; - DIR *dp; - struct dirent *de; - struct stat st; - size_t len; - int err = AFP_OK; - size_t remain; - - if ((len = strlen(dir)) +2 > sizeof(path)) - return AFPERR_PARAM; - - /* already gone */ - if ((dp = opendir(dir)) == NULL) - return AFP_OK; - - strcpy(path, dir); - strcat(path, "/"); - len++; - remain = sizeof(path) -len -1; - while ((de = readdir(dp)) && err == AFP_OK) { - /* skip this and previous directory */ - if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) - continue; - - if (strlen(de->d_name) > remain) { - err = AFPERR_PARAM; - break; - } - strcpy(path + len, de->d_name); - if (stat(path, &st)) { - continue; - } - if (S_ISDIR(st.st_mode)) { - err = deletedir(path); - } else { - err = netatalk_unlink(path); - } - } - closedir(dp); - - /* okay. the directory is empty. delete it. note: we already got rid - of .AppleDouble. */ - if (err == AFP_OK) { - err = netatalk_rmdir(dir); - } - return err; -} - -/* do a recursive copy. */ -static int copydir(const struct vol *vol, char *src, char *dst) -{ - char spath[MAXPATHLEN + 1], dpath[MAXPATHLEN + 1]; - DIR *dp; - struct dirent *de; - struct stat st; - struct utimbuf ut; - size_t slen, dlen; - size_t srem, drem; - int err; - - /* doesn't exist or the path is too long. */ - if (((slen = strlen(src)) > sizeof(spath) - 2) || - ((dlen = strlen(dst)) > sizeof(dpath) - 2) || - ((dp = opendir(src)) == NULL)) - return AFPERR_PARAM; - - /* try to create the destination directory */ - if (AFP_OK != (err = netatalk_mkdir(dst)) ) { - closedir(dp); - return err; + if (convert_string_allocate( (utf8_encoding()) ? CH_UTF8_MAC : vol->v_maccharset, + CH_UCS2, + m_name, + -1, (char **)&dir->d_m_name_ucs2) == (size_t)-1 ) { + LOG(log_error, logtype_afpd, "dir_new(did: %u) {%s, %s}: couldn't set UCS2 name", ntohl(did), m_name, u_name); + dir->d_m_name_ucs2 = NULL; } - /* set things up to copy */ - strcpy(spath, src); - strcat(spath, "/"); - slen++; - srem = sizeof(spath) - slen -1; - - strcpy(dpath, dst); - strcat(dpath, "/"); - dlen++; - drem = sizeof(dpath) - dlen -1; - - err = AFP_OK; - while ((de = readdir(dp))) { - /* skip this and previous directory */ - if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) - continue; - - if (strlen(de->d_name) > srem) { - err = AFPERR_PARAM; - break; - } - strcpy(spath + slen, de->d_name); - - if (stat(spath, &st) == 0) { - if (strlen(de->d_name) > drem) { - err = AFPERR_PARAM; - break; - } - strcpy(dpath + dlen, de->d_name); - - if (S_ISDIR(st.st_mode)) { - if (AFP_OK != (err = copydir(vol, spath, dpath))) - goto copydir_done; - } else if (AFP_OK != (err = copyfile(vol, vol, spath, dpath, NULL, NULL))) { - goto copydir_done; - - } else { - /* keep the same time stamp. */ - ut.actime = ut.modtime = st.st_mtime; - utime(dpath, &ut); - } - } + if (m_name == u_name || !strcmp(m_name, u_name)) { + dir->d_u_name = dir->d_m_name; } - - /* keep the same time stamp. */ - if (stat(src, &st) == 0) { - ut.actime = ut.modtime = st.st_mtime; - utime(dst, &ut); + else if ((dir->d_u_name = bfromcstr(u_name)) == NULL) { + bdestroy(dir->d_m_name); + free(dir); + return NULL; } -copydir_done: - closedir(dp); - return err; + dir->d_did = did; + dir->d_pdid = pdid; + dir->d_vid = vol->v_vid; + dir->d_fullpath = path; + return dir; } - -/* --- public functions follow --- */ - -/* NOTE: we start off with at least one node (the root directory). */ -static struct dir *dirinsert(struct vol *vol, struct dir *dir) +/*! + * @brief Free a struct dir and all its members + * + * @param (rw) pointer to struct dir + */ +void dir_free(struct dir *dir) { - struct dir *node; - - if ((node = dir_insert(vol, dir))) - return node; - - /* recolor the tree. the current node is red. */ - dir->d_color = DIRTREE_COLOR_RED; - - /* parent of this node has to be black. if the parent node - * is red, then we have a grandparent. */ - while ((dir != vol->v_root) && - (dir->d_back->d_color == DIRTREE_COLOR_RED)) { - /* are we on the left tree? */ - if (dir->d_back == dir->d_back->d_back->d_left) { - node = dir->d_back->d_back->d_right; /* get the right node */ - if (node->d_color == DIRTREE_COLOR_RED) { - /* we're red. we need to change to black. */ - dir->d_back->d_color = DIRTREE_COLOR_BLACK; - node->d_color = DIRTREE_COLOR_BLACK; - dir->d_back->d_back->d_color = DIRTREE_COLOR_RED; - dir = dir->d_back->d_back; /* finished. go up. */ - } else { - if (dir == dir->d_back->d_right) { - dir = dir->d_back; - dir_leftrotate(vol, dir); - } - dir->d_back->d_color = DIRTREE_COLOR_BLACK; - dir->d_back->d_back->d_color = DIRTREE_COLOR_RED; - dir_rightrotate(vol, dir->d_back->d_back); - } - } else { - node = dir->d_back->d_back->d_left; - if (node->d_color == DIRTREE_COLOR_RED) { - /* we're red. we need to change to black. */ - dir->d_back->d_color = DIRTREE_COLOR_BLACK; - node->d_color = DIRTREE_COLOR_BLACK; - dir->d_back->d_back->d_color = DIRTREE_COLOR_RED; - dir = dir->d_back->d_back; /* finished. ascend */ - } else { - if (dir == dir->d_back->d_left) { - dir = dir->d_back; - dir_rightrotate(vol, dir); - } - dir->d_back->d_color = DIRTREE_COLOR_BLACK; - dir->d_back->d_back->d_color = DIRTREE_COLOR_RED; - dir_leftrotate(vol, dir->d_back->d_back); - } - } + if (dir->d_u_name != dir->d_m_name) { + bdestroy(dir->d_u_name); } - - vol->v_root->d_color = DIRTREE_COLOR_BLACK; - return NULL; + if (dir->d_m_name_ucs2) + free(dir->d_m_name_ucs2); + bdestroy(dir->d_m_name); + bdestroy(dir->d_fullpath); + free(dir); } -/* ---------------------------- */ -struct dir * -adddir(struct vol *vol, struct dir *dir, struct path *path) +/*! + * @brief Create struct dir from struct path + * + * Create a new struct dir from struct path. Then add it to the cache. + * The caller must have assured that the dir is not already in the cache, + * cf the assertion. + * 1. Open adouble file, get CNID from it. + * 2. Search the database, hinting with the CNID from (1). + * 3. Build fullpath and create struct dir. + * 4. Add it to the cache. + * + * @param vol (r) pointer to struct vol + * @param dir (r) pointer to parrent directory + * @param path (rw) pointer to struct path with valid path->u_name + * @param len (r) strlen of path->u_name + * + * @returns Pointer to new struct dir or NULL on error. + * + * @note Function also assigns path->m_name from path->u_name. + */ +struct dir *dir_add(const struct vol *vol, const struct dir *dir, struct path *path, int len) { - struct dir *cdir, *edir; - int upathlen; - char *name; - char *upath; - struct stat *st; - int deleted; + int err = 0; + struct dir *cdir = NULL; + cnid_t id; struct adouble ad; struct adouble *adp = NULL; - cnid_t id; + bstring fullpath; - upath = path->u_name; - st = &path->st; - upathlen = strlen(upath); + assert(vol); + assert(dir); + assert(path); + assert(len > 0); + assert(dircache_search_by_name(vol, dir->d_did, path->u_name, strlen(path->u_name)) == NULL); /* get_id needs adp for reading CNID from adouble file */ ad_init(&ad, vol->v_adouble, vol->v_ad_options); - if ((ad_open_metadata(upath, ADFLAGS_DIR, 0, &ad)) == 0) - adp = &ad; - - id = get_id(vol, adp, st, dir->d_did, upath, upathlen); - - if (adp) - ad_close_metadata(adp); - - if (id == 0) { - return NULL; - } - if (!path->m_name && !(path->m_name = utompath(vol, upath, id , utf8_encoding()))) { - return NULL; - } - name = path->m_name; - if ((cdir = dirnew(name, upath)) == NULL) { - LOG(log_error, logtype_afpd, "adddir: malloc: %s", strerror(errno) ); - return NULL; - } - if ((size_t)-1 == convert_string_allocate((utf8_encoding())?CH_UTF8_MAC:vol->v_maccharset, CH_UCS2, path->m_name, -1, (char **)&cdir->d_m_name_ucs2)) { - LOG(log_error, logtype_afpd, "Couldn't set UCS2 name for %s", name); - cdir->d_m_name_ucs2 = NULL; - } - - cdir->d_did = id; - - if ((edir = dirinsert( vol, cdir ))) { - /* it's not possible with LASTDID - for CNID: - - someone else have moved the directory. - - it's a symlink inside the share. - - it's an ID reused, the old directory was deleted but not - the cnid record and the server've reused the inode for - the new dir. - for HASH (we should get ride of HASH) - - someone else have moved the directory. - - it's an ID reused as above - - it's a hash duplicate and we are in big trouble - */ - deleted = (edir->d_m_name == NULL); - if (!deleted) - dir_hash_del(vol, edir); - dirfreename(edir); - edir->d_m_name = cdir->d_m_name; - edir->d_u_name = cdir->d_u_name; - edir->d_m_name_ucs2 = cdir->d_m_name_ucs2; - free(cdir); - cdir = edir; - LOG(log_error, logtype_afpd, "adddir: insert %s", edir->d_m_name); - if (!cdir->d_parent || (cdir->d_parent == dir && !deleted)) { - hash_alloc_insert(vol->v_hash, cdir, cdir); - return cdir; - } - /* the old was not in the same folder */ - if (!deleted) - dirchildremove(cdir->d_parent, cdir); + if ((ad_open_metadata(path->u_name, ADFLAGS_DIR, 0, &ad)) == 0) /* 1 */ + adp = &ad; + + /* Get CNID */ + if ((id = get_id(vol, adp, &path->st, dir->d_did, path->u_name, len)) == 0) { /* 2 */ + err = 1; + goto exit; } - /* parent/child directories */ - cdir->d_parent = dir; - dirchildadd(vol, dir, cdir); - return( cdir ); -} + if (adp) + ad_close_metadata(adp); -/* --- public functions follow --- */ -/* free everything down. we don't bother to recolor as this is only - * called to free the entire tree */ -void dirfreename(struct dir *dir) -{ - if (dir->d_u_name != dir->d_m_name) { - free(dir->d_u_name); + /* Get macname from unixname */ + if (path->m_name == NULL) { + if ((path->m_name = utompath(vol, path->u_name, id, utf8_encoding())) == NULL) { + err = 1; + goto exit; + } } - if (dir->d_m_name_ucs2) - free(dir->d_m_name_ucs2); - free(dir->d_m_name); -} -void dirfree(struct dir *dir) -{ - if (!dir || (dir == SENTINEL)) - return; + /* Build fullpath */ + if ( ((fullpath = bstrcpy(dir->d_fullpath)) == NULL) /* 3 */ + || (bconchar(fullpath, '/') != BSTR_OK) + || (bcatcstr(fullpath, path->u_name)) != BSTR_OK) { + LOG(log_error, logtype_afpd, "dir_add: fullpath: %s", strerror(errno) ); + err = 1; + goto exit; + } - if ( dir->d_left != SENTINEL ) { - dirfree( dir->d_left ); + /* Allocate and initialize struct dir */ + if ((cdir = dir_new( path->m_name, path->u_name, vol, dir->d_did, id, fullpath)) == NULL) { /* 3 */ + err = 1; + goto exit; } - if ( dir->d_right != SENTINEL ) { - dirfree( dir->d_right ); + + if ((dircache_add(cdir)) != 0) { /* 4 */ + LOG(log_error, logtype_afpd, "dir_add: fatal dircache error: %s", cfrombstring(fullpath)); + exit(EXITERR_SYS); } - if (dir != SENTINEL) { - dirfreename(dir); - free( dir ); +exit: + if (err != 0) { + if (adp) + ad_close_metadata(adp); + if (!cdir && fullpath) + bdestroy(fullpath); + if (cdir) + dir_free(cdir); + cdir = NULL; } + + return(cdir); } -/* -------------------------------------------- - * most of the time mac name and unix name are the same +/*! + * @brief Remove a dir from a cache and free it and any ressources with it + * + * @param (r) pointer to struct vol + * @param (rw) pointer to struct dir */ -struct dir *dirnew(const char *m_name, const char *u_name) +int dir_remove(const struct vol *vol, struct dir *dir) { - struct dir *dir; + assert(vol); + assert(dir); - dir = (struct dir *) calloc(1, sizeof( struct dir )); - if (!dir) - return NULL; + if (dir->d_did == DIRDID_ROOT_PARENT || dir->d_did == DIRDID_ROOT) + return 0; - if ((dir->d_m_name = strdup(m_name)) == NULL) { - free(dir); - return NULL; + if (curdir == dir) { + if (movecwd(vol, vol->v_root) < 0) { + LOG(log_error, logtype_afpd, "dir_remove: can't chdir to : %s", vol->v_root); + } } - if (m_name == u_name || !strcmp(m_name, u_name)) { - dir->d_u_name = dir->d_m_name; - } - else if ((dir->d_u_name = strdup(u_name)) == NULL) { - free(dir->d_m_name); - free(dir); - return NULL; - } + dircache_remove(vol, dir, DIRCACHE | DIDNAME_INDEX | QUEUE_INDEX); + dir_free(dir); - dir->d_m_name_ucs2 = NULL; - dir->d_left = dir->d_right = SENTINEL; - dir->d_next = dir->d_prev = dir; - return dir; + return 0; } -/* ------------------ */ -static hash_val_t hash_fun_dir(const void *key) +/*! + * @brief Modify a struct dir, adust cache + * + * Any value that is 0 or NULL is not changed. If new_uname is NULL it is set to new_mname. + * If given new_uname == new_mname, new_uname will point to new_mname. + * + * @param vol (r) pointer to struct vol + * @param dir (rw) pointer to struct dir + * @param pdid (r) new parent DID + * @param did (r) new DID + * @param new_mname (r) new mac-name + * @param new_uname (r) new unix-name + */ +int dir_modify(const struct vol *vol, + struct dir *dir, + cnid_t pdid, + cnid_t did, + const char *new_mname, + const char *new_uname, + bstring pdir_fullpath) { - const struct dir *k = key; - - static unsigned long randbox[] = { - 0x49848f1bU, 0xe6255dbaU, 0x36da5bdcU, 0x47bf94e9U, - 0x8cbcce22U, 0x559fc06aU, 0xd268f536U, 0xe10af79aU, - 0xc1af4d69U, 0x1d2917b5U, 0xec4c304dU, 0x9ee5016cU, - 0x69232f74U, 0xfead7bb3U, 0xe9089ab6U, 0xf012f6aeU, - }; - - const unsigned char *str = (unsigned char *)(k->d_u_name); - hash_val_t acc = k->d_parent->d_did; - - while (*str) { - acc ^= randbox[(*str + acc) & 0xf]; - acc = (acc << 1) | (acc >> 31); - acc &= 0xffffffffU; - acc ^= randbox[((*str++ >> 4) + acc) & 0xf]; - acc = (acc << 2) | (acc >> 30); - acc &= 0xffffffffU; - } - return acc; -} - -#undef get16bits -#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ - || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) -#define get16bits(d) (*((const uint16_t *) (d))) -#endif + int ret = 0; -#if !defined (get16bits) -#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ - +(uint32_t)(((const uint8_t *)(d))[0]) ) -#endif + /* Remove it from the cache */ + dircache_remove(vol, dir, DIRCACHE | DIDNAME_INDEX | QUEUE_INDEX); -static hash_val_t hash_fun2_dir(const void *key) -{ - const struct dir *k = key; - const char *data = k->d_u_name; - int len = strlen(k->d_u_name); - hash_val_t hash = k->d_parent->d_did, tmp; - - int rem = len & 3; - len >>= 2; - - /* Main loop */ - for (;len > 0; len--) { - hash += get16bits (data); - tmp = (get16bits (data+2) << 11) ^ hash; - hash = (hash << 16) ^ tmp; - data += 2*sizeof (uint16_t); - hash += hash >> 11; - } - - /* Handle end cases */ - switch (rem) { - case 3: hash += get16bits (data); - hash ^= hash << 16; - hash ^= data[sizeof (uint16_t)] << 18; - hash += hash >> 11; - break; - case 2: hash += get16bits (data); - hash ^= hash << 11; - hash += hash >> 17; - break; - case 1: hash += *data; - hash ^= hash << 10; - hash += hash >> 1; - } + if (pdid) + dir->d_pdid = pdid; + if (did) + dir->d_did = did; - /* Force "avalanching" of final 127 bits */ - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; + if (new_mname) { + /* free uname if it's not the same as mname */ + if (dir->d_m_name != dir->d_u_name) + bdestroy(dir->d_u_name); - return hash; -} + if (new_uname == NULL) + new_uname = new_mname; -/* ---------------- */ -static int hash_comp_dir(const void *key1, const void *key2) -{ - const struct dir *k1 = key1; - const struct dir *k2 = key2; + /* assign new name */ + if ((bassigncstr(dir->d_m_name, new_mname)) != BSTR_OK) { + LOG(log_error, logtype_afpd, "dir_modify: bassigncstr: %s", strerror(errno) ); + return -1; + } - return !(k1->d_parent->d_did == k2->d_parent->d_did && !strcmp(k1->d_u_name, k2->d_u_name)); -} + if (new_mname == new_uname || (strcmp(new_mname, new_uname) == 0)) { + dir->d_u_name = dir->d_m_name; + } else { + if ((dir->d_u_name = bfromcstr(new_uname)) == NULL) { + LOG(log_error, logtype_afpd, "renamedir: bassigncstr: %s", strerror(errno) ); + return -1; + } + } + } -/* ---------------- */ -hash_t * -dirhash(void) -{ - return hash_create(HASHCOUNT_T_MAX, hash_comp_dir, hash_fun2_dir); -} + if (pdir_fullpath) { + if (bassign(dir->d_fullpath, pdir_fullpath) != BSTR_OK) + return -1; + if (bcatcstr(dir->d_fullpath, "/") != BSTR_OK) + return -1; + if (bcatcstr(dir->d_fullpath, new_uname) != BSTR_OK) + return -1; + } -/* ------------------ */ -static struct path *invalidate (struct vol *vol, struct dir *dir, struct path *ret) -{ - /* it's tricky: - movecwd failed some of dir path are not there anymore. - FIXME Is it true with other errors? - so we remove dir from the cache - */ - if (dir->d_did == DIRDID_ROOT_PARENT) - return NULL; - if (afp_errno == AFPERR_ACCESS) { - if ( movecwd( vol, dir->d_parent ) < 0 ) { - return NULL; - } - /* FIXME should we set these?, don't need to call stat() after: - ret->st_valid = 1; - ret->st_errno = EACCES; - */ - ret->m_name = dir->d_m_name; - ret->u_name = dir->d_u_name; - ret->d_dir = dir; - return ret; - } else if (afp_errno == AFPERR_NOOBJ) { - if ( movecwd( vol, dir->d_parent ) < 0 ) { - return NULL; - } - strcpy(ret->m_name, dir->d_m_name); - if (dir->d_m_name == dir->d_u_name) { - ret->u_name = ret->m_name; - } - else { - size_t tp = strlen(ret->m_name)+1; + if (dir->d_m_name_ucs2) + free(dir->d_m_name_ucs2); + if ((size_t)-1 == convert_string_allocate((utf8_encoding())?CH_UTF8_MAC:vol->v_maccharset, CH_UCS2, dir->d_m_name, -1, (char**)&dir->d_m_name_ucs2)) + dir->d_m_name_ucs2 = NULL; - ret->u_name = ret->m_name +tp; - strcpy(ret->u_name, dir->d_u_name); - } - /* FIXME should we set : - ret->st_valid = 1; - ret->st_errno = ENOENT; - */ - dir_invalidate(vol, dir); - return ret; + /* Re-add it to the cache */ + if ((dircache_add(dir)) != 0) { + dircache_dump(); + exit(EXITERR_SYS); } - dir_invalidate(vol, dir); - return NULL; + + return ret; } -/* -------------------------------------------------- */ -/* cname - return - if it's a filename: - in extenddir: - compute unix name - stat the file or errno - return - filename - curdir: filename parent directory - - if it's a dirname: - not in the cache - in extenddir - compute unix name - stat the dir or errno - return - if chdir error - dirname - curdir: dir parent directory - sinon - dirname: "" - curdir: dir - in the cache +/*! + * @brief Resolve a catalog node name path + * + * If it's a filename: + * 1. compute unix name + * 2. stat the file, storing struct stat or errno in struct path + * 3. cwd (and curdir) is filename parent directory + * 4. return path with with filename + * + * If it's a dirname: + * 5. search the dircache + * 6. if not in the cache: + * 7. compute unix name + * 8. stat the dir, storing struct stat or errno in struct path + * 9. chdir dirname + * 10. if chdir failed, return path with dirname + * cwd is dir parent directory + * if chdir succeeded, add to dircache + * return path with "" and "." + * cwd is dirname + * 11. else in the cache: + * 12. stat the dir, storing struct stat or errno in struct path + * 13. chdir dirname + * 14. if chdir failed + * if ENOENT + * remove from cache + * if not last path part, return NULL + * else return if chdir error dirname @@ -1299,33 +955,31 @@ static struct path *invalidate (struct vol *vol, struct dir *dir, struct path *r else dirname: "" curdir: dir - */ -struct path * -cname(struct vol *vol, struct dir *dir, char **cpath) +struct path *cname(struct vol *vol, struct dir *dir, char **cpath) { - struct dir *cdir, *scdir=NULL; static char path[ MAXPATHLEN + 1]; static struct path ret; + struct dir *cdir; char *data, *p; - int extend = 0; int len; u_int32_t hint; u_int16_t len16; int size = 0; - char sep; int toUTF8 = 0; + LOG(log_debug, logtype_afpd, "came('%s'): {start}", cfrombstring(dir->d_fullpath)); + data = *cpath; afp_errno = AFPERR_NOOBJ; memset(&ret, 0, sizeof(ret)); + switch (ret.m_type = *data) { /* path type */ case 2: data++; len = (unsigned char) *data++; size = 2; - sep = 0; if (afp_version >= 30) { ret.m_type = 3; toUTF8 = 1; @@ -1342,7 +996,6 @@ cname(struct vol *vol, struct dir *dir, char **cpath) len = ntohs(len16); data += 2; size = 7; - sep = 0; /* '/';*/ break; } /* else it's an error */ @@ -1351,236 +1004,208 @@ cname(struct vol *vol, struct dir *dir, char **cpath) return( NULL ); } *cpath += len + size; - *path = '\0'; + + path[0] = 0; ret.m_name = path; - for ( ;; ) { - if ( len == 0 ) { - if (movecwd( vol, dir ) < 0 ) { - return invalidate(vol, dir, &ret ); - } - if (*path == '\0') { - ret.u_name = "."; - ret.d_dir = dir; - } - return &ret; - } - if (*data == sep ) { + if (movecwd(vol, dir) < 0 ) { + LOG(log_debug, logtype_afpd, "cname(did:%u): failed to chdir to '%s'", + ntohl(dir->d_did), cfrombstring(dir->d_fullpath)); + if (len == 0) + return path_from_dir(vol, dir, &ret); + else + return NULL; + } + + while (len) { + /* + * Three cases: + * 1. single 0 -> delimiter + * 2. additional 0 -> chdir(..) + * 3. a name + * a) name is a file, build struct path from it etc., exit while loop + * b) name is a dir, add it to the dircache, chdir to it, continue + */ + if (*data == 0) { /* case 1 or 2 */ data++; len--; - } - while (*data == sep && len > 0 ) { - if ( dir->d_parent == NULL ) { - return NULL; + while (len > 0 && *data == 0) { /* case 2 */ + /* chdir to parrent dir */ + if ((dir = dirlookup(vol, dir->d_pdid)) == NULL) + return NULL; + if (movecwd( vol, dir ) < 0 ) { + dir_remove(vol, dir); + return NULL; + } + data++; + len--; } - dir = dir->d_parent; - data++; - len--; + continue; } - /* would this be faster with strlen + strncpy? */ - p = path; - while ( *data != sep && len > 0 ) { + /* case 3: copy name from packet buffer to ret.m_name and process it */ + for ( p = path; *data != 0 && len > 0; len-- ) { *p++ = *data++; if (p > &path[ MAXPATHLEN]) { afp_errno = AFPERR_PARAM; - return( NULL ); + return NULL; } - len--; } + *p = 0; /* Terminate string */ + ret.u_name = NULL; - /* short cut bits by chopping off a trailing \0. this also - makes the traversal happy w/ filenames at the end of the - cname. */ - if (len == 1) - len--; - - *p = '\0'; - - if ( p == path ) { /* end of the name parameter */ - continue; + /* Get u_name from m_name */ + if (cname_mtouname(vol, dir, &ret, toUTF8) != 0) { + LOG(log_error, logtype_afpd, "cname('%s'): error from cname_mtouname", path); + return NULL; } - ret.u_name = NULL; - if (afp_version >= 30) { - char *t; - cnid_t fileid; - if (toUTF8) { - static char temp[ MAXPATHLEN + 1]; + LOG(log_maxdebug, logtype_afpd, "came('%s'): {node: '%s}", cfrombstring(dir->d_fullpath), ret.u_name); - if (dir->d_did == DIRDID_ROOT_PARENT) { - /* - With uft8 volume name is utf8-mac, but requested path may be a mangled longname. See #2611981. - So we compare it with the longname from the current volume and if they match - we overwrite the requested path with the utf8 volume name so that the following - strcmp can match. - */ - ucs2_to_charset(vol->v_maccharset, vol->v_macname, temp, AFPVOL_MACNAMELEN + 1); - if (strcasecmp( path, temp) == 0) - ucs2_to_charset(CH_UTF8_MAC, vol->v_u8mname, path, AFPVOL_U8MNAMELEN); - } else { - /* toUTF8 */ - if (mtoUTF8(vol, path, strlen(path), temp, MAXPATHLEN) == (size_t)-1) { - afp_errno = AFPERR_PARAM; - return( NULL ); - } - strcpy(path, temp); - } - } - /* check for OS X mangled filename :( */ + /* Prevent access to our special folders like .AppleDouble */ + if (check_name(vol, ret.u_name)) { + /* the name is illegal */ + LOG(log_info, logtype_afpd, "cname: illegal path: '%s'", ret.u_name); + afp_errno = AFPERR_PARAM; + return NULL; + } - t = demangle_osx(vol, path, dir->d_did, &fileid); - if (t != path) { - ret.u_name = t; - /* duplicate work but we can't reuse all convert_char we did in demangle_osx - * flags weren't the same + if (dir->d_did == DIRDID_ROOT_PARENT) { + /* + * Special case: CNID 1 + * root parent (did 1) has one child: the volume. Requests for did=1 with + * some must check against the volume name. + */ + if ((strcmp(cfrombstring(vol->v_root->d_m_name), ret.m_name)) == 0) + cdir = vol->v_root; + else + return NULL; + } else { + /* + * CNID != 1, eg. most of the times we take this way. + * Now check if current path-part is a file or dir: + * o if it's dir we have to step into it + * o if it's a file we expect it to be the last part of the requested path + * and thus call continue which should terminate the while loop because + * len = 0. Ok? + */ + if (of_stat(&ret) != 0) { + /* + * ret.u_name doesn't exist, might be afp_createfile|dir + * that means it should have been the last part */ - if ( (t = utompath(vol, ret.u_name, fileid, utf8_encoding())) ) { - /* at last got our view of mac name */ - strcpy(path,t); + if (len > 0) { + /* it wasn't the last part, so we have a bogus path request */ + afp_errno = AFPERR_NOOBJ; + return NULL; } + /* + * this will terminate clean in while (1) because len == 0, + * probably afp_createfile|dir + */ + LOG(log_maxdebug, logtype_afpd, "came('%s'): {leave-cnode ENOENT (possile create request): '%s'}", cfrombstring(dir->d_fullpath), ret.u_name); + continue; } - } - if (ret.u_name == NULL) { - if (!(ret.u_name = mtoupath(vol, ret.m_name, dir->d_did, utf8_encoding()))) { - afp_errno = AFPERR_PARAM; - return NULL; - } - } - if ( !extend ) { - ucs2_t *tmpname; - cdir = dir->d_child; - scdir = NULL; - if ( cdir && (vol->v_flags & AFPVOL_CASEINSEN) && - (size_t)-1 != convert_string_allocate(((ret.m_type == 3)?CH_UTF8_MAC:vol->v_maccharset), - CH_UCS2, path, -1, (char **)&tmpname) ) - { - while (cdir) { - if (!cdir->d_m_name_ucs2) { - LOG(log_error, logtype_afpd, "cname: no UCS2 name for %s (did %u)!!!", cdir->d_m_name, ntohl(cdir->d_did) ); - /* this shouldn't happen !!!! */ - goto noucsfallback; - } - if ( strcmp_w( cdir->d_m_name_ucs2, tmpname ) == 0 ) { - break; - } - if ( strcasecmp_w( cdir->d_m_name_ucs2, tmpname ) == 0 ) { - scdir = cdir; - } - cdir = (cdir == dir->d_child->d_prev) ? NULL :cdir->d_next; - } - free(tmpname); - } - else { - noucsfallback: - if (dir->d_did == DIRDID_ROOT_PARENT) { - /* - root parent (did 1) has one child: the volume. Requests for did=1 with some - must check against the volume name. - */ - if (!strcmp(vol->v_dir->d_m_name, ret.m_name)) - cdir = vol->v_dir; - else - cdir = NULL; + switch (ret.st.st_mode & S_IFMT) { + case S_IFREG: + LOG(log_debug, logtype_afpd, "came('%s'): {file: '%s'}", cfrombstring(dir->d_fullpath), ret.u_name); + if (len > 0) { + /* it wasn't the last part, so we have a bogus path request */ + afp_errno = AFPERR_PARAM; + return NULL; } - else { - cdir = dirsearch_byname(vol, dir, ret.u_name); + continue; /* continues while loop */ + case S_IFLNK: + LOG(log_debug, logtype_afpd, "came('%s'): {link: '%s'}", cfrombstring(dir->d_fullpath), ret.u_name); + if (len > 0) { + LOG(log_warning, logtype_afpd, "came('%s'): {symlinked dir: '%s'}", cfrombstring(dir->d_fullpath), ret.u_name); + afp_errno = AFPERR_PARAM; + return NULL; } + continue; /* continues while loop */ + case S_IFDIR: + break; + default: + LOG(log_info, logtype_afpd, "cname: special file: '%s'", ret.u_name); + afp_errno = AFPERR_NODIR; + return NULL; } - if (cdir == NULL && scdir != NULL) { - cdir = scdir; - /* LOG(log_debug, logtype_afpd, "cname: using casediff for %s, (%s = %s)", fullpathname(cdir->d_u_name), cdir->d_m_name, path ); */ - } - - if ( cdir == NULL ) { - ++extend; - /* if dir == curdir it always succeed, - even if curdir is deleted. - it's not a pb because it will fail in extenddir - */ - if ( movecwd( vol, dir ) < 0 ) { - /* dir is not valid anymore - we delete dir from the cache and abort. - */ - if ( dir->d_did == DIRDID_ROOT_PARENT) { - afp_errno = AFPERR_NOOBJ; - return NULL; - } - if (afp_errno == AFPERR_ACCESS) - return NULL; - dir_invalidate(vol, dir); + /* Search the cache */ + int unamelen = strlen(ret.u_name); + cdir = dircache_search_by_name(vol, dir->d_did, ret.u_name, unamelen); + if (cdir == NULL) { + /* Not in cache, create one */ + if ((cdir = dir_add(vol, dir, &ret, unamelen)) == NULL) { + LOG(log_error, logtype_afpd, "cname(did:%u, name:'%s', cwd:'%s'): failed to add dir", + ntohl(dir->d_did), ret.u_name, getcwdpath()); return NULL; } - cdir = extenddir( vol, dir, &ret ); } + } /* if/else cnid==1 */ + + /* Now chdir to the evaluated dir */ + if (movecwd( vol, cdir ) < 0 ) { + LOG(log_debug, logtype_afpd, "cname(cwd:'%s'): failed to chdir to new subdir '%s': %s", + cfrombstring(curdir->d_fullpath), cfrombstring(cdir->d_fullpath), strerror(errno)); + if (len == 0) + return path_from_dir(vol, cdir, &ret); + else + return NULL; + } + dir = cdir; + ret.m_name[0] = 0; /* so we later know last token was a dir */ + } /* while (len) */ - } else { - cdir = extenddir( vol, dir, &ret ); - } /* if (!extend) */ + if (curdir->d_did == DIRDID_ROOT_PARENT) { + afp_errno = AFPERR_DID1; + return NULL; + } - if ( cdir == NULL ) { + if (ret.m_name[0] == 0) { + /* Last part was a dir */ + ret.u_name = mtoupath(vol, ret.m_name, 0, 1); /* Force "." into a useable static buffer */ + ret.d_dir = dir; + } - if ( len > 0 || !ret.u_name ) { - return NULL; - } + LOG(log_debug, logtype_afpd, "came('%s') {end: curdir:'%s', path:'%s'}", + cfrombstring(dir->d_fullpath), + cfrombstring(curdir->d_fullpath), + ret.u_name); - } else { - dir = cdir; - *path = '\0'; - } - } /* for (;;) */ + return &ret; } /* - * Move curdir to dir, with a possible chdir() + * @brief chdir() to dir + * + * @param vol (r) pointer to struct vol + * @param dir (r) pointer to struct dir + * + * @returns 0 on success, -1 on error with afp_errno set appropiately */ -int movecwd(struct vol *vol, struct dir *dir) +int movecwd(const struct vol *vol, struct dir *dir) { - char path[MAXPATHLEN + 1]; - struct dir *d; - char *p, *u; - int n; + assert(vol); + + if (dir == NULL) + return -1; - if ( dir == curdir ) { + LOG(log_maxdebug, logtype_afpd, "movecwd(curdir:'%s', cwd:'%s')", + cfrombstring(curdir->d_fullpath), getcwdpath()); + + if ( dir == curdir) return( 0 ); - } - if ( dir->d_did == DIRDID_ROOT_PARENT) { - afp_errno = AFPERR_DID1; /* AFPERR_PARAM;*/ - return( -1 ); + if (dir->d_did == DIRDID_ROOT_PARENT) { + curdir = &rootParent; + return 0; } - p = path + sizeof(path) - 1; - *p-- = '\0'; - *p = '.'; - for ( d = dir; d->d_parent != NULL && d != curdir; d = d->d_parent ) { - u = d->d_u_name; - if (!u) { - /* parent directory is deleted */ - afp_errno = AFPERR_NOOBJ; - return -1; - } - n = strlen( u ); - if (p -n -1 < path) { - afp_errno = AFPERR_PARAM; - return -1; - } - *--p = '/'; - p -= n; - memcpy( p, u, n ); - } - if ( d != curdir ) { - n = strlen( vol->v_path ); - if (p -n -1 < path) { - afp_errno = AFPERR_PARAM; - return -1; - } - *--p = '/'; - p -= n; - memcpy( p, vol->v_path, n ); - } - if ( chdir( p ) < 0 ) { + LOG(log_debug, logtype_afpd, "movecwd(did:%u, '%s')", ntohl(dir->d_did), cfrombstring(dir->d_fullpath)); + + if ( chdir(cfrombstring(dir->d_fullpath)) < 0 ) { + LOG(log_debug, logtype_afpd, "movecwd('%s'): %s", cfrombstring(dir->d_fullpath), strerror(errno)); switch (errno) { case EACCES: case EPERM: @@ -1588,11 +1213,11 @@ int movecwd(struct vol *vol, struct dir *dir) break; default: afp_errno = AFPERR_NOOBJ; - } return( -1 ); } - vol->v_curdir = curdir = dir; + + curdir = dir; return( 0 ); } @@ -1644,30 +1269,15 @@ void setdiroffcnt(struct dir *dir, struct stat *st, u_int32_t count) dir->d_flags &= ~DIRF_CNID; } -/* --------------------- - * is our cached offspring count valid? - */ - -static int diroffcnt(struct dir *dir, struct stat *st) -{ - return st->st_ctime == dir->ctime; -} /* --------------------- * is our cached also for reenumerate id? */ - int dirreenumerate(struct dir *dir, struct stat *st) { return st->st_ctime == dir->ctime && (dir->d_flags & DIRF_CNID); } -/* --------------------- */ -static int invisible_dots(const struct vol *vol, const char *name) -{ - return vol_inv_dots(vol) && *name == '.' && strcmp(name, ".") && strcmp(name, ".."); -} - /* ------------------------------ (".", curdir) (name, dir) with curdir:name == dir, from afp_enumerate @@ -1706,20 +1316,14 @@ int getdirparams(const struct vol *vol, s_path->st.st_dev, s_path->st.st_ino, dir->d_did, - dir->d_parent->d_did, + dir->d_pdid, vol->v_stamp); ad_flush( &ad); } } } - if ( dir->d_did == DIRDID_ROOT) { - pdid = DIRDID_ROOT_PARENT; - } else if (dir->d_did == DIRDID_ROOT_PARENT) { - pdid = 0; - } else { - pdid = dir->d_parent->d_did; - } + pdid = dir->d_pdid; data = buf; while ( bitmap != 0 ) { @@ -1732,7 +1336,7 @@ int getdirparams(const struct vol *vol, case DIRPBIT_ATTR : if ( isad ) { ad_getattr(&ad, &ashort); - } else if (invisible_dots(vol, dir->d_u_name)) { + } else if (invisible_dots(vol, cfrombstring(dir->d_u_name))) { ashort = htons(ATTRBIT_INVISIBLE); } else ashort = 0; @@ -1776,7 +1380,7 @@ int getdirparams(const struct vol *vol, memcpy(data + FINDERINFO_FRVIEWOFF, &ashort, sizeof(ashort)); /* dot files are by default visible */ - if (invisible_dots(vol, dir->d_u_name)) { + if (invisible_dots(vol, cfrombstring(dir->d_u_name))) { ashort = htons(FINDERINFO_INVISIBLE); memcpy(data + FINDERINFO_FRFLAGOFF, &ashort, sizeof(ashort)); } @@ -1897,12 +1501,12 @@ int getdirparams(const struct vol *vol, if ( l_nameoff ) { ashort = htons( data - buf ); memcpy( l_nameoff, &ashort, sizeof( ashort )); - data = set_name(vol, data, pdid, dir->d_m_name, dir->d_did, 0); + data = set_name(vol, data, pdid, cfrombstring(dir->d_m_name), dir->d_did, 0); } if ( utf_nameoff ) { ashort = htons( data - buf ); memcpy( utf_nameoff, &ashort, sizeof( ashort )); - data = set_name(vol, data, pdid, dir->d_m_name, dir->d_did, utf8); + data = set_name(vol, data, pdid, cfrombstring(dir->d_m_name), dir->d_did, utf8); } if ( isad ) { ad_close_metadata( &ad ); @@ -1987,33 +1591,7 @@ int afp_setdirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_ * * assume path == '\0' eg. it's a directory in canonical form */ - -struct path Cur_Path = { - 0, - "", /* mac name */ - ".", /* unix name */ - 0, /* id */ - NULL,/* struct dir */ - 0, /* stat is not set */ -}; - -/* ------------------ */ -static int set_dir_errors(struct path *path, const char *where, int err) -{ - switch ( err ) { - case EPERM : - case EACCES : - return AFPERR_ACCESS; - case EROFS : - return AFPERR_VLOCK; - } - LOG(log_error, logtype_afpd, "setdirparam(%s): %s: %s", fullpathname(path->u_name), where, strerror(err) ); - return AFPERR_PARAM; -} - -/* ------------------ */ -int setdirparams(struct vol *vol, - struct path *path, u_int16_t d_bitmap, char *buf ) +int setdirparams(struct vol *vol, struct path *path, u_int16_t d_bitmap, char *buf ) { struct maccess ma; struct adouble ad; @@ -2165,7 +1743,7 @@ int setdirparams(struct vol *vol, * to set our name, etc. */ if ( (ad_get_HF_flags( &ad ) & O_CREAT)) { - ad_setname(&ad, curdir->d_m_name); + ad_setname(&ad, cfrombstring(curdir->d_m_name)); } } @@ -2322,14 +1900,15 @@ setdirparam_done: if (path->st_valid && !path->st_errno) { struct stat *st = &path->st; - if (dir && dir->d_parent) { - ad_setid(&ad, st->st_dev, st->st_ino, dir->d_did, dir->d_parent->d_did, vol->v_stamp); + if (dir && dir->d_pdid) { + ad_setid(&ad, st->st_dev, st->st_ino, dir->d_did, dir->d_pdid, vol->v_stamp); } } ad_flush( &ad); ad_close_metadata( &ad); } +#if 0 if (change_parent_mdate && dir->d_did != DIRDID_ROOT && gettimeofday(&tv, NULL) == 0) { if (!movecwd(vol, dir->d_parent)) { @@ -2340,7 +1919,7 @@ setdirparam_done: /* should we reset curdir ?*/ } } - +#endif return err; } @@ -2427,7 +2006,7 @@ int afp_syncdir(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, if ( fsync(dfd) < 0 ) LOG(log_error, logtype_afpd, "afp_syncdir(%s): %s", - vol->ad_path(dir->d_u_name, ADFLAGS_DIR), strerror(errno) ); + vol->ad_path(cfrombstring(dir->d_u_name), ADFLAGS_DIR), strerror(errno) ); close(dfd); } @@ -2480,18 +2059,22 @@ int afp_createdir(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_ return err; } + LOG(log_debug, logtype_afpd, "afp_createdir: alive1"); + if (of_stat(s_path) < 0) { return AFPERR_MISC; } + LOG(log_debug, logtype_afpd, "afp_createdir: alive2"); curdir->offcnt++; - if ((dir = adddir( vol, curdir, s_path)) == NULL) { + LOG(log_debug, logtype_afpd, "afp_createdir: alive3"); + if ((dir = dir_add(vol, curdir, s_path, strlen(s_path->u_name))) == NULL) { return AFPERR_MISC; } - + LOG(log_debug, logtype_afpd, "afp_createdir: alive4"); if ( movecwd( vol, dir ) < 0 ) { return( AFPERR_PARAM ); } - + LOG(log_debug, logtype_afpd, "afp_createdir: alive5"); ad_init(&ad, vol->v_adouble, vol->v_ad_options); if (ad_open_metadata( ".", ADFLAGS_DIR, O_CREAT, &ad ) < 0) { if (vol_noadouble(vol)) @@ -2520,7 +2103,6 @@ createdir_done: * dst new unix filename (not a pathname) * newname new mac name * newparent curdir - * */ int renamedir(const struct vol *vol, char *src, char *dst, struct dir *dir, @@ -2528,9 +2110,7 @@ int renamedir(const struct vol *vol, char *src, char *dst, char *newname) { struct adouble ad; - struct dir *parent; - char *buf; - int len, err; + int err; /* existence check moved to afp_moveandrename */ if ( unix_rename( src, dst ) < 0 ) { @@ -2561,11 +2141,6 @@ int renamedir(const struct vol *vol, char *src, char *dst, vol->vfs->vfs_renamedir(vol, src, dst); - len = strlen( newname ); - /* rename() succeeded so we need to update our tree even if we can't open - * metadata - */ - ad_init(&ad, vol->v_adouble, vol->v_ad_options); if (!ad_open_metadata( dst, ADFLAGS_DIR, 0, &ad)) { @@ -2574,50 +2149,11 @@ int renamedir(const struct vol *vol, char *src, char *dst, ad_close_metadata( &ad); } - dir_hash_del(vol, dir); - if (dir->d_m_name == dir->d_u_name) - dir->d_u_name = NULL; - - if ((buf = (char *) realloc( dir->d_m_name, len + 1 )) == NULL ) { - LOG(log_error, logtype_afpd, "renamedir: realloc mac name: %s", strerror(errno) ); - /* FIXME : fatal ? */ + if (dir_modify(vol, dir, curdir->d_did, 0, newname, dst, curdir->d_fullpath) != 0) { + LOG(log_error, logtype_afpd, "renamedir: fatal error from dir_modify: %s -> %s", src, dst); return AFPERR_MISC; } - dir->d_m_name = buf; - strcpy( dir->d_m_name, newname ); - - if (newname == dst) { - free(dir->d_u_name); - dir->d_u_name = dir->d_m_name; - } - else { - if ((buf = (char *) realloc( dir->d_u_name, strlen(dst) + 1 )) == NULL ) { - LOG(log_error, logtype_afpd, "renamedir: realloc unix name: %s", strerror(errno) ); - return AFPERR_MISC; - } - dir->d_u_name = buf; - strcpy( dir->d_u_name, dst ); - } - - if (dir->d_m_name_ucs2) - free(dir->d_m_name_ucs2); - - dir->d_m_name_ucs2 = NULL; - if ((size_t)-1 == convert_string_allocate((utf8_encoding())?CH_UTF8_MAC:vol->v_maccharset, CH_UCS2, dir->d_m_name, -1, (char**)&dir->d_m_name_ucs2)) - dir->d_m_name_ucs2 = NULL; - - if (( parent = dir->d_parent ) == NULL ) { - return( AFP_OK ); - } - if ( parent == newparent ) { - hash_alloc_insert(vol->v_hash, dir, dir); - return( AFP_OK ); - } - /* detach from old parent and add to new one. */ - dirchildremove(parent, dir); - dir->d_parent = newparent; - dirchildadd(vol, newparent, dir); return( AFP_OK ); } @@ -2632,7 +2168,7 @@ int deletecurdir(struct vol *vol) u_int16_t ashort; int err; - if ( curdir->d_parent == NULL ) { + if ( dirlookup(vol, curdir->d_pdid) == NULL ) { return( AFPERR_ACCESS ); } @@ -2673,14 +2209,13 @@ int deletecurdir(struct vol *vol) } } - if ( movecwd( vol, curdir->d_parent ) < 0 ) { + if ( movecwd(vol, dirlookup(vol, curdir->d_pdid)) < 0 ) { err = afp_errno; goto delete_done; } - err = netatalk_rmdir_all_errors(fdir->d_u_name); + err = netatalk_rmdir_all_errors(cfrombstring(fdir->d_u_name)); if ( err == AFP_OK || err == AFPERR_NOOBJ) { - dirchildremove(curdir, fdir); cnid_delete(vol->v_cdb, fdir->d_did); dir_remove( vol, fdir ); } diff --git a/etc/afpd/directory.h b/etc/afpd/directory.h index 0a699a2a..dd14692f 100644 --- a/etc/afpd/directory.h +++ b/etc/afpd/directory.h @@ -1,5 +1,5 @@ /* - * $Id: directory.h,v 1.33 2009-11-13 00:27:35 didg Exp $ + * $Id: directory.h,v 1.33.4.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -43,9 +43,6 @@ #include "globals.h" #include "volume.h" -#define DIRTREE_COLOR_RED 0 -#define DIRTREE_COLOR_BLACK 1 - #define DIRF_FSMASK (3<<0) #define DIRF_NOFS (0<<0) #define DIRF_AFS (1<<0) @@ -76,10 +73,6 @@ #define FILDIRBIT_ISDIR (1 << 7) /* is a directory */ #define FILDIRBIT_ISFILE (0) /* is a file */ -/* reserved directory id's */ -#define DIRDID_ROOT_PARENT htonl(1) /* parent directory of root */ -#define DIRDID_ROOT htonl(2) /* root directory */ - /* file/directory ids. what a mess. we scramble things in a vain attempt * to get something meaningful */ #ifndef AFS @@ -100,7 +93,6 @@ #define CNID(a,b) (((a)->st_ino & 0x7fffffff) | CNID_FILE(b)) #endif /* AFS */ - struct maccess { u_char ma_user; u_char ma_world; @@ -113,44 +105,33 @@ struct maccess { #define AR_UWRITE (1<<2) #define AR_UOWN (1<<7) -extern struct dir *dirnew (const char *, const char *); -extern void dirfreename (struct dir *); -extern void dirfree (struct dir *); -extern struct dir *dirsearch (const struct vol *, u_int32_t); -extern struct dir *dirlookup (struct vol *, u_int32_t); -extern struct dir *dirsearch_byname (const struct vol *, struct dir *,char *); - -extern struct dir *adddir (struct vol *, struct dir *, - struct path *); - -extern int movecwd (struct vol *, struct dir *); -extern int deletecurdir (struct vol *); -extern struct path *cname (struct vol *, struct dir *, - char **); -extern mode_t mtoumode (struct maccess *); -extern void utommode (struct stat *, struct maccess *); -extern int getdirparams (const struct vol *, u_int16_t, struct path *, - struct dir *, char *, size_t *); -extern int setdirparams (struct vol *, struct path *, u_int16_t, char *); -extern int renamedir (const struct vol *, char *, char *, struct dir *, - struct dir *, char *); -extern int path_error (struct path *, int error); - -extern void setdiroffcnt (struct dir *dir, struct stat *st, u_int32_t count); -extern int dirreenumerate (struct dir *dir, struct stat *st); - typedef int (*dir_loop)(struct dirent *, char *, void *); -extern int for_each_dirent (const struct vol *, char *, dir_loop , void *); - -extern int check_access (char *name , int mode); -extern int file_access (struct path *path, int mode); - -extern int netatalk_unlink (const char *name); - -extern int caseenumerate (const struct vol *, struct path *, struct dir *); - -extern hash_t *dirhash (void); +extern struct dir *dir_new(const char *mname, const char *uname, const struct vol *, cnid_t pdid, cnid_t did, bstring fullpath); /* volume.c needs it once */ +extern void dir_free (struct dir *); +extern struct dir *dir_add(const struct vol *, const struct dir *, struct path *, int); +extern int dir_modify(const struct vol *vol, struct dir *dir, cnid_t pdid, cnid_t did, const char *new_mname, const char *new_uname, bstring pdir_fullpath); +extern int dir_remove(const struct vol *vol, struct dir *dir); +extern struct dir *dirlookup (const struct vol *, cnid_t); +extern int movecwd (const struct vol *, struct dir *); +extern struct path *cname (struct vol *, struct dir *, char **); + +extern int deletecurdir (struct vol *); +extern mode_t mtoumode (struct maccess *); +extern void utommode (struct stat *, struct maccess *); +extern int getdirparams (const struct vol *, u_int16_t, struct path *, + struct dir *, char *, size_t *); +extern int setdirparams (struct vol *, struct path *, u_int16_t, char *); +extern int renamedir (const struct vol *, char *, char *, struct dir *, + struct dir *, char *); +extern int path_error (struct path *, int error); +extern void setdiroffcnt (struct dir *dir, struct stat *st, u_int32_t count); +extern int dirreenumerate (struct dir *dir, struct stat *st); +extern int for_each_dirent (const struct vol *, char *, dir_loop , void *); +extern int check_access (char *name , int mode); +extern int file_access (struct path *path, int mode); +extern int netatalk_unlink (const char *name); +extern int caseenumerate (const struct vol *, struct path *, struct dir *); /* from enumerate.c */ extern char *check_dirent (const struct vol *, char *); diff --git a/etc/afpd/enumerate.c b/etc/afpd/enumerate.c index 15235c6f..61ae747e 100644 --- a/etc/afpd/enumerate.c +++ b/etc/afpd/enumerate.c @@ -1,5 +1,5 @@ /* - * $Id: enumerate.c,v 1.48 2010-01-11 11:09:36 franklahm Exp $ + * $Id: enumerate.c,v 1.48.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -21,8 +21,12 @@ #include #include #include +#include +#include + #include "desktop.h" #include "directory.h" +#include "dircache.h" #include "volume.h" #include "globals.h" #include "file.h" @@ -266,8 +270,10 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, return path_error(o_path, AFPERR_NODIR ); } - LOG(log_debug, logtype_afpd, "enumerate(vid:%u, did:%u, name:'%s', f/d:%04x/%04x, rc:%u, i:%u, max:%u)", - ntohs(vid), ntohl(did), o_path->u_name, fbitmap, dbitmap, reqcnt, sindex, maxsz); + LOG(log_debug, logtype_afpd, "enumerate(vid:%u, did:%u, cwddid:%u, cwd:'%s', name:'%s', f/d:%04x/%04x, rc:%u, i:%u, max:%u)", + ntohs(vid), ntohl(did), ntohl(curdir->d_did), + cfrombstring(curdir->d_fullpath), o_path->u_name, + fbitmap, dbitmap, reqcnt, sindex, maxsz); data = rbuf + 3 * sizeof( u_int16_t ); sz = 3 * sizeof( u_int16_t ); /* fbitmap, dbitmap, reqcount */ @@ -370,14 +376,16 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, if ( dbitmap == 0 ) { continue; } - dir = dirsearch_byname(vol, curdir, s_path.u_name); - if (!dir && NULL == (dir = adddir( vol, curdir, &s_path) ) ) { + int len = strlen(s_path.u_name); + if ((dir = dircache_search_by_name(vol, curdir->d_did, s_path.u_name, len)) == NULL) { + if ((dir = dir_add(vol, curdir, &s_path, len)) == NULL) { + LOG(log_error, logtype_afpd, "enumerate(vid:%u, did:%u, name:'%s'): error adding dir: '%s'", + ntohs(vid), ntohl(did), o_path->u_name, s_path.u_name); return AFPERR_MISC; } - if (AFP_OK != ( ret = getdirparams(vol, dbitmap, &s_path, dir, - data + header , &esz ))) { - return( ret ); } + if ((ret = getdirparams(vol, dbitmap, &s_path, dir, data + header , &esz)) != AFP_OK) + return( ret ); } else { if ( fbitmap == 0 ) { diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 82c7739d..dd648658 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.131 2010-01-26 20:39:52 didg Exp $ + * $Id: file.c,v 1.131.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -191,7 +191,7 @@ char *set_name(const struct vol *vol, char *data, cnid_t pid, char *name, cnid_t (1 << FILPBIT_UNIXPR))) /* -------------------------- */ -u_int32_t get_id(struct vol *vol, struct adouble *adp, const struct stat *st, +u_int32_t get_id(const struct vol *vol, struct adouble *adp, const struct stat *st, const cnid_t did, char *upath, const int len) { u_int32_t adcnid; diff --git a/etc/afpd/file.h b/etc/afpd/file.h index c4253ca0..ad4e312a 100644 --- a/etc/afpd/file.h +++ b/etc/afpd/file.h @@ -1,5 +1,5 @@ /* - * $Id: file.h,v 1.24 2009-10-15 10:43:13 didg Exp $ + * $Id: file.h,v 1.24.4.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -127,7 +127,7 @@ extern void *get_finderinfo (const struct vol *, const char *, struct adouble *, extern size_t mtoUTF8 (const struct vol *, const char *, size_t , char *, size_t ); extern int copy_path_name (const struct vol *, char *, char *i); -extern u_int32_t get_id (struct vol *, struct adouble *, const struct stat *, +extern u_int32_t get_id (const struct vol *, struct adouble *, const struct stat *, const cnid_t , char *, const int ); /* FP functions */ diff --git a/etc/afpd/filedir.c b/etc/afpd/filedir.c index 897bb576..bbbc422f 100644 --- a/etc/afpd/filedir.c +++ b/etc/afpd/filedir.c @@ -1,5 +1,5 @@ /* - * $Id: filedir.c,v 1.69 2010-01-21 14:14:49 didg Exp $ + * $Id: filedir.c,v 1.69.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -39,6 +39,8 @@ char *strchr (), *strrchr (); #include #include #include +#include +#include #include "directory.h" #include "desktop.h" @@ -52,22 +54,22 @@ char *strchr (), *strrchr (); #ifdef DROPKLUDGE int matchfile2dirperms( /* Since it's kinda' big; I decided against an -inline function */ - char *upath, + inline function */ + char *upath, struct vol *vol, - int did) + int did) /* The below code changes the way file ownership is determined in the name of -fixing dropboxes. It has known security problem. See the netatalk FAQ for -more information */ + fixing dropboxes. It has known security problem. See the netatalk FAQ for + more information */ { - struct stat st, sb; - struct dir *dir; - char *adpath; + struct stat st, sb; + struct dir *dir; + char *adpath; uid_t uid; int ret = AFP_OK; #ifdef DEBUG LOG(log_debug9, logtype_afpd, "begin matchfile2dirperms:"); -#endif +#endif if (stat(upath, &st ) < 0) { LOG(log_error, logtype_afpd, "Could not stat %s: %s", upath, strerror(errno)); @@ -119,7 +121,7 @@ more information */ adpath, strerror(errno)); ret = AFPERR_ACCESS; } - seteuid(uid); + seteuid(uid); } } /* end else if stat success */ @@ -132,13 +134,13 @@ more information */ int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen) { - struct stat *st; - struct vol *vol; - struct dir *dir; + struct stat *st; + struct vol *vol; + struct dir *dir; u_int32_t did; - int ret; - size_t buflen; - u_int16_t fbitmap, dbitmap, vid; + int ret; + size_t buflen; + u_int16_t fbitmap, dbitmap, vid; struct path *s_path; *rbuflen = 0; @@ -149,7 +151,7 @@ int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *r if (NULL == ( vol = getvolbyvid( vid )) ) { /* was AFPERR_PARAM but it helps OS 10.3 when a volume has been removed * from the list. - */ + */ return( AFPERR_ACCESS ); } @@ -168,14 +170,16 @@ int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *r ibuf += sizeof( dbitmap ); if (NULL == ( s_path = cname( vol, dir, &ibuf )) ) { - return get_afp_errno(AFPERR_NOOBJ); + return get_afp_errno(AFPERR_NOOBJ); } - LOG(log_debug, logtype_afpd, "getfildirparams(vid:%u, did:%u, name:'%s', f/d:%04x/%04x) {cwd: %s}", - ntohs(vid), ntohl(dir->d_did), s_path->u_name, fbitmap, dbitmap, getcwdpath()); + LOG(log_debug, logtype_afpd, "getfildirparams(vid:%u, did:%u, f/d:%04x/%04x) {cwdid:%u, cwd: %s, name:'%s'}", + ntohs(vid), ntohl(dir->d_did), fbitmap, dbitmap, + ntohl(curdir->d_did), cfrombstring(curdir->d_fullpath), s_path->u_name); st = &s_path->st; if (!s_path->st_valid) { + LOG(log_debug, logtype_afpd, "getfildirparams: !s_path->st_valid"); /* it's a dir and it should be there * because we chdir in it in cname or * it's curdir (maybe deleted, but then we can't know). @@ -184,7 +188,10 @@ int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *r of_statdir(vol, s_path); } if ( s_path->st_errno != 0 ) { - return( AFPERR_NOOBJ ); + if (s_path->st_errno != EACCES) { + LOG(log_debug, logtype_afpd, "getfildirparams: s_path->st_errno != 0"); + return( AFPERR_NOOBJ ); + } } @@ -192,19 +199,19 @@ int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *r if (S_ISDIR(st->st_mode)) { if (dbitmap) { dir = s_path->d_dir; - if (!dir) + if (!dir) return AFPERR_NOOBJ; ret = getdirparams(vol, dbitmap, s_path, dir, - rbuf + 3 * sizeof( u_int16_t ), &buflen ); + rbuf + 3 * sizeof( u_int16_t ), &buflen ); if (ret != AFP_OK ) return( ret ); } /* this is a directory */ *(rbuf + 2 * sizeof( u_int16_t )) = (char) FILDIRBIT_ISDIR; } else { - if (fbitmap && AFP_OK != (ret = getfilparams(vol, fbitmap, s_path, curdir, - rbuf + 3 * sizeof( u_int16_t ), &buflen )) ) { + if (fbitmap && AFP_OK != (ret = getfilparams(vol, fbitmap, s_path, curdir, + rbuf + 3 * sizeof( u_int16_t ), &buflen )) ) { return( ret ); } /* this is a file */ @@ -224,12 +231,12 @@ int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *r int afp_setfildirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { - struct stat *st; - struct vol *vol; - struct dir *dir; + struct stat *st; + struct vol *vol; + struct dir *dir; struct path *path; - u_int16_t vid, bitmap; - int did, rc; + u_int16_t vid, bitmap; + int did, rc; *rbuflen = 0; ibuf += 2; @@ -247,7 +254,7 @@ int afp_setfildirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf ibuf += sizeof( did); if (NULL == ( dir = dirlookup( vol, did )) ) { - return afp_errno; + return afp_errno; } memcpy( &bitmap, ibuf, sizeof( bitmap )); @@ -255,7 +262,7 @@ int afp_setfildirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf ibuf += sizeof( bitmap ); if (NULL == ( path = cname( vol, dir, &ibuf ))) { - return get_afp_errno(AFPERR_NOOBJ); + return get_afp_errno(AFPERR_NOOBJ); } st = &path->st; @@ -288,7 +295,7 @@ int afp_setfildirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf return( rc ); } -/* -------------------------------------------- +/* -------------------------------------------- Factorise some checks on a pathname */ int check_name(const struct vol *vol, char *name) @@ -311,10 +318,10 @@ int check_name(const struct vol *vol, char *name) return 0; } -/* ------------------------- - move and rename sdir:oldname to curdir:newname in volume vol - - special care is needed for lock +/* ------------------------- + move and rename sdir:oldname to curdir:newname in volume vol + + special care is needed for lock */ static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname, char *newname, int isdir) { @@ -323,24 +330,24 @@ static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname, int rc; struct stat *st, nst; int adflags; - struct adouble ad; - struct adouble *adp; - struct ofork *opened = NULL; + struct adouble ad; + struct adouble *adp; + struct ofork *opened = NULL; struct path path; cnid_t id; ad_init(&ad, vol->v_adouble, vol->v_ad_options); adp = &ad; adflags = 0; - + if (!isdir) { p = mtoupath(vol, oldname, sdir->d_did, utf8_encoding()); - if (!p) { + if (!p) { return AFPERR_PARAM; /* can't convert */ } id = cnid_get(vol->v_cdb, sdir->d_did, p, strlen(p)); p = ctoupath( vol, sdir, oldname ); - if (!p) { + if (!p) { return AFPERR_PARAM; /* pathname too long */ } path.st_valid = 0; @@ -352,7 +359,7 @@ static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname, } else { id = sdir->d_did; /* we already have the CNID */ - p = ctoupath( vol, sdir->d_parent, oldname ); + p = ctoupath( vol, dirlookup(vol, sdir->d_pdid), oldname ); if (!p) { return AFPERR_PARAM; } @@ -360,30 +367,30 @@ static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname, } /* * p now points to the full pathname of the source fs object. - * + * * we are in the dest folder so we need to use p for ad_open - */ - + */ + if (!ad_metadata(p, adflags, adp)) { u_int16_t bshort; ad_getattr(adp, &bshort); ad_close_metadata( adp); - if ((bshort & htons(ATTRBIT_NORENAME))) + if ((bshort & htons(ATTRBIT_NORENAME))) return(AFPERR_OLOCK); } - if (NULL == (upath = mtoupath(vol, newname, curdir->d_did, utf8_encoding()))){ + if (NULL == (upath = mtoupath(vol, newname, curdir->d_did, utf8_encoding()))){ return AFPERR_PARAM; } path.u_name = upath; - st = &path.st; + st = &path.st; if (0 != (rc = check_name(vol, upath))) { - return rc; + return rc; } /* source == destination. we just silently accept this. */ - if ((!isdir && curdir == sdir) || (isdir && curdir == sdir->d_parent)) { + if ((!isdir && curdir == sdir) || (isdir && curdir->d_did == sdir->d_pdid)) { if (strcmp(oldname, newname) == 0) return AFP_OK; @@ -425,13 +432,13 @@ static int moveandrename(const struct vol *vol, struct dir *sdir, char *oldname, /* -------------------------------------------- */ int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { - struct vol *vol; - struct dir *sdir; + struct vol *vol; + struct dir *sdir; char *oldname, *newname; struct path *path; - u_int32_t did; + u_int32_t did; int plen; - u_int16_t vid; + u_int16_t vid; int isdir = 0; int rc; @@ -450,12 +457,12 @@ int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size memcpy( &did, ibuf, sizeof( did )); ibuf += sizeof( did ); if (NULL == ( sdir = dirlookup( vol, did )) ) { - return afp_errno; + return afp_errno; } /* source pathname */ if (NULL == ( path = cname( vol, sdir, &ibuf )) ) { - return get_afp_errno(AFPERR_NOOBJ); + return get_afp_errno(AFPERR_NOOBJ); } sdir = curdir; @@ -470,14 +477,14 @@ int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size } } else { - if ( sdir->d_parent == NULL ) { /* root directory */ + if ( sdir->d_did == DIRDID_ROOT ) { /* root directory */ return( AFPERR_NORENAME ); } /* move to destination dir */ - if ( movecwd( vol, sdir->d_parent ) < 0 ) { + if ( movecwd( vol, dirlookup(vol, sdir->d_pdid) ) < 0 ) { return afp_errno; } - strcpy(oldname, sdir->d_m_name); + memcpy(oldname, cfrombstring(sdir->d_m_name), blength(sdir->d_m_name) +1); } /* another place where we know about the path type */ @@ -488,7 +495,7 @@ int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size if (!plen) { return AFP_OK; /* newname == oldname same dir */ } - + rc = moveandrename(vol, sdir, oldname, newname, isdir); if ( rc == AFP_OK ) { @@ -501,12 +508,12 @@ int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size /* ------------------------------- */ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { - struct vol *vol; - struct dir *dir; + struct vol *vol; + struct dir *dir; struct path *s_path; - char *upath; - int did, rc; - u_int16_t vid; + char *upath; + int did, rc; + u_int16_t vid; *rbuflen = 0; ibuf += 2; @@ -522,22 +529,21 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size memcpy( &did, ibuf, sizeof( did )); ibuf += sizeof( int ); + if (NULL == ( dir = dirlookup( vol, did )) ) { - return afp_errno; + return afp_errno; } if (NULL == ( s_path = cname( vol, dir, &ibuf )) ) { - return get_afp_errno(AFPERR_NOOBJ); + return get_afp_errno(AFPERR_NOOBJ); } upath = s_path->u_name; if ( path_isadir( s_path) ) { - if (*s_path->m_name != '\0') { - rc = AFPERR_ACCESS; - } - else { + if (*s_path->m_name != '\0' || curdir->d_did == DIRDID_ROOT) + rc = AFPERR_ACCESS; + else rc = deletecurdir( vol); - } } else if (of_findname(s_path)) { rc = AFPERR_BUSY; } else { @@ -553,7 +559,7 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size } } if ( rc == AFP_OK ) { - curdir->offcnt--; + curdir->offcnt--; setvoltime(obj, vol ); } @@ -562,66 +568,51 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size /* ------------------------ */ char *absupath(const struct vol *vol, struct dir *dir, char *u) { - struct dir *d; - static char path[ MAXPATHLEN + 1]; - char *p; - int len; + static char pathbuf[MAXPATHLEN + 1]; + bstring path; - if (u == NULL) + if (u == NULL || dir == NULL || vol == NULL) return NULL; - - p = path + sizeof( path ) - 1; - *p = '\0'; - len = strlen( u ); - p -= len; - memcpy( p, u, len ); - if (dir) for ( d = dir; d->d_parent; d = d->d_parent ) { - u = d->d_u_name; - len = strlen( u ); - if (p -len -1 < path) { - /* FIXME - rather rare so LOG error and/or client message ? - */ - return NULL; - } - *--p = '/'; - p -= len; - memcpy( p, u, len ); - } - len = strlen( vol->v_path ); - if (p -len -1 < path) { + + if ((path = bstrcpy(dir->d_fullpath)) == NULL) + return NULL; + if (bcatcstr(path, "/") != BSTR_OK) + return NULL; + if (bcatcstr(path, u) != BSTR_OK) + return NULL; + if (path->slen > MAXPATHLEN) return NULL; - } - *--p = '/'; - p -= len; - memcpy( p, vol->v_path, len ); - return( p ); + LOG(log_debug, logtype_afpd, "absupath: %s", cfrombstring(path)); + + strncpy(pathbuf, cfrombstring(path), blength(path) + 1); + bdestroy(path); + + return(pathbuf); } -/* ------------------------ - * FIXME dir could be NULL -*/ char *ctoupath(const struct vol *vol, struct dir *dir, char *name) { + if (vol == NULL || dir == NULL || name == NULL) + return NULL; return absupath(vol, dir, mtoupath(vol, name, dir->d_did, utf8_encoding())); } /* ------------------------- */ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { - struct vol *vol; - struct dir *sdir, *ddir; + struct vol *vol; + struct dir *sdir, *ddir; int isdir; - char *oldname, *newname; + char *oldname, *newname; struct path *path; - int did; - int pdid; + int did; + int pdid; int plen; - u_int16_t vid; + u_int16_t vid; int rc; #ifdef DROPKLUDGE - int retvalue; + int retvalue; #endif /* DROPKLUDGE */ *rbuflen = 0; @@ -648,21 +639,21 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U /* source pathname */ if (NULL == ( path = cname( vol, sdir, &ibuf )) ) { - return get_afp_errno(AFPERR_NOOBJ); + return get_afp_errno(AFPERR_NOOBJ); } sdir = curdir; newname = obj->newtmp; oldname = obj->oldtmp; - + isdir = path_isadir(path); if ( *path->m_name != '\0' ) { if (isdir) { sdir = path->d_dir; - } + } strcpy(oldname, path->m_name); /* an extra copy for of_rename */ } else { - strcpy(oldname, sdir->d_m_name); + memcpy(oldname, cfrombstring(sdir->d_m_name), blength(sdir->d_m_name) + 1); } /* get the destination directory */ @@ -686,11 +677,13 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U strcpy(newname, oldname); } + LOG(log_debug, logtype_afpd, "afp_move: {oldname:'%s', newname:'%s', isdir:%u}", + oldname, newname, isdir); rc = moveandrename(vol, sdir, oldname, newname, isdir); if ( rc == AFP_OK ) { char *upath = mtoupath(vol, newname, pdid, utf8_encoding()); - + if (NULL == upath) { return AFPERR_PARAM; } @@ -725,8 +718,8 @@ int veto_file(const char*veto_str, const char*path) * otherwise, 0 is returned. */ { - int i; /* index to veto_str */ - int j; /* index to path */ + int i; /* index to veto_str */ + int j; /* index to path */ if ((veto_str == NULL) || (path == NULL)) return 0; @@ -741,7 +734,7 @@ int veto_file(const char*veto_str, const char*path) } else { if (veto_str[i] != path[j]) { while ((veto_str[i] != '/') - && (veto_str[i] != '\0')) + && (veto_str[i] != '\0')) i++; j = 0; continue; diff --git a/etc/afpd/globals.h b/etc/afpd/globals.h index a88adab9..ec1911e6 100644 --- a/etc/afpd/globals.h +++ b/etc/afpd/globals.h @@ -1,5 +1,5 @@ /* - * $Id: globals.h,v 1.31 2010-01-18 12:55:28 franklahm Exp $ + * $Id: globals.h,v 1.31.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -139,6 +139,9 @@ extern int parseline (int, char *); extern const char *AfpNum2name (int ); extern const char *AfpErr2name(int err); +/* directory.c */ +extern struct dir rootParent; + #ifndef NO_DDP extern void afp_over_asp (AFPObj *); #endif /* NO_DDP */ diff --git a/etc/afpd/mangle.c b/etc/afpd/mangle.c index c00b76ba..260d1e62 100644 --- a/etc/afpd/mangle.c +++ b/etc/afpd/mangle.c @@ -1,5 +1,5 @@ /* - * $Id: mangle.c,v 1.19 2006-09-19 01:35:45 didg Exp $ + * $Id: mangle.c,v 1.19.4.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com) * All Rights Reserved. See COPYRIGHT. @@ -169,8 +169,8 @@ private_demangle(const struct vol *vol, char *mfilename, cnid_t did, cnid_t *osx } /* is it a dir?, there's a conflict with pre OSX 'trash #2' */ - if ((dir = dirsearch(vol, id))) { - if (dir->d_parent && dir->d_parent->d_did != did) { + if ((dir = dirlookup(vol, id))) { + if (dir->d_did != did) { /* not in the same folder, there's a race with outdate cache * but we have to live with it, hopefully client will recover */ @@ -178,12 +178,12 @@ private_demangle(const struct vol *vol, char *mfilename, cnid_t did, cnid_t *osx } if (!osx) { /* it's not from cname so mfilename and dir must be the same */ - if (!strcmp(dir->d_m_name, mfilename)) { - return dir->d_u_name; + if (strcmp((char *)dir->d_m_name->data, mfilename) == 0) { + return (char *)dir->d_u_name->data; } } else { - return demangle_checks (vol, dir->d_u_name, mfilename, prefix, t); + return demangle_checks (vol, (char *)dir->d_u_name->data, mfilename, prefix, t); } } else if (NULL != (u_name = cnid_resolve(vol->v_cdb, &id, buffer, len)) ) { diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index 9bb69667..14f0bb88 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -1,5 +1,5 @@ /* - * $Id: ofork.c,v 1.30 2009-11-13 00:27:36 didg Exp $ + * $Id: ofork.c,v 1.30.4.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1996 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -17,10 +17,12 @@ #include #include /* works around a bug */ #include -#include #include +#include #include +#include +#include #include "globals.h" #include "volume.h" @@ -280,14 +282,17 @@ struct ofork *of_find(const u_int16_t ofrefnum ) } /* -------------------------- */ -int of_stat (struct path *path) +int of_stat(struct path *path) { -int ret; + int ret; + + LOG(log_maxdebug, logtype_afpd, "of_stat: {stat:'%s/%s'}", getcwdpath(), path->u_name); + path->st_errno = 0; path->st_valid = 1; if ((ret = stat(path->u_name, &path->st)) < 0) path->st_errno = errno; - return ret; + return ret; } /* -------------------------- @@ -295,10 +300,12 @@ int ret; stat(".") works even if "." is deleted thus we have to stat ../name because we want to know if it's there */ -int of_statdir (struct vol *vol, struct path *path) +int of_statdir(struct vol *vol, struct path *path) { -static char pathname[ MAXPATHLEN + 1] = "../"; -int ret; + static char pathname[ MAXPATHLEN + 1] = "../"; + int ret; + size_t len; + struct dir *dir; if (*path->m_name) { /* not curdir */ @@ -307,26 +314,32 @@ int ret; path->st_errno = 0; path->st_valid = 1; /* FIXME, what about: we don't have r-x perm anymore ? */ - strlcpy(pathname +3, path->d_dir->d_u_name, sizeof (pathname) -3); + len = blength(path->d_dir->d_u_name); + if (len > (MAXPATHLEN - 3)) + len = MAXPATHLEN - 3; + strncpy(pathname + 3, cfrombstring(path->d_dir->d_u_name), len + 1); + + LOG(log_debug, logtype_afpd, "of_statdir: stating: '%s'", pathname); if (!(ret = stat(pathname, &path->st))) return 0; path->st_errno = errno; + /* hmm, can't stat curdir anymore */ - if (errno == EACCES && curdir->d_parent ) { - if (movecwd(vol, curdir->d_parent)) + if (errno == EACCES && (dir = dirlookup(vol, curdir->d_pdid))) { + if (movecwd(vol, dir)) return -1; path->st_errno = 0; - if ((ret = stat(path->d_dir->d_u_name, &path->st)) < 0) + if ((ret = stat(cfrombstring(path->d_dir->d_u_name), &path->st)) < 0) path->st_errno = errno; } + return ret; } /* -------------------------- */ -struct ofork * - of_findname(struct path *path) +struct ofork *of_findname(struct path *path) { struct ofork *of; struct file_key key; diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index e43d3b4a..2b6b24c2 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.115 2010-01-26 09:31:59 didg Exp $ + * $Id: volume.c,v 1.115.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -2008,9 +2008,6 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t volume->max_filename = MACFILELEN; } - volume->v_dir = volume->v_root = NULL; - volume->v_hash = NULL; - volume->v_flags |= AFPVOL_OPEN; volume->v_cdb = NULL; @@ -2029,7 +2026,13 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t else if (*(vol_uname + 1) != '\0') vol_uname++; - if ((dir = dirnew(vol_mname, vol_uname) ) == NULL) { + if ((dir = dir_new(vol_mname, + vol_uname, + volume, + DIRDID_ROOT_PARENT, + DIRDID_ROOT, + bfromcstr(volume->v_path)) + ) == NULL) { free(vol_mname); LOG(log_error, logtype_afpd, "afp_openvol(%s): malloc: %s", volume->v_path, strerror(errno) ); ret = AFPERR_MISC; @@ -2037,14 +2040,9 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t } free(vol_mname); - dir->d_did = DIRDID_ROOT; - dir->d_color = DIRTREE_COLOR_BLACK; /* root node is black */ - dir->d_m_name_ucs2 = strdup_w(volume->v_name); - volume->v_dir = volume->v_root = dir; - volume->v_curdir = NULL; - volume->v_hash = dirhash(); + volume->v_root = dir; + curdir = dir; - curdir = volume->v_dir; if (volume_openDB(volume) < 0) { LOG(log_error, logtype_afpd, "Fatal error: cannot open CNID or invalid CNID backend for %s: %s", volume->v_path, volume->v_cnidscheme); @@ -2081,16 +2079,15 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t } else { p = Trash; - cname( volume, volume->v_dir, &p ); + cname( volume, volume->v_root, &p ); } return( AFP_OK ); } openvol_err: - if (volume->v_dir) { - hash_free( volume->v_hash); - dirfree( volume->v_dir ); - volume->v_dir = volume->v_root = NULL; + if (volume->v_root) { + dir_free( volume->v_root ); + volume->v_root = NULL; } volume->v_flags &= ~AFPVOL_OPEN; @@ -2108,9 +2105,8 @@ static void closevol(struct vol *vol) if (!vol) return; - hash_free( vol->v_hash); - dirfree( vol->v_root ); - vol->v_dir = NULL; + dir_free( vol->v_root ); + vol->v_root = NULL; if (vol->v_cdb != NULL) { cnid_close(vol->v_cdb); vol->v_cdb = NULL; @@ -2151,7 +2147,7 @@ static void deletevol(struct vol *vol) if ( ovol != NULL ) { /* Even if chdir fails, we can't say afp_closevol fails. */ if ( chdir( ovol->v_path ) == 0 ) { - curdir = ovol->v_dir; + curdir = ovol->v_root; } } diff --git a/include/atalk/Makefile.am b/include/atalk/Makefile.am index 69000564..739629bc 100644 --- a/include/atalk/Makefile.am +++ b/include/atalk/Makefile.am @@ -8,4 +8,4 @@ atalkinclude_HEADERS = \ server_ipc.h tdb.h uam.h unicode.h util.h uuid.h volinfo.h \ zip.h ea.h acl.h unix.h directory.h hash.h volume.h -noinst_HEADERS = cnid_dbd_private.h cnid_private.h +noinst_HEADERS = cnid_dbd_private.h cnid_private.h bstrlib.h diff --git a/include/atalk/bstradd.h b/include/atalk/bstradd.h new file mode 100644 index 00000000..a402339a --- /dev/null +++ b/include/atalk/bstradd.h @@ -0,0 +1,41 @@ +/* + $Id: bstradd.h,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +/*! + * @file + * Additional functions for bstrlib. + */ + +#ifndef ATALK_BSTRADD_H +#define ATALK_BSTRADD_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#define cfrombstring(b) ((char *)((b)->data)) + +typedef struct tagbstring static_bstring; + +extern bstring brefcstr(const char *str); +extern int bunrefcstr(bstring b); + +extern struct bstrList *bstListCreateMin(int min); +extern int bstrListPush(struct bstrList *sl, bstring bs); +extern bstring bstrListPop(struct bstrList *sl); +extern bstring bjoinInv(const struct bstrList * bl, const_bstring sep); +#endif /* ATALK_BSTRADD_H */ diff --git a/include/atalk/bstrlib.h b/include/atalk/bstrlib.h new file mode 100755 index 00000000..6dc888a2 --- /dev/null +++ b/include/atalk/bstrlib.h @@ -0,0 +1,300 @@ +/* + * This source file is part of the bstring string library. This code was + * written by Paul Hsieh in 2002-2008, and is covered by the BSD open source + * license and the GPL. Refer to the accompanying documentation for details + * on usage and license. + */ + +/*! + * @file + * This file is the core module for implementing the bstring functions. + */ + +#ifndef BSTRLIB_INCLUDE +#define BSTRLIB_INCLUDE + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#if !defined (BSTRLIB_VSNP_OK) && !defined (BSTRLIB_NOVSNP) +# if defined (__TURBOC__) && !defined (__BORLANDC__) +# define BSTRLIB_NOVSNP +# endif +#endif + +#define BSTR_ERR (-1) +#define BSTR_OK (0) +#define BSTR_BS_BUFF_LENGTH_GET (0) + +typedef struct tagbstring * bstring; +typedef const struct tagbstring * const_bstring; + +/* Copy functions */ +#define cstr2bstr bfromcstr +extern bstring bfromcstr (const char * str); +extern bstring bfromcstralloc (int mlen, const char * str); +extern bstring blk2bstr (const void * blk, int len); +extern char * bstr2cstr (const_bstring s, char z); +extern int bcstrfree (char * s); +extern bstring bstrcpy (const_bstring b1); +extern int bassign (bstring a, const_bstring b); +extern int bassignmidstr (bstring a, const_bstring b, int left, int len); +extern int bassigncstr (bstring a, const char * str); +extern int bassignblk (bstring a, const void * s, int len); + +/* Destroy function */ +extern int bdestroy (bstring b); + +/* Space allocation hinting functions */ +extern int balloc (bstring s, int len); +extern int ballocmin (bstring b, int len); + +/* Substring extraction */ +extern bstring bmidstr (const_bstring b, int left, int len); + +/* Various standard manipulations */ +extern int bconcat (bstring b0, const_bstring b1); +extern int bconchar (bstring b0, char c); +extern int bcatcstr (bstring b, const char * s); +extern int bcatblk (bstring b, const void * s, int len); +extern int binsert (bstring s1, int pos, const_bstring s2, unsigned char fill); +extern int binsertch (bstring s1, int pos, int len, unsigned char fill); +extern int breplace (bstring b1, int pos, int len, const_bstring b2, unsigned char fill); +extern int bdelete (bstring s1, int pos, int len); +extern int bsetstr (bstring b0, int pos, const_bstring b1, unsigned char fill); +extern int btrunc (bstring b, int n); + +/* Scan/search functions */ +extern int bstricmp (const_bstring b0, const_bstring b1); +extern int bstrnicmp (const_bstring b0, const_bstring b1, int n); +extern int biseqcaseless (const_bstring b0, const_bstring b1); +extern int bisstemeqcaselessblk (const_bstring b0, const void * blk, int len); +extern int biseq (const_bstring b0, const_bstring b1); +extern int bisstemeqblk (const_bstring b0, const void * blk, int len); +extern int biseqcstr (const_bstring b, const char * s); +extern int biseqcstrcaseless (const_bstring b, const char * s); +extern int bstrcmp (const_bstring b0, const_bstring b1); +extern int bstrncmp (const_bstring b0, const_bstring b1, int n); +extern int binstr (const_bstring s1, int pos, const_bstring s2); +extern int binstrr (const_bstring s1, int pos, const_bstring s2); +extern int binstrcaseless (const_bstring s1, int pos, const_bstring s2); +extern int binstrrcaseless (const_bstring s1, int pos, const_bstring s2); +extern int bstrchrp (const_bstring b, int c, int pos); +extern int bstrrchrp (const_bstring b, int c, int pos); +#define bstrchr(b,c) bstrchrp ((b), (c), 0) +#define bstrrchr(b,c) bstrrchrp ((b), (c), blength(b)-1) +extern int binchr (const_bstring b0, int pos, const_bstring b1); +extern int binchrr (const_bstring b0, int pos, const_bstring b1); +extern int bninchr (const_bstring b0, int pos, const_bstring b1); +extern int bninchrr (const_bstring b0, int pos, const_bstring b1); +extern int bfindreplace (bstring b, const_bstring find, const_bstring repl, int pos); +extern int bfindreplacecaseless (bstring b, const_bstring find, const_bstring repl, int pos); + +/* List of string container functions */ +struct bstrList { + int qty, mlen; + bstring * entry; +}; +extern struct bstrList * bstrListCreate (void); +extern int bstrListDestroy (struct bstrList * sl); +extern int bstrListAlloc (struct bstrList * sl, int msz); +extern int bstrListAllocMin (struct bstrList * sl, int msz); + +/* String split and join functions */ +extern struct bstrList * bsplit (const_bstring str, unsigned char splitChar); +extern struct bstrList * bsplits (const_bstring str, const_bstring splitStr); +extern struct bstrList * bsplitstr (const_bstring str, const_bstring splitStr); +extern bstring bjoin (const struct bstrList * bl, const_bstring sep); +extern int bsplitcb (const_bstring str, unsigned char splitChar, int pos, + int (* cb) (void * parm, int ofs, int len), void * parm); +extern int bsplitscb (const_bstring str, const_bstring splitStr, int pos, + int (* cb) (void * parm, int ofs, int len), void * parm); +extern int bsplitstrcb (const_bstring str, const_bstring splitStr, int pos, + int (* cb) (void * parm, int ofs, int len), void * parm); + +/* Miscellaneous functions */ +extern int bpattern (bstring b, int len); +extern int btoupper (bstring b); +extern int btolower (bstring b); +extern int bltrimws (bstring b); +extern int brtrimws (bstring b); +extern int btrimws (bstring b); + +#if !defined (BSTRLIB_NOVSNP) +extern bstring bformat (const char * fmt, ...); +extern int bformata (bstring b, const char * fmt, ...); +extern int bassignformat (bstring b, const char * fmt, ...); +extern int bvcformata (bstring b, int count, const char * fmt, va_list arglist); + +#define bvformata(ret, b, fmt, lastarg) { \ +bstring bstrtmp_b = (b); \ +const char * bstrtmp_fmt = (fmt); \ +int bstrtmp_r = BSTR_ERR, bstrtmp_sz = 16; \ + for (;;) { \ + va_list bstrtmp_arglist; \ + va_start (bstrtmp_arglist, lastarg); \ + bstrtmp_r = bvcformata (bstrtmp_b, bstrtmp_sz, bstrtmp_fmt, bstrtmp_arglist); \ + va_end (bstrtmp_arglist); \ + if (bstrtmp_r >= 0) { /* Everything went ok */ \ + bstrtmp_r = BSTR_OK; \ + break; \ + } else if (-bstrtmp_r <= bstrtmp_sz) { /* A real error? */ \ + bstrtmp_r = BSTR_ERR; \ + break; \ + } \ + bstrtmp_sz = -bstrtmp_r; /* Doubled or target size */ \ + } \ + ret = bstrtmp_r; \ +} + +#endif + +typedef int (*bNgetc) (void *parm); +typedef size_t (* bNread) (void *buff, size_t elsize, size_t nelem, void *parm); + +/* Input functions */ +extern bstring bgets (bNgetc getcPtr, void * parm, char terminator); +extern bstring bread (bNread readPtr, void * parm); +extern int bgetsa (bstring b, bNgetc getcPtr, void * parm, char terminator); +extern int bassigngets (bstring b, bNgetc getcPtr, void * parm, char terminator); +extern int breada (bstring b, bNread readPtr, void * parm); + +/* Stream functions */ +extern struct bStream * bsopen (bNread readPtr, void * parm); +extern void * bsclose (struct bStream * s); +extern int bsbufflength (struct bStream * s, int sz); +extern int bsreadln (bstring b, struct bStream * s, char terminator); +extern int bsreadlns (bstring r, struct bStream * s, const_bstring term); +extern int bsread (bstring b, struct bStream * s, int n); +extern int bsreadlna (bstring b, struct bStream * s, char terminator); +extern int bsreadlnsa (bstring r, struct bStream * s, const_bstring term); +extern int bsreada (bstring b, struct bStream * s, int n); +extern int bsunread (struct bStream * s, const_bstring b); +extern int bspeek (bstring r, const struct bStream * s); +extern int bssplitscb (struct bStream * s, const_bstring splitStr, + int (* cb) (void * parm, int ofs, const_bstring entry), void * parm); +extern int bssplitstrcb (struct bStream * s, const_bstring splitStr, + int (* cb) (void * parm, int ofs, const_bstring entry), void * parm); +extern int bseof (const struct bStream * s); + +struct tagbstring { + int mlen; + int slen; + unsigned char * data; +}; + +/* Accessor macros */ +#define blengthe(b, e) (((b) == (void *)0 || (b)->slen < 0) ? (int)(e) : ((b)->slen)) +#define blength(b) (blengthe ((b), 0)) +#define bdataofse(b, o, e) (((b) == (void *)0 || (b)->data == (void*)0) ? (char *)(e) : ((char *)(b)->data) + (o)) +#define bdataofs(b, o) (bdataofse ((b), (o), (void *)0)) +#define bdatae(b, e) (bdataofse (b, 0, e)) +#define bdata(b) (bdataofs (b, 0)) +#define bchare(b, p, e) ((((unsigned)(p)) < (unsigned)blength(b)) ? ((b)->data[(p)]) : (e)) +#define bchar(b, p) bchare ((b), (p), '\0') + +/* Static constant string initialization macro */ +#define bsStaticMlen(q,m) {(m), (int) sizeof(q)-1, (unsigned char *) ("" q "")} +#if defined(_MSC_VER) +# define bsStatic(q) bsStaticMlen(q,-32) +#endif +#ifndef bsStatic +# define bsStatic(q) bsStaticMlen(q,-__LINE__) +#endif + +/* Static constant block parameter pair */ +#define bsStaticBlkParms(q) ((void *)("" q "")), ((int) sizeof(q)-1) + +/* Reference building macros */ +#define cstr2tbstr btfromcstr +#define btfromcstr(t,s) { \ + (t).data = (unsigned char *) (s); \ + (t).slen = ((t).data) ? ((int) (strlen) ((char *)(t).data)) : 0; \ + (t).mlen = -1; \ +} +#define blk2tbstr(t,s,l) { \ + (t).data = (unsigned char *) (s); \ + (t).slen = l; \ + (t).mlen = -1; \ +} +#define btfromblk(t,s,l) blk2tbstr(t,s,l) +#define bmid2tbstr(t,b,p,l) { \ + const_bstring bstrtmp_s = (b); \ + if (bstrtmp_s && bstrtmp_s->data && bstrtmp_s->slen >= 0) { \ + int bstrtmp_left = (p); \ + int bstrtmp_len = (l); \ + if (bstrtmp_left < 0) { \ + bstrtmp_len += bstrtmp_left; \ + bstrtmp_left = 0; \ + } \ + if (bstrtmp_len > bstrtmp_s->slen - bstrtmp_left) \ + bstrtmp_len = bstrtmp_s->slen - bstrtmp_left; \ + if (bstrtmp_len <= 0) { \ + (t).data = (unsigned char *)""; \ + (t).slen = 0; \ + } else { \ + (t).data = bstrtmp_s->data + bstrtmp_left; \ + (t).slen = bstrtmp_len; \ + } \ + } else { \ + (t).data = (unsigned char *)""; \ + (t).slen = 0; \ + } \ + (t).mlen = -__LINE__; \ +} +#define btfromblkltrimws(t,s,l) { \ + int bstrtmp_idx = 0, bstrtmp_len = (l); \ + unsigned char * bstrtmp_s = (s); \ + if (bstrtmp_s && bstrtmp_len >= 0) { \ + for (; bstrtmp_idx < bstrtmp_len; bstrtmp_idx++) { \ + if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \ + } \ + } \ + (t).data = bstrtmp_s + bstrtmp_idx; \ + (t).slen = bstrtmp_len - bstrtmp_idx; \ + (t).mlen = -__LINE__; \ +} +#define btfromblkrtrimws(t,s,l) { \ + int bstrtmp_len = (l) - 1; \ + unsigned char * bstrtmp_s = (s); \ + if (bstrtmp_s && bstrtmp_len >= 0) { \ + for (; bstrtmp_len >= 0; bstrtmp_len--) { \ + if (!isspace (bstrtmp_s[bstrtmp_len])) break; \ + } \ + } \ + (t).data = bstrtmp_s; \ + (t).slen = bstrtmp_len + 1; \ + (t).mlen = -__LINE__; \ +} +#define btfromblktrimws(t,s,l) { \ + int bstrtmp_idx = 0, bstrtmp_len = (l) - 1; \ + unsigned char * bstrtmp_s = (s); \ + if (bstrtmp_s && bstrtmp_len >= 0) { \ + for (; bstrtmp_idx <= bstrtmp_len; bstrtmp_idx++) { \ + if (!isspace (bstrtmp_s[bstrtmp_idx])) break; \ + } \ + for (; bstrtmp_len >= bstrtmp_idx; bstrtmp_len--) { \ + if (!isspace (bstrtmp_s[bstrtmp_len])) break; \ + } \ + } \ + (t).data = bstrtmp_s + bstrtmp_idx; \ + (t).slen = bstrtmp_len + 1 - bstrtmp_idx; \ + (t).mlen = -__LINE__; \ +} + +/* Write protection macros */ +#define bwriteprotect(t) { if ((t).mlen >= 0) (t).mlen = -1; } +#define bwriteallow(t) { if ((t).mlen == -1) (t).mlen = (t).slen + ((t).slen == 0); } +#define biswriteprotected(t) ((t).mlen <= 0) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/atalk/directory.h b/include/atalk/directory.h index 17e5d087..dd889dbb 100644 --- a/include/atalk/directory.h +++ b/include/atalk/directory.h @@ -1,5 +1,5 @@ /* - * $Id: directory.h,v 1.3 2010-01-10 10:58:25 franklahm Exp $ + * $Id: directory.h,v 1.3.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -30,9 +30,11 @@ #include #include #include +#include #include -#include +#include +#include /* setgid directories */ #ifndef DIRBITS @@ -43,30 +45,33 @@ # endif /* AFS */ #endif /* DIRBITS */ -/* the did tree is now a red-black tree while the parent/child - * tree is a circular doubly-linked list. how exciting. */ -struct dir { - struct dir *d_left, *d_right, *d_back; /* for red-black tree */ - int d_color; - struct dir *d_parent, *d_child; /* parent-child */ - struct dir *d_prev, *d_next; /* siblings */ - void *d_ofork; /* oforks using this directory. */ - u_int32_t d_did; - int d_flags; +/* reserved directory id's */ +#define DIRDID_ROOT_PARENT htonl(1) /* parent directory of root */ +#define DIRDID_ROOT htonl(2) /* root directory */ +struct dir { + bstring d_fullpath; /* complete unix path to dir */ + bstring d_m_name; /* mac name */ + bstring d_u_name; /* unix name */ + /* be careful here! if d_m_name == d_u_name, d_u_name */ + /* will just point to the same storage as d_m_name !! */ + ucs2_t *d_m_name_ucs2; /* mac name as UCS2 */ + qnode_t *qidx_node; /* pointer to position in queue index */ + void *d_ofork; /* oforks using this directory. */ time_t ctime; /* inode ctime */ - u_int32_t offcnt; /* offspring count */ - - char *d_m_name; /* mac name */ - char *d_u_name; /* unix name */ - ucs2_t *d_m_name_ucs2; /* mac name as UCS2 */ + int d_flags; /* directory flags */ + cnid_t d_pdid; /* CNID of parent directory */ + cnid_t d_did; /* CNID of directory */ + uint32_t offcnt; /* offspring count */ + uint16_t d_vid; /* only needed in the dircache, because + we put all directories in one cache. */ }; struct path { int m_type; /* mac name type (long name, unicode */ - char *m_name; /* mac name */ + char *m_name; /* mac name */ char *u_name; /* unix name */ - cnid_t id; /* file id (only for getmetadata) */ + cnid_t id; /* file id (only for getmetadata) */ struct dir *d_dir; /* */ int st_valid; /* does st_errno and st set */ int st_errno; @@ -83,5 +88,4 @@ static inline int path_isadir(struct path *o_path) #endif } - #endif /* ATALK_DIRECTORY_H */ diff --git a/include/atalk/queue.h b/include/atalk/queue.h new file mode 100644 index 00000000..6d8c8dce --- /dev/null +++ b/include/atalk/queue.h @@ -0,0 +1,40 @@ +/* + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef ATALK_QUEUE_H +#define ATALK_QUEUE_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +typedef struct qnode { + struct qnode *prev; + struct qnode *next; + void *data; +} qnode_t; + +typedef qnode_t queue_t; + +extern queue_t *queue_init(void); +extern void queue_destroy(queue_t *q, void (*callback)(void *)); +#define queue_free(q) queue_destroy((q), free) +extern qnode_t *enqueue(queue_t *q, void *data); +extern void *dequeue(queue_t *q); + +#endif /* ATALK_QUEUE_H */ diff --git a/include/atalk/volume.h b/include/atalk/volume.h index 0a4f1c88..06bbe53b 100644 --- a/include/atalk/volume.h +++ b/include/atalk/volume.h @@ -1,5 +1,5 @@ /* - * $Id: volume.h,v 1.11 2010-01-05 12:06:34 franklahm Exp $ + * $Id: volume.h,v 1.11.2.1 2010-02-01 10:56:08 franklahm Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -25,9 +25,7 @@ struct vol { u_int16_t v_vid; int v_flags; char *v_path; - struct dir *v_dir, *v_root; - struct dir *v_curdir; /* cache */ - hash_t *v_hash; + struct dir *v_root; time_t v_mtime; charset_t v_volcharset; diff --git a/libatalk/Makefile.am b/libatalk/Makefile.am index 5fcf4483..3ce5c240 100644 --- a/libatalk/Makefile.am +++ b/libatalk/Makefile.am @@ -1,7 +1,7 @@ # Makefile.am for libatalk/ -SUBDIRS = acl adouble asp atp compat cnid dsi nbp netddp tdb util unicode vfs +SUBDIRS = acl adouble asp atp bstring compat cnid dsi nbp netddp tdb util unicode vfs lib_LTLIBRARIES = libatalk.la @@ -11,6 +11,7 @@ libatalk_la_LIBADD = \ adouble/libadouble.la \ asp/libasp.la \ atp/libatp.la \ + bstring/libbstring.la \ compat/libcompat.la \ dsi/libdsi.la \ nbp/libnbp.la \ @@ -24,6 +25,7 @@ libatalk_la_DEPENDENCIES = \ adouble/libadouble.la \ asp/libasp.la \ atp/libatp.la \ + bstring/libbstring.la \ compat/libcompat.la \ dsi/libdsi.la \ nbp/libnbp.la \ diff --git a/libatalk/bstring/.cvsignore b/libatalk/bstring/.cvsignore new file mode 100644 index 00000000..0d0371d7 --- /dev/null +++ b/libatalk/bstring/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +*.lo +*.la +.deps +.libs diff --git a/libatalk/bstring/Makefile.am b/libatalk/bstring/Makefile.am new file mode 100644 index 00000000..39f78c3e --- /dev/null +++ b/libatalk/bstring/Makefile.am @@ -0,0 +1,6 @@ +# Makefile.am for libatalk/adouble/ + +noinst_LTLIBRARIES = libbstring.la + +libbstring_la_SOURCES = bstrlib.c bstradd.c + diff --git a/libatalk/bstring/bstradd.c b/libatalk/bstring/bstradd.c new file mode 100644 index 00000000..9f617ebc --- /dev/null +++ b/libatalk/bstring/bstradd.c @@ -0,0 +1,208 @@ +/* + $Id: bstradd.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +/*! + * @file + * Additional functions for bstrlib + */ + +#include +#include +#include +#include +#include +#include + +#include + +/* Optionally include a mechanism for debugging memory */ + +#if defined(MEMORY_DEBUG) || defined(BSTRLIB_MEMORY_DEBUG) +#include "memdbg.h" +#endif + +#ifndef bstr__alloc +#define bstr__alloc(x) malloc (x) +#endif + +#ifndef bstr__free +#define bstr__free(p) free (p) +#endif + +#ifndef bstr__realloc +#define bstr__realloc(p,x) realloc ((p), (x)) +#endif + +#ifndef bstr__memcpy +#define bstr__memcpy(d,s,l) memcpy ((d), (s), (l)) +#endif + +#ifndef bstr__memmove +#define bstr__memmove(d,s,l) memmove ((d), (s), (l)) +#endif + +#ifndef bstr__memset +#define bstr__memset(d,c,l) memset ((d), (c), (l)) +#endif + +#ifndef bstr__memcmp +#define bstr__memcmp(d,c,l) memcmp ((d), (c), (l)) +#endif + +#ifndef bstr__memchr +#define bstr__memchr(s,c,l) memchr ((s), (c), (l)) +#endif + +/************************************************************************* + * Stuff for making bstrings referencing c-strings + ************************************************************************/ + +/*! + * @brief Create a bstring referencing "str" + * + * This is usefull if a well know code path uses string, often doing strlen on string. + * By converting to bstring which carries the strlen, the repeated computation can be avoided. + */ +bstring brefcstr (const char *str) { + bstring b; + int i; + size_t j; + + if (str == NULL) + return NULL; + j = strlen(str); + + b = (bstring)bstr__alloc(sizeof(struct tagbstring)); + if (NULL == b) + return NULL; + + b->slen = (int) j; + b->mlen = -1; + b->data = str; + + return b; +} + +/*! + * @brief Free up the bstring, WITHOUT freeing the pointed to c-string! + */ +int bunrefcstr (bstring b) { + if (b == NULL || b->slen < 0 || b->mlen > 0 || b->data == NULL) + return BSTR_ERR; + + /* In case there is any stale usage, there is one more chance to + notice this error. */ + + b->slen = -1; + b->mlen = -__LINE__; + b->data = NULL; + + bstr__free (b); + return BSTR_OK; +} + +/************************************************************************* + * stuff for bstrList + ************************************************************************/ + +/*! + * @brief Create an empty list with preallocated storage for at least 'min' members + */ +struct bstrList *bstListCreateMin(int min) +{ + struct bstrList *sl = NULL; + + if ((sl = bstrListCreate()) == NULL) + return NULL; + + if ((bstrListAlloc(sl, min)) != BSTR_OK) { + bstrListDestroy(sl); + return NULL; + } + + return sl; +} + +/*! + * @brief Push a bstring to the end of a list + */ +int bstrListPush(struct bstrList *sl, bstring bs) +{ + if (sl->qty == sl->mlen) { + if ((bstrListAlloc(sl, sl->qty + 1)) != BSTR_OK) + return BSTR_ERR; + } + + sl->entry[sl->qty] = bs; + sl->qty++; + return BSTR_OK; +} + +/*! + * @brief Pop a bstring from the end of a list + */ +bstring bstrListPop(struct bstrList *sl) +{ + return NULL; +} + +/*! + * @brief Inverse bjoin + */ +bstring bjoinInv(const struct bstrList * bl, const_bstring sep) { + bstring b; + int i, j, c, v; + + if (bl == NULL || bl->qty < 0) + return NULL; + if (sep != NULL && (sep->slen < 0 || sep->data == NULL)) + return NULL; + + for (i = 0, c = 1; i < bl->qty; i++) { + v = bl->entry[i]->slen; + if (v < 0) + return NULL;/* Invalid input */ + c += v; + if (c < 0) + return NULL;/* Wrap around ?? */ + } + + if (sep != NULL) + c += (bl->qty - 1) * sep->slen; + + b = (bstring) bstr__alloc (sizeof (struct tagbstring)); + if (NULL == b) + return NULL; /* Out of memory */ + b->data = (unsigned char *) bstr__alloc (c); + if (b->data == NULL) { + bstr__free (b); + return NULL; + } + + b->mlen = c; + b->slen = c-1; + + for (i = bl->qty - 1, c = 0, j = 0; i >= 0; i--, j++) { + if (j > 0 && sep != NULL) { + bstr__memcpy (b->data + c, sep->data, sep->slen); + c += sep->slen; + } + v = bl->entry[i]->slen; + bstr__memcpy (b->data + c, bl->entry[i]->data, v); + c += v; + } + b->data[c] = (unsigned char) '\0'; + return b; +} diff --git a/libatalk/bstring/bstrlib.c b/libatalk/bstring/bstrlib.c new file mode 100755 index 00000000..93c481ca --- /dev/null +++ b/libatalk/bstring/bstrlib.c @@ -0,0 +1,2956 @@ +/* + * This source file is part of the bstring string library. This code was + * written by Paul Hsieh in 2002-2008, and is covered by the BSD open source + * license and the GPL. Refer to the accompanying documentation for details + * on usage and license. + */ + +/* + * bstrlib.c + * + * This file is the core module for implementing the bstring functions. + */ + +#include +#include +#include +#include +#include +#include + +#include + +/* Optionally include a mechanism for debugging memory */ + +#if defined(MEMORY_DEBUG) || defined(BSTRLIB_MEMORY_DEBUG) +#include "memdbg.h" +#endif + +#ifndef bstr__alloc +#define bstr__alloc(x) malloc (x) +#endif + +#ifndef bstr__free +#define bstr__free(p) free (p) +#endif + +#ifndef bstr__realloc +#define bstr__realloc(p,x) realloc ((p), (x)) +#endif + +#ifndef bstr__memcpy +#define bstr__memcpy(d,s,l) memcpy ((d), (s), (l)) +#endif + +#ifndef bstr__memmove +#define bstr__memmove(d,s,l) memmove ((d), (s), (l)) +#endif + +#ifndef bstr__memset +#define bstr__memset(d,c,l) memset ((d), (c), (l)) +#endif + +#ifndef bstr__memcmp +#define bstr__memcmp(d,c,l) memcmp ((d), (c), (l)) +#endif + +#ifndef bstr__memchr +#define bstr__memchr(s,c,l) memchr ((s), (c), (l)) +#endif + +/* Just a length safe wrapper for memmove. */ + +#define bBlockCopy(D,S,L) { if ((L) > 0) bstr__memmove ((D),(S),(L)); } + +/* Compute the snapped size for a given requested size. By snapping to powers + of 2 like this, repeated reallocations are avoided. */ +static int snapUpSize (int i) { + if (i < 8) { + i = 8; + } else { + unsigned int j; + j = (unsigned int) i; + + j |= (j >> 1); + j |= (j >> 2); + j |= (j >> 4); + j |= (j >> 8); /* Ok, since int >= 16 bits */ +#if (UINT_MAX != 0xffff) + j |= (j >> 16); /* For 32 bit int systems */ +#if (UINT_MAX > 0xffffffffUL) + j |= (j >> 32); /* For 64 bit int systems */ +#endif +#endif + /* Least power of two greater than i */ + j++; + if ((int) j >= i) i = (int) j; + } + return i; +} + +/* int balloc (bstring b, int len) + * + * Increase the size of the memory backing the bstring b to at least len. + */ +int balloc (bstring b, int olen) { + int len; + if (b == NULL || b->data == NULL || b->slen < 0 || b->mlen <= 0 || + b->mlen < b->slen || olen <= 0) { + return BSTR_ERR; + } + + if (olen >= b->mlen) { + unsigned char * x; + + if ((len = snapUpSize (olen)) <= b->mlen) return BSTR_OK; + + /* Assume probability of a non-moving realloc is 0.125 */ + if (7 * b->mlen < 8 * b->slen) { + + /* If slen is close to mlen in size then use realloc to reduce + the memory defragmentation */ + + reallocStrategy:; + + x = (unsigned char *) bstr__realloc (b->data, (size_t) len); + if (x == NULL) { + + /* Since we failed, try allocating the tighest possible + allocation */ + + if (NULL == (x = (unsigned char *) bstr__realloc (b->data, (size_t) (len = olen)))) { + return BSTR_ERR; + } + } + } else { + + /* If slen is not close to mlen then avoid the penalty of copying + the extra bytes that are allocated, but not considered part of + the string */ + + if (NULL == (x = (unsigned char *) bstr__alloc ((size_t) len))) { + + /* Perhaps there is no available memory for the two + allocations to be in memory at once */ + + goto reallocStrategy; + + } else { + if (b->slen) bstr__memcpy ((char *) x, (char *) b->data, (size_t) b->slen); + bstr__free (b->data); + } + } + b->data = x; + b->mlen = len; + b->data[b->slen] = (unsigned char) '\0'; + } + + return BSTR_OK; +} + +/* int ballocmin (bstring b, int len) + * + * Set the size of the memory backing the bstring b to len or b->slen+1, + * whichever is larger. Note that repeated use of this function can degrade + * performance. + */ +int ballocmin (bstring b, int len) { + unsigned char * s; + + if (b == NULL || b->data == NULL || (b->slen+1) < 0 || b->mlen <= 0 || + b->mlen < b->slen || len <= 0) { + return BSTR_ERR; + } + + if (len < b->slen + 1) len = b->slen + 1; + + if (len != b->mlen) { + s = (unsigned char *) bstr__realloc (b->data, (size_t) len); + if (NULL == s) return BSTR_ERR; + s[b->slen] = (unsigned char) '\0'; + b->data = s; + b->mlen = len; + } + + return BSTR_OK; +} + +/* bstring bfromcstr (const char * str) + * + * Create a bstring which contains the contents of the '\0' terminated char * + * buffer str. + */ +bstring bfromcstr (const char * str) { +bstring b; +int i; +size_t j; + + if (str == NULL) return NULL; + j = (strlen) (str); + i = snapUpSize ((int) (j + (2 - (j != 0)))); + if (i <= (int) j) return NULL; + + b = (bstring) bstr__alloc (sizeof (struct tagbstring)); + if (NULL == b) return NULL; + b->slen = (int) j; + if (NULL == (b->data = (unsigned char *) bstr__alloc (b->mlen = i))) { + bstr__free (b); + return NULL; + } + + bstr__memcpy (b->data, str, j+1); + return b; +} + +/* bstring bfromcstralloc (int mlen, const char * str) + * + * Create a bstring which contains the contents of the '\0' terminated char * + * buffer str. The memory buffer backing the string is at least len + * characters in length. + */ +bstring bfromcstralloc (int mlen, const char * str) { +bstring b; +int i; +size_t j; + + if (str == NULL) return NULL; + j = (strlen) (str); + i = snapUpSize ((int) (j + (2 - (j != 0)))); + if (i <= (int) j) return NULL; + + b = (bstring) bstr__alloc (sizeof (struct tagbstring)); + if (b == NULL) return NULL; + b->slen = (int) j; + if (i < mlen) i = mlen; + + if (NULL == (b->data = (unsigned char *) bstr__alloc (b->mlen = i))) { + bstr__free (b); + return NULL; + } + + bstr__memcpy (b->data, str, j+1); + return b; +} + +/* bstring blk2bstr (const void * blk, int len) + * + * Create a bstring which contains the content of the block blk of length + * len. + */ +bstring blk2bstr (const void * blk, int len) { +bstring b; +int i; + + if (blk == NULL || len < 0) return NULL; + b = (bstring) bstr__alloc (sizeof (struct tagbstring)); + if (b == NULL) return NULL; + b->slen = len; + + i = len + (2 - (len != 0)); + i = snapUpSize (i); + + b->mlen = i; + + b->data = (unsigned char *) bstr__alloc ((size_t) b->mlen); + if (b->data == NULL) { + bstr__free (b); + return NULL; + } + + if (len > 0) bstr__memcpy (b->data, blk, (size_t) len); + b->data[len] = (unsigned char) '\0'; + + return b; +} + +/* char * bstr2cstr (const_bstring s, char z) + * + * Create a '\0' terminated char * buffer which is equal to the contents of + * the bstring s, except that any contained '\0' characters are converted + * to the character in z. This returned value should be freed with a + * bcstrfree () call, by the calling application. + */ +char * bstr2cstr (const_bstring b, char z) { +int i, l; +char * r; + + if (b == NULL || b->slen < 0 || b->data == NULL) return NULL; + l = b->slen; + r = (char *) bstr__alloc ((size_t) (l + 1)); + if (r == NULL) return r; + + for (i=0; i < l; i ++) { + r[i] = (char) ((b->data[i] == '\0') ? z : (char) (b->data[i])); + } + + r[l] = (unsigned char) '\0'; + + return r; +} + +/* int bcstrfree (char * s) + * + * Frees a C-string generated by bstr2cstr (). This is normally unnecessary + * since it just wraps a call to bstr__free (), however, if bstr__alloc () + * and bstr__free () have been redefined as a macros within the bstrlib + * module (via defining them in memdbg.h after defining + * BSTRLIB_MEMORY_DEBUG) with some difference in behaviour from the std + * library functions, then this allows a correct way of freeing the memory + * that allows higher level code to be independent from these macro + * redefinitions. + */ +int bcstrfree (char * s) { + if (s) { + bstr__free (s); + return BSTR_OK; + } + return BSTR_ERR; +} + +/* int bconcat (bstring b0, const_bstring b1) + * + * Concatenate the bstring b1 to the bstring b0. + */ +int bconcat (bstring b0, const_bstring b1) { +int len, d; +bstring aux = (bstring) b1; + + if (b0 == NULL || b1 == NULL || b0->data == NULL || b1->data == NULL) return BSTR_ERR; + + d = b0->slen; + len = b1->slen; + if ((d | (b0->mlen - d) | len | (d + len)) < 0) return BSTR_ERR; + + if (b0->mlen <= d + len + 1) { + ptrdiff_t pd = b1->data - b0->data; + if (0 <= pd && pd < b0->mlen) { + if (NULL == (aux = bstrcpy (b1))) return BSTR_ERR; + } + if (balloc (b0, d + len + 1) != BSTR_OK) { + if (aux != b1) bdestroy (aux); + return BSTR_ERR; + } + } + + bBlockCopy (&b0->data[d], &aux->data[0], (size_t) len); + b0->data[d + len] = (unsigned char) '\0'; + b0->slen = d + len; + if (aux != b1) bdestroy (aux); + return BSTR_OK; +} + +/* int bconchar (bstring b, char c) +/ * + * Concatenate the single character c to the bstring b. + */ +int bconchar (bstring b, char c) { +int d; + + if (b == NULL) return BSTR_ERR; + d = b->slen; + if ((d | (b->mlen - d)) < 0 || balloc (b, d + 2) != BSTR_OK) return BSTR_ERR; + b->data[d] = (unsigned char) c; + b->data[d + 1] = (unsigned char) '\0'; + b->slen++; + return BSTR_OK; +} + +/* int bcatcstr (bstring b, const char * s) + * + * Concatenate a char * string to a bstring. + */ +int bcatcstr (bstring b, const char * s) { +char * d; +int i, l; + + if (b == NULL || b->data == NULL || b->slen < 0 || b->mlen < b->slen + || b->mlen <= 0 || s == NULL) return BSTR_ERR; + + /* Optimistically concatenate directly */ + l = b->mlen - b->slen; + d = (char *) &b->data[b->slen]; + for (i=0; i < l; i++) { + if ((*d++ = *s++) == '\0') { + b->slen += i; + return BSTR_OK; + } + } + b->slen += i; + + /* Need to explicitely resize and concatenate tail */ + return bcatblk (b, (const void *) s, (int) strlen (s)); +} + +/* int bcatblk (bstring b, const void * s, int len) + * + * Concatenate a fixed length buffer to a bstring. + */ +int bcatblk (bstring b, const void * s, int len) { +int nl; + + if (b == NULL || b->data == NULL || b->slen < 0 || b->mlen < b->slen + || b->mlen <= 0 || s == NULL || len < 0) return BSTR_ERR; + + if (0 > (nl = b->slen + len)) return BSTR_ERR; /* Overflow? */ + if (b->mlen <= nl && 0 > balloc (b, nl + 1)) return BSTR_ERR; + + bBlockCopy (&b->data[b->slen], s, (size_t) len); + b->slen = nl; + b->data[nl] = (unsigned char) '\0'; + return BSTR_OK; +} + +/* bstring bstrcpy (const_bstring b) + * + * Create a copy of the bstring b. + */ +bstring bstrcpy (const_bstring b) { +bstring b0; +int i,j; + + /* Attempted to copy an invalid string? */ + if (b == NULL || b->slen < 0 || b->data == NULL) return NULL; + + b0 = (bstring) bstr__alloc (sizeof (struct tagbstring)); + if (b0 == NULL) { + /* Unable to allocate memory for string header */ + return NULL; + } + + i = b->slen; + j = snapUpSize (i + 1); + + b0->data = (unsigned char *) bstr__alloc (j); + if (b0->data == NULL) { + j = i + 1; + b0->data = (unsigned char *) bstr__alloc (j); + if (b0->data == NULL) { + /* Unable to allocate memory for string data */ + bstr__free (b0); + return NULL; + } + } + + b0->mlen = j; + b0->slen = i; + + if (i) bstr__memcpy ((char *) b0->data, (char *) b->data, i); + b0->data[b0->slen] = (unsigned char) '\0'; + + return b0; +} + +/* int bassign (bstring a, const_bstring b) + * + * Overwrite the string a with the contents of string b. + */ +int bassign (bstring a, const_bstring b) { + if (b == NULL || b->data == NULL || b->slen < 0) + return BSTR_ERR; + if (b->slen != 0) { + if (balloc (a, b->slen) != BSTR_OK) return BSTR_ERR; + bstr__memmove (a->data, b->data, b->slen); + } else { + if (a == NULL || a->data == NULL || a->mlen < a->slen || + a->slen < 0 || a->mlen == 0) + return BSTR_ERR; + } + a->data[b->slen] = (unsigned char) '\0'; + a->slen = b->slen; + return BSTR_OK; +} + +/* int bassignmidstr (bstring a, const_bstring b, int left, int len) + * + * Overwrite the string a with the middle of contents of string b + * starting from position left and running for a length len. left and + * len are clamped to the ends of b as with the function bmidstr. + */ +int bassignmidstr (bstring a, const_bstring b, int left, int len) { + if (b == NULL || b->data == NULL || b->slen < 0) + return BSTR_ERR; + + if (left < 0) { + len += left; + left = 0; + } + + if (len > b->slen - left) len = b->slen - left; + + if (a == NULL || a->data == NULL || a->mlen < a->slen || + a->slen < 0 || a->mlen == 0) + return BSTR_ERR; + + if (len > 0) { + if (balloc (a, len) != BSTR_OK) return BSTR_ERR; + bstr__memmove (a->data, b->data + left, len); + a->slen = len; + } else { + a->slen = 0; + } + a->data[a->slen] = (unsigned char) '\0'; + return BSTR_OK; +} + +/* int bassigncstr (bstring a, const char * str) + * + * Overwrite the string a with the contents of char * string str. Note that + * the bstring a must be a well defined and writable bstring. If an error + * occurs BSTR_ERR is returned however a may be partially overwritten. + */ +int bassigncstr (bstring a, const char * str) { +int i; +size_t len; + if (a == NULL || a->data == NULL || a->mlen < a->slen || + a->slen < 0 || a->mlen == 0 || NULL == str) + return BSTR_ERR; + + for (i=0; i < a->mlen; i++) { + if ('\0' == (a->data[i] = str[i])) { + a->slen = i; + return BSTR_OK; + } + } + + a->slen = i; + len = strlen (str + i); + if (len > INT_MAX || i + len + 1 > INT_MAX || + 0 > balloc (a, (int) (i + len + 1))) return BSTR_ERR; + bBlockCopy (a->data + i, str + i, (size_t) len + 1); + a->slen += (int) len; + return BSTR_OK; +} + +/* int bassignblk (bstring a, const void * s, int len) + * + * Overwrite the string a with the contents of the block (s, len). Note that + * the bstring a must be a well defined and writable bstring. If an error + * occurs BSTR_ERR is returned and a is not overwritten. + */ +int bassignblk (bstring a, const void * s, int len) { + if (a == NULL || a->data == NULL || a->mlen < a->slen || + a->slen < 0 || a->mlen == 0 || NULL == s || len + 1 < 1) + return BSTR_ERR; + if (len + 1 > a->mlen && 0 > balloc (a, len + 1)) return BSTR_ERR; + bBlockCopy (a->data, s, (size_t) len); + a->data[len] = (unsigned char) '\0'; + a->slen = len; + return BSTR_OK; +} + +/* int btrunc (bstring b, int n) + * + * Truncate the bstring to at most n characters. + */ +int btrunc (bstring b, int n) { + if (n < 0 || b == NULL || b->data == NULL || b->mlen < b->slen || + b->slen < 0 || b->mlen <= 0) return BSTR_ERR; + if (b->slen > n) { + b->slen = n; + b->data[n] = (unsigned char) '\0'; + } + return BSTR_OK; +} + +#define upcase(c) (toupper ((unsigned char) c)) +#define downcase(c) (tolower ((unsigned char) c)) +#define wspace(c) (isspace ((unsigned char) c)) + +/* int btoupper (bstring b) + * + * Convert contents of bstring to upper case. + */ +int btoupper (bstring b) { +int i, len; + if (b == NULL || b->data == NULL || b->mlen < b->slen || + b->slen < 0 || b->mlen <= 0) return BSTR_ERR; + for (i=0, len = b->slen; i < len; i++) { + b->data[i] = (unsigned char) upcase (b->data[i]); + } + return BSTR_OK; +} + +/* int btolower (bstring b) + * + * Convert contents of bstring to lower case. + */ +int btolower (bstring b) { +int i, len; + if (b == NULL || b->data == NULL || b->mlen < b->slen || + b->slen < 0 || b->mlen <= 0) return BSTR_ERR; + for (i=0, len = b->slen; i < len; i++) { + b->data[i] = (unsigned char) downcase (b->data[i]); + } + return BSTR_OK; +} + +/* int bstricmp (const_bstring b0, const_bstring b1) + * + * Compare two strings without differentiating between case. The return + * value is the difference of the values of the characters where the two + * strings first differ after lower case transformation, otherwise 0 is + * returned indicating that the strings are equal. If the lengths are + * different, then a difference from 0 is given, but if the first extra + * character is '\0', then it is taken to be the value UCHAR_MAX+1. + */ +int bstricmp (const_bstring b0, const_bstring b1) { +int i, v, n; + + if (bdata (b0) == NULL || b0->slen < 0 || + bdata (b1) == NULL || b1->slen < 0) return SHRT_MIN; + if ((n = b0->slen) > b1->slen) n = b1->slen; + else if (b0->slen == b1->slen && b0->data == b1->data) return BSTR_OK; + + for (i = 0; i < n; i ++) { + v = (char) downcase (b0->data[i]) + - (char) downcase (b1->data[i]); + if (0 != v) return v; + } + + if (b0->slen > n) { + v = (char) downcase (b0->data[n]); + if (v) return v; + return UCHAR_MAX + 1; + } + if (b1->slen > n) { + v = - (char) downcase (b1->data[n]); + if (v) return v; + return - (int) (UCHAR_MAX + 1); + } + return BSTR_OK; +} + +/* int bstrnicmp (const_bstring b0, const_bstring b1, int n) + * + * Compare two strings without differentiating between case for at most n + * characters. If the position where the two strings first differ is + * before the nth position, the return value is the difference of the values + * of the characters, otherwise 0 is returned. If the lengths are different + * and less than n characters, then a difference from 0 is given, but if the + * first extra character is '\0', then it is taken to be the value + * UCHAR_MAX+1. + */ +int bstrnicmp (const_bstring b0, const_bstring b1, int n) { +int i, v, m; + + if (bdata (b0) == NULL || b0->slen < 0 || + bdata (b1) == NULL || b1->slen < 0 || n < 0) return SHRT_MIN; + m = n; + if (m > b0->slen) m = b0->slen; + if (m > b1->slen) m = b1->slen; + + if (b0->data != b1->data) { + for (i = 0; i < m; i ++) { + v = (char) downcase (b0->data[i]); + v -= (char) downcase (b1->data[i]); + if (v != 0) return b0->data[i] - b1->data[i]; + } + } + + if (n == m || b0->slen == b1->slen) return BSTR_OK; + + if (b0->slen > m) { + v = (char) downcase (b0->data[m]); + if (v) return v; + return UCHAR_MAX + 1; + } + + v = - (char) downcase (b1->data[m]); + if (v) return v; + return - (int) (UCHAR_MAX + 1); +} + +/* int biseqcaseless (const_bstring b0, const_bstring b1) + * + * Compare two strings for equality without differentiating between case. + * If the strings differ other than in case, 0 is returned, if the strings + * are the same, 1 is returned, if there is an error, -1 is returned. If + * the length of the strings are different, this function is O(1). '\0' + * termination characters are not treated in any special way. + */ +int biseqcaseless (const_bstring b0, const_bstring b1) { +int i, n; + + if (bdata (b0) == NULL || b0->slen < 0 || + bdata (b1) == NULL || b1->slen < 0) return BSTR_ERR; + if (b0->slen != b1->slen) return BSTR_OK; + if (b0->data == b1->data || b0->slen == 0) return 1; + for (i=0, n=b0->slen; i < n; i++) { + if (b0->data[i] != b1->data[i]) { + unsigned char c = (unsigned char) downcase (b0->data[i]); + if (c != (unsigned char) downcase (b1->data[i])) return 0; + } + } + return 1; +} + +/* int bisstemeqcaselessblk (const_bstring b0, const void * blk, int len) + * + * Compare beginning of string b0 with a block of memory of length len + * without differentiating between case for equality. If the beginning of b0 + * differs from the memory block other than in case (or if b0 is too short), + * 0 is returned, if the strings are the same, 1 is returned, if there is an + * error, -1 is returned. '\0' characters are not treated in any special + * way. + */ +int bisstemeqcaselessblk (const_bstring b0, const void * blk, int len) { +int i; + + if (bdata (b0) == NULL || b0->slen < 0 || NULL == blk || len < 0) + return BSTR_ERR; + if (b0->slen < len) return BSTR_OK; + if (b0->data == (const unsigned char *) blk || len == 0) return 1; + + for (i = 0; i < len; i ++) { + if (b0->data[i] != ((const unsigned char *) blk)[i]) { + if (downcase (b0->data[i]) != + downcase (((const unsigned char *) blk)[i])) return 0; + } + } + return 1; +} + +/* + * int bltrimws (bstring b) + * + * Delete whitespace contiguous from the left end of the string. + */ +int bltrimws (bstring b) { +int i, len; + + if (b == NULL || b->data == NULL || b->mlen < b->slen || + b->slen < 0 || b->mlen <= 0) return BSTR_ERR; + + for (len = b->slen, i = 0; i < len; i++) { + if (!wspace (b->data[i])) { + return bdelete (b, 0, i); + } + } + + b->data[0] = (unsigned char) '\0'; + b->slen = 0; + return BSTR_OK; +} + +/* + * int brtrimws (bstring b) + * + * Delete whitespace contiguous from the right end of the string. + */ +int brtrimws (bstring b) { +int i; + + if (b == NULL || b->data == NULL || b->mlen < b->slen || + b->slen < 0 || b->mlen <= 0) return BSTR_ERR; + + for (i = b->slen - 1; i >= 0; i--) { + if (!wspace (b->data[i])) { + if (b->mlen > i) b->data[i+1] = (unsigned char) '\0'; + b->slen = i + 1; + return BSTR_OK; + } + } + + b->data[0] = (unsigned char) '\0'; + b->slen = 0; + return BSTR_OK; +} + +/* + * int btrimws (bstring b) + * + * Delete whitespace contiguous from both ends of the string. + */ +int btrimws (bstring b) { +int i, j; + + if (b == NULL || b->data == NULL || b->mlen < b->slen || + b->slen < 0 || b->mlen <= 0) return BSTR_ERR; + + for (i = b->slen - 1; i >= 0; i--) { + if (!wspace (b->data[i])) { + if (b->mlen > i) b->data[i+1] = (unsigned char) '\0'; + b->slen = i + 1; + for (j = 0; wspace (b->data[j]); j++) {} + return bdelete (b, 0, j); + } + } + + b->data[0] = (unsigned char) '\0'; + b->slen = 0; + return BSTR_OK; +} + +/* int biseq (const_bstring b0, const_bstring b1) + * + * Compare the string b0 and b1. If the strings differ, 0 is returned, if + * the strings are the same, 1 is returned, if there is an error, -1 is + * returned. If the length of the strings are different, this function is + * O(1). '\0' termination characters are not treated in any special way. + */ +int biseq (const_bstring b0, const_bstring b1) { + if (b0 == NULL || b1 == NULL || b0->data == NULL || b1->data == NULL || + b0->slen < 0 || b1->slen < 0) return BSTR_ERR; + if (b0->slen != b1->slen) return BSTR_OK; + if (b0->data == b1->data || b0->slen == 0) return 1; + return !bstr__memcmp (b0->data, b1->data, b0->slen); +} + +/* int bisstemeqblk (const_bstring b0, const void * blk, int len) + * + * Compare beginning of string b0 with a block of memory of length len for + * equality. If the beginning of b0 differs from the memory block (or if b0 + * is too short), 0 is returned, if the strings are the same, 1 is returned, + * if there is an error, -1 is returned. '\0' characters are not treated in + * any special way. + */ +int bisstemeqblk (const_bstring b0, const void * blk, int len) { +int i; + + if (bdata (b0) == NULL || b0->slen < 0 || NULL == blk || len < 0) + return BSTR_ERR; + if (b0->slen < len) return BSTR_OK; + if (b0->data == (const unsigned char *) blk || len == 0) return 1; + + for (i = 0; i < len; i ++) { + if (b0->data[i] != ((const unsigned char *) blk)[i]) return BSTR_OK; + } + return 1; +} + +/* int biseqcstr (const_bstring b, const char *s) + * + * Compare the bstring b and char * string s. The C string s must be '\0' + * terminated at exactly the length of the bstring b, and the contents + * between the two must be identical with the bstring b with no '\0' + * characters for the two contents to be considered equal. This is + * equivalent to the condition that their current contents will be always be + * equal when comparing them in the same format after converting one or the + * other. If the strings are equal 1 is returned, if they are unequal 0 is + * returned and if there is a detectable error BSTR_ERR is returned. + */ +int biseqcstr (const_bstring b, const char * s) { +int i; + if (b == NULL || s == NULL || b->data == NULL || b->slen < 0) return BSTR_ERR; + for (i=0; i < b->slen; i++) { + if (s[i] == '\0' || b->data[i] != (unsigned char) s[i]) return BSTR_OK; + } + return s[i] == '\0'; +} + +/* int biseqcstrcaseless (const_bstring b, const char *s) + * + * Compare the bstring b and char * string s. The C string s must be '\0' + * terminated at exactly the length of the bstring b, and the contents + * between the two must be identical except for case with the bstring b with + * no '\0' characters for the two contents to be considered equal. This is + * equivalent to the condition that their current contents will be always be + * equal ignoring case when comparing them in the same format after + * converting one or the other. If the strings are equal, except for case, + * 1 is returned, if they are unequal regardless of case 0 is returned and + * if there is a detectable error BSTR_ERR is returned. + */ +int biseqcstrcaseless (const_bstring b, const char * s) { +int i; + if (b == NULL || s == NULL || b->data == NULL || b->slen < 0) return BSTR_ERR; + for (i=0; i < b->slen; i++) { + if (s[i] == '\0' || + (b->data[i] != (unsigned char) s[i] && + downcase (b->data[i]) != (unsigned char) downcase (s[i]))) + return BSTR_OK; + } + return s[i] == '\0'; +} + +/* int bstrcmp (const_bstring b0, const_bstring b1) + * + * Compare the string b0 and b1. If there is an error, SHRT_MIN is returned, + * otherwise a value less than or greater than zero, indicating that the + * string pointed to by b0 is lexicographically less than or greater than + * the string pointed to by b1 is returned. If the the string lengths are + * unequal but the characters up until the length of the shorter are equal + * then a value less than, or greater than zero, indicating that the string + * pointed to by b0 is shorter or longer than the string pointed to by b1 is + * returned. 0 is returned if and only if the two strings are the same. If + * the length of the strings are different, this function is O(n). Like its + * standard C library counter part strcmp, the comparison does not proceed + * past any '\0' termination characters encountered. + */ +int bstrcmp (const_bstring b0, const_bstring b1) { +int i, v, n; + + if (b0 == NULL || b1 == NULL || b0->data == NULL || b1->data == NULL || + b0->slen < 0 || b1->slen < 0) return SHRT_MIN; + n = b0->slen; if (n > b1->slen) n = b1->slen; + if (b0->slen == b1->slen && (b0->data == b1->data || b0->slen == 0)) + return BSTR_OK; + + for (i = 0; i < n; i ++) { + v = ((char) b0->data[i]) - ((char) b1->data[i]); + if (v != 0) return v; + if (b0->data[i] == (unsigned char) '\0') return BSTR_OK; + } + + if (b0->slen > n) return 1; + if (b1->slen > n) return -1; + return BSTR_OK; +} + +/* int bstrncmp (const_bstring b0, const_bstring b1, int n) + * + * Compare the string b0 and b1 for at most n characters. If there is an + * error, SHRT_MIN is returned, otherwise a value is returned as if b0 and + * b1 were first truncated to at most n characters then bstrcmp was called + * with these new strings are paremeters. If the length of the strings are + * different, this function is O(n). Like its standard C library counter + * part strcmp, the comparison does not proceed past any '\0' termination + * characters encountered. + */ +int bstrncmp (const_bstring b0, const_bstring b1, int n) { +int i, v, m; + + if (b0 == NULL || b1 == NULL || b0->data == NULL || b1->data == NULL || + b0->slen < 0 || b1->slen < 0) return SHRT_MIN; + m = n; + if (m > b0->slen) m = b0->slen; + if (m > b1->slen) m = b1->slen; + + if (b0->data != b1->data) { + for (i = 0; i < m; i ++) { + v = ((char) b0->data[i]) - ((char) b1->data[i]); + if (v != 0) return v; + if (b0->data[i] == (unsigned char) '\0') return BSTR_OK; + } + } + + if (n == m || b0->slen == b1->slen) return BSTR_OK; + + if (b0->slen > m) return 1; + return -1; +} + +/* bstring bmidstr (const_bstring b, int left, int len) + * + * Create a bstring which is the substring of b starting from position left + * and running for a length len (clamped by the end of the bstring b.) If + * b is detectably invalid, then NULL is returned. The section described + * by (left, len) is clamped to the boundaries of b. + */ +bstring bmidstr (const_bstring b, int left, int len) { + + if (b == NULL || b->slen < 0 || b->data == NULL) return NULL; + + if (left < 0) { + len += left; + left = 0; + } + + if (len > b->slen - left) len = b->slen - left; + + if (len <= 0) return bfromcstr (""); + return blk2bstr (b->data + left, len); +} + +/* int bdelete (bstring b, int pos, int len) + * + * Removes characters from pos to pos+len-1 inclusive and shifts the tail of + * the bstring starting from pos+len to pos. len must be positive for this + * call to have any effect. The section of the string described by (pos, + * len) is clamped to boundaries of the bstring b. + */ +int bdelete (bstring b, int pos, int len) { + /* Clamp to left side of bstring */ + if (pos < 0) { + len += pos; + pos = 0; + } + + if (len < 0 || b == NULL || b->data == NULL || b->slen < 0 || + b->mlen < b->slen || b->mlen <= 0) + return BSTR_ERR; + if (len > 0 && pos < b->slen) { + if (pos + len >= b->slen) { + b->slen = pos; + } else { + bBlockCopy ((char *) (b->data + pos), + (char *) (b->data + pos + len), + b->slen - (pos+len)); + b->slen -= len; + } + b->data[b->slen] = (unsigned char) '\0'; + } + return BSTR_OK; +} + +/* int bdestroy (bstring b) + * + * Free up the bstring. Note that if b is detectably invalid or not writable + * then no action is performed and BSTR_ERR is returned. Like a freed memory + * allocation, dereferences, writes or any other action on b after it has + * been bdestroyed is undefined. + */ +int bdestroy (bstring b) { + if (b == NULL || b->slen < 0 || b->mlen <= 0 || b->mlen < b->slen || + b->data == NULL) + return BSTR_ERR; + + bstr__free (b->data); + + /* In case there is any stale usage, there is one more chance to + notice this error. */ + + b->slen = -1; + b->mlen = -__LINE__; + b->data = NULL; + + bstr__free (b); + return BSTR_OK; +} + +/* int binstr (const_bstring b1, int pos, const_bstring b2) + * + * Search for the bstring b2 in b1 starting from position pos, and searching + * forward. If it is found then return with the first position where it is + * found, otherwise return BSTR_ERR. Note that this is just a brute force + * string searcher that does not attempt clever things like the Boyer-Moore + * search algorithm. Because of this there are many degenerate cases where + * this can take much longer than it needs to. + */ +int binstr (const_bstring b1, int pos, const_bstring b2) { +int j, ii, ll, lf; +unsigned char * d0; +unsigned char c0; +register unsigned char * d1; +register unsigned char c1; +register int i; + + if (b1 == NULL || b1->data == NULL || b1->slen < 0 || + b2 == NULL || b2->data == NULL || b2->slen < 0) return BSTR_ERR; + if (b1->slen == pos) return (b2->slen == 0)?pos:BSTR_ERR; + if (b1->slen < pos || pos < 0) return BSTR_ERR; + if (b2->slen == 0) return pos; + + /* No space to find such a string? */ + if ((lf = b1->slen - b2->slen + 1) <= pos) return BSTR_ERR; + + /* An obvious alias case */ + if (b1->data == b2->data && pos == 0) return 0; + + i = pos; + + d0 = b2->data; + d1 = b1->data; + ll = b2->slen; + + /* Peel off the b2->slen == 1 case */ + c0 = d0[0]; + if (1 == ll) { + for (;i < lf; i++) if (c0 == d1[i]) return i; + return BSTR_ERR; + } + + c1 = c0; + j = 0; + lf = b1->slen - 1; + + ii = -1; + if (i < lf) do { + /* Unrolled current character test */ + if (c1 != d1[i]) { + if (c1 != d1[1+i]) { + i += 2; + continue; + } + i++; + } + + /* Take note if this is the start of a potential match */ + if (0 == j) ii = i; + + /* Shift the test character down by one */ + j++; + i++; + + /* If this isn't past the last character continue */ + if (j < ll) { + c1 = d0[j]; + continue; + } + + N0:; + + /* If no characters mismatched, then we matched */ + if (i == ii+j) return ii; + + /* Shift back to the beginning */ + i -= j; + j = 0; + c1 = c0; + } while (i < lf); + + /* Deal with last case if unrolling caused a misalignment */ + if (i == lf && ll == j+1 && c1 == d1[i]) goto N0; + + return BSTR_ERR; +} + +/* int binstrr (const_bstring b1, int pos, const_bstring b2) + * + * Search for the bstring b2 in b1 starting from position pos, and searching + * backward. If it is found then return with the first position where it is + * found, otherwise return BSTR_ERR. Note that this is just a brute force + * string searcher that does not attempt clever things like the Boyer-Moore + * search algorithm. Because of this there are many degenerate cases where + * this can take much longer than it needs to. + */ +int binstrr (const_bstring b1, int pos, const_bstring b2) { +int j, i, l; +unsigned char * d0, * d1; + + if (b1 == NULL || b1->data == NULL || b1->slen < 0 || + b2 == NULL || b2->data == NULL || b2->slen < 0) return BSTR_ERR; + if (b1->slen == pos && b2->slen == 0) return pos; + if (b1->slen < pos || pos < 0) return BSTR_ERR; + if (b2->slen == 0) return pos; + + /* Obvious alias case */ + if (b1->data == b2->data && pos == 0 && b2->slen <= b1->slen) return 0; + + i = pos; + if ((l = b1->slen - b2->slen) < 0) return BSTR_ERR; + + /* If no space to find such a string then snap back */ + if (l + 1 <= i) i = l; + j = 0; + + d0 = b2->data; + d1 = b1->data; + l = b2->slen; + + for (;;) { + if (d0[j] == d1[i + j]) { + j ++; + if (j >= l) return i; + } else { + i --; + if (i < 0) break; + j=0; + } + } + + return BSTR_ERR; +} + +/* int binstrcaseless (const_bstring b1, int pos, const_bstring b2) + * + * Search for the bstring b2 in b1 starting from position pos, and searching + * forward but without regard to case. If it is found then return with the + * first position where it is found, otherwise return BSTR_ERR. Note that + * this is just a brute force string searcher that does not attempt clever + * things like the Boyer-Moore search algorithm. Because of this there are + * many degenerate cases where this can take much longer than it needs to. + */ +int binstrcaseless (const_bstring b1, int pos, const_bstring b2) { +int j, i, l, ll; +unsigned char * d0, * d1; + + if (b1 == NULL || b1->data == NULL || b1->slen < 0 || + b2 == NULL || b2->data == NULL || b2->slen < 0) return BSTR_ERR; + if (b1->slen == pos) return (b2->slen == 0)?pos:BSTR_ERR; + if (b1->slen < pos || pos < 0) return BSTR_ERR; + if (b2->slen == 0) return pos; + + l = b1->slen - b2->slen + 1; + + /* No space to find such a string? */ + if (l <= pos) return BSTR_ERR; + + /* An obvious alias case */ + if (b1->data == b2->data && pos == 0) return BSTR_OK; + + i = pos; + j = 0; + + d0 = b2->data; + d1 = b1->data; + ll = b2->slen; + + for (;;) { + if (d0[j] == d1[i + j] || downcase (d0[j]) == downcase (d1[i + j])) { + j ++; + if (j >= ll) return i; + } else { + i ++; + if (i >= l) break; + j=0; + } + } + + return BSTR_ERR; +} + +/* int binstrrcaseless (const_bstring b1, int pos, const_bstring b2) + * + * Search for the bstring b2 in b1 starting from position pos, and searching + * backward but without regard to case. If it is found then return with the + * first position where it is found, otherwise return BSTR_ERR. Note that + * this is just a brute force string searcher that does not attempt clever + * things like the Boyer-Moore search algorithm. Because of this there are + * many degenerate cases where this can take much longer than it needs to. + */ +int binstrrcaseless (const_bstring b1, int pos, const_bstring b2) { +int j, i, l; +unsigned char * d0, * d1; + + if (b1 == NULL || b1->data == NULL || b1->slen < 0 || + b2 == NULL || b2->data == NULL || b2->slen < 0) return BSTR_ERR; + if (b1->slen == pos && b2->slen == 0) return pos; + if (b1->slen < pos || pos < 0) return BSTR_ERR; + if (b2->slen == 0) return pos; + + /* Obvious alias case */ + if (b1->data == b2->data && pos == 0 && b2->slen <= b1->slen) return BSTR_OK; + + i = pos; + if ((l = b1->slen - b2->slen) < 0) return BSTR_ERR; + + /* If no space to find such a string then snap back */ + if (l + 1 <= i) i = l; + j = 0; + + d0 = b2->data; + d1 = b1->data; + l = b2->slen; + + for (;;) { + if (d0[j] == d1[i + j] || downcase (d0[j]) == downcase (d1[i + j])) { + j ++; + if (j >= l) return i; + } else { + i --; + if (i < 0) break; + j=0; + } + } + + return BSTR_ERR; +} + + +/* int bstrchrp (const_bstring b, int c, int pos) + * + * Search for the character c in b forwards from the position pos + * (inclusive). + */ +int bstrchrp (const_bstring b, int c, int pos) { +unsigned char * p; + + if (b == NULL || b->data == NULL || b->slen <= pos || pos < 0) return BSTR_ERR; + p = (unsigned char *) bstr__memchr ((b->data + pos), (unsigned char) c, (b->slen - pos)); + if (p) return (int) (p - b->data); + return BSTR_ERR; +} + +/* int bstrrchrp (const_bstring b, int c, int pos) + * + * Search for the character c in b backwards from the position pos in string + * (inclusive). + */ +int bstrrchrp (const_bstring b, int c, int pos) { +int i; + + if (b == NULL || b->data == NULL || b->slen <= pos || pos < 0) return BSTR_ERR; + for (i=pos; i >= 0; i--) { + if (b->data[i] == (unsigned char) c) return i; + } + return BSTR_ERR; +} + +#if !defined (BSTRLIB_AGGRESSIVE_MEMORY_FOR_SPEED_TRADEOFF) +#define LONG_LOG_BITS_QTY (3) +#define LONG_BITS_QTY (1 << LONG_LOG_BITS_QTY) +#define LONG_TYPE unsigned char + +#define CFCLEN ((1 << CHAR_BIT) / LONG_BITS_QTY) +struct charField { LONG_TYPE content[CFCLEN]; }; +#define testInCharField(cf,c) ((cf)->content[(c) >> LONG_LOG_BITS_QTY] & (((long)1) << ((c) & (LONG_BITS_QTY-1)))) +#define setInCharField(cf,idx) { \ + unsigned int c = (unsigned int) (idx); \ + (cf)->content[c >> LONG_LOG_BITS_QTY] |= (LONG_TYPE) (1ul << (c & (LONG_BITS_QTY-1))); \ +} + +#else + +#define CFCLEN (1 << CHAR_BIT) +struct charField { unsigned char content[CFCLEN]; }; +#define testInCharField(cf,c) ((cf)->content[(unsigned char) (c)]) +#define setInCharField(cf,idx) (cf)->content[(unsigned int) (idx)] = ~0 + +#endif + +/* Convert a bstring to charField */ +static int buildCharField (struct charField * cf, const_bstring b) { +int i; + if (b == NULL || b->data == NULL || b->slen <= 0) return BSTR_ERR; + memset ((void *) cf->content, 0, sizeof (struct charField)); + for (i=0; i < b->slen; i++) { + setInCharField (cf, b->data[i]); + } + return BSTR_OK; +} + +static void invertCharField (struct charField * cf) { +int i; + for (i=0; i < CFCLEN; i++) cf->content[i] = ~cf->content[i]; +} + +/* Inner engine for binchr */ +static int binchrCF (const unsigned char * data, int len, int pos, const struct charField * cf) { +int i; + for (i=pos; i < len; i++) { + unsigned char c = (unsigned char) data[i]; + if (testInCharField (cf, c)) return i; + } + return BSTR_ERR; +} + +/* int binchr (const_bstring b0, int pos, const_bstring b1); + * + * Search for the first position in b0 starting from pos or after, in which + * one of the characters in b1 is found and return it. If such a position + * does not exist in b0, then BSTR_ERR is returned. + */ +int binchr (const_bstring b0, int pos, const_bstring b1) { +struct charField chrs; + if (pos < 0 || b0 == NULL || b0->data == NULL || + b0->slen <= pos) return BSTR_ERR; + if (1 == b1->slen) return bstrchrp (b0, b1->data[0], pos); + if (0 > buildCharField (&chrs, b1)) return BSTR_ERR; + return binchrCF (b0->data, b0->slen, pos, &chrs); +} + +/* Inner engine for binchrr */ +static int binchrrCF (const unsigned char * data, int pos, const struct charField * cf) { +int i; + for (i=pos; i >= 0; i--) { + unsigned int c = (unsigned int) data[i]; + if (testInCharField (cf, c)) return i; + } + return BSTR_ERR; +} + +/* int binchrr (const_bstring b0, int pos, const_bstring b1); + * + * Search for the last position in b0 no greater than pos, in which one of + * the characters in b1 is found and return it. If such a position does not + * exist in b0, then BSTR_ERR is returned. + */ +int binchrr (const_bstring b0, int pos, const_bstring b1) { +struct charField chrs; + if (pos < 0 || b0 == NULL || b0->data == NULL || b1 == NULL || + b0->slen < pos) return BSTR_ERR; + if (pos == b0->slen) pos--; + if (1 == b1->slen) return bstrrchrp (b0, b1->data[0], pos); + if (0 > buildCharField (&chrs, b1)) return BSTR_ERR; + return binchrrCF (b0->data, pos, &chrs); +} + +/* int bninchr (const_bstring b0, int pos, const_bstring b1); + * + * Search for the first position in b0 starting from pos or after, in which + * none of the characters in b1 is found and return it. If such a position + * does not exist in b0, then BSTR_ERR is returned. + */ +int bninchr (const_bstring b0, int pos, const_bstring b1) { +struct charField chrs; + if (pos < 0 || b0 == NULL || b0->data == NULL || + b0->slen <= pos) return BSTR_ERR; + if (buildCharField (&chrs, b1) < 0) return BSTR_ERR; + invertCharField (&chrs); + return binchrCF (b0->data, b0->slen, pos, &chrs); +} + +/* int bninchrr (const_bstring b0, int pos, const_bstring b1); + * + * Search for the last position in b0 no greater than pos, in which none of + * the characters in b1 is found and return it. If such a position does not + * exist in b0, then BSTR_ERR is returned. + */ +int bninchrr (const_bstring b0, int pos, const_bstring b1) { +struct charField chrs; + if (pos < 0 || b0 == NULL || b0->data == NULL || + b0->slen < pos) return BSTR_ERR; + if (pos == b0->slen) pos--; + if (buildCharField (&chrs, b1) < 0) return BSTR_ERR; + invertCharField (&chrs); + return binchrrCF (b0->data, pos, &chrs); +} + +/* int bsetstr (bstring b0, int pos, bstring b1, unsigned char fill) + * + * Overwrite the string b0 starting at position pos with the string b1. If + * the position pos is past the end of b0, then the character "fill" is + * appended as necessary to make up the gap between the end of b0 and pos. + * If b1 is NULL, it behaves as if it were a 0-length string. + */ +int bsetstr (bstring b0, int pos, const_bstring b1, unsigned char fill) { +int d, newlen; +ptrdiff_t pd; +bstring aux = (bstring) b1; + + if (pos < 0 || b0 == NULL || b0->slen < 0 || NULL == b0->data || + b0->mlen < b0->slen || b0->mlen <= 0) return BSTR_ERR; + if (b1 != NULL && (b1->slen < 0 || b1->data == NULL)) return BSTR_ERR; + + d = pos; + + /* Aliasing case */ + if (NULL != aux) { + if ((pd = (ptrdiff_t) (b1->data - b0->data)) >= 0 && pd < (ptrdiff_t) b0->mlen) { + if (NULL == (aux = bstrcpy (b1))) return BSTR_ERR; + } + d += aux->slen; + } + + /* Increase memory size if necessary */ + if (balloc (b0, d + 1) != BSTR_OK) { + if (aux != b1) bdestroy (aux); + return BSTR_ERR; + } + + newlen = b0->slen; + + /* Fill in "fill" character as necessary */ + if (pos > newlen) { + bstr__memset (b0->data + b0->slen, (int) fill, (size_t) (pos - b0->slen)); + newlen = pos; + } + + /* Copy b1 to position pos in b0. */ + if (aux != NULL) { + bBlockCopy ((char *) (b0->data + pos), (char *) aux->data, aux->slen); + if (aux != b1) bdestroy (aux); + } + + /* Indicate the potentially increased size of b0 */ + if (d > newlen) newlen = d; + + b0->slen = newlen; + b0->data[newlen] = (unsigned char) '\0'; + + return BSTR_OK; +} + +/* int binsert (bstring b1, int pos, bstring b2, unsigned char fill) + * + * Inserts the string b2 into b1 at position pos. If the position pos is + * past the end of b1, then the character "fill" is appended as necessary to + * make up the gap between the end of b1 and pos. Unlike bsetstr, binsert + * does not allow b2 to be NULL. + */ +int binsert (bstring b1, int pos, const_bstring b2, unsigned char fill) { +int d, l; +ptrdiff_t pd; +bstring aux = (bstring) b2; + + if (pos < 0 || b1 == NULL || b2 == NULL || b1->slen < 0 || + b2->slen < 0 || b1->mlen < b1->slen || b1->mlen <= 0) return BSTR_ERR; + + /* Aliasing case */ + if ((pd = (ptrdiff_t) (b2->data - b1->data)) >= 0 && pd < (ptrdiff_t) b1->mlen) { + if (NULL == (aux = bstrcpy (b2))) return BSTR_ERR; + } + + /* Compute the two possible end pointers */ + d = b1->slen + aux->slen; + l = pos + aux->slen; + if ((d|l) < 0) return BSTR_ERR; + + if (l > d) { + /* Inserting past the end of the string */ + if (balloc (b1, l + 1) != BSTR_OK) { + if (aux != b2) bdestroy (aux); + return BSTR_ERR; + } + bstr__memset (b1->data + b1->slen, (int) fill, (size_t) (pos - b1->slen)); + b1->slen = l; + } else { + /* Inserting in the middle of the string */ + if (balloc (b1, d + 1) != BSTR_OK) { + if (aux != b2) bdestroy (aux); + return BSTR_ERR; + } + bBlockCopy (b1->data + l, b1->data + pos, d - l); + b1->slen = d; + } + bBlockCopy (b1->data + pos, aux->data, aux->slen); + b1->data[b1->slen] = (unsigned char) '\0'; + if (aux != b2) bdestroy (aux); + return BSTR_OK; +} + +/* int breplace (bstring b1, int pos, int len, bstring b2, + * unsigned char fill) + * + * Replace a section of a string from pos for a length len with the string b2. + * fill is used is pos > b1->slen. + */ +int breplace (bstring b1, int pos, int len, const_bstring b2, + unsigned char fill) { +int pl, ret; +ptrdiff_t pd; +bstring aux = (bstring) b2; + + if (pos < 0 || len < 0 || (pl = pos + len) < 0 || b1 == NULL || + b2 == NULL || b1->data == NULL || b2->data == NULL || + b1->slen < 0 || b2->slen < 0 || b1->mlen < b1->slen || + b1->mlen <= 0) return BSTR_ERR; + + /* Straddles the end? */ + if (pl >= b1->slen) { + if ((ret = bsetstr (b1, pos, b2, fill)) < 0) return ret; + if (pos + b2->slen < b1->slen) { + b1->slen = pos + b2->slen; + b1->data[b1->slen] = (unsigned char) '\0'; + } + return ret; + } + + /* Aliasing case */ + if ((pd = (ptrdiff_t) (b2->data - b1->data)) >= 0 && pd < (ptrdiff_t) b1->slen) { + if (NULL == (aux = bstrcpy (b2))) return BSTR_ERR; + } + + if (aux->slen > len) { + if (balloc (b1, b1->slen + aux->slen - len) != BSTR_OK) { + if (aux != b2) bdestroy (aux); + return BSTR_ERR; + } + } + + if (aux->slen != len) bstr__memmove (b1->data + pos + aux->slen, b1->data + pos + len, b1->slen - (pos + len)); + bstr__memcpy (b1->data + pos, aux->data, aux->slen); + b1->slen += aux->slen - len; + b1->data[b1->slen] = (unsigned char) '\0'; + if (aux != b2) bdestroy (aux); + return BSTR_OK; +} + +/* int bfindreplace (bstring b, const_bstring find, const_bstring repl, + * int pos) + * + * Replace all occurrences of a find string with a replace string after a + * given point in a bstring. + */ + +typedef int (*instr_fnptr) (const_bstring s1, int pos, const_bstring s2); + +static int findreplaceengine (bstring b, const_bstring find, const_bstring repl, int pos, instr_fnptr instr) { +int i, ret, slen, mlen, delta, acc; +int * d; +int static_d[32]; +ptrdiff_t pd; +bstring auxf = (bstring) find; +bstring auxr = (bstring) repl; + + if (b == NULL || b->data == NULL || find == NULL || + find->data == NULL || repl == NULL || repl->data == NULL || + pos < 0 || find->slen <= 0 || b->mlen < 0 || b->slen > b->mlen || + b->mlen <= 0 || b->slen < 0 || repl->slen < 0) return BSTR_ERR; + if (pos > b->slen - find->slen) return BSTR_OK; + + /* Alias with find string */ + pd = (ptrdiff_t) (find->data - b->data); + if ((ptrdiff_t) (pos - find->slen) < pd && pd < (ptrdiff_t) b->slen) { + if (NULL == (auxf = bstrcpy (find))) return BSTR_ERR; + } + + /* Alias with repl string */ + pd = (ptrdiff_t) (repl->data - b->data); + if ((ptrdiff_t) (pos - repl->slen) < pd && pd < (ptrdiff_t) b->slen) { + if (NULL == (auxr = bstrcpy (repl))) { + if (auxf != find) bdestroy (auxf); + return BSTR_ERR; + } + } + + delta = auxf->slen - auxr->slen; + + /* in-place replacement since find and replace strings are of equal + length */ + if (delta == 0) { + while ((pos = instr (b, pos, auxf)) >= 0) { + bstr__memcpy (b->data + pos, auxr->data, auxr->slen); + pos += auxf->slen; + } + if (auxf != find) bdestroy (auxf); + if (auxr != repl) bdestroy (auxr); + return BSTR_OK; + } + + /* shrinking replacement since auxf->slen > auxr->slen */ + if (delta > 0) { + acc = 0; + + while ((i = instr (b, pos, auxf)) >= 0) { + if (acc && i > pos) + bstr__memmove (b->data + pos - acc, b->data + pos, i - pos); + if (auxr->slen) + bstr__memcpy (b->data + i - acc, auxr->data, auxr->slen); + acc += delta; + pos = i + auxf->slen; + } + + if (acc) { + i = b->slen; + if (i > pos) + bstr__memmove (b->data + pos - acc, b->data + pos, i - pos); + b->slen -= acc; + b->data[b->slen] = (unsigned char) '\0'; + } + + if (auxf != find) bdestroy (auxf); + if (auxr != repl) bdestroy (auxr); + return BSTR_OK; + } + + /* expanding replacement since find->slen < repl->slen. Its a lot + more complicated. */ + + mlen = 32; + d = (int *) static_d; /* Avoid malloc for trivial cases */ + acc = slen = 0; + + while ((pos = instr (b, pos, auxf)) >= 0) { + if (slen + 1 >= mlen) { + int sl; + int * t; + mlen += mlen; + sl = sizeof (int *) * mlen; + if (static_d == d) d = NULL; + if (sl < mlen || NULL == (t = (int *) bstr__realloc (d, sl))) { + ret = BSTR_ERR; + goto done; + } + if (NULL == d) bstr__memcpy (t, static_d, sizeof (static_d)); + d = t; + } + d[slen] = pos; + slen++; + acc -= delta; + pos += auxf->slen; + if (pos < 0 || acc < 0) { + ret = BSTR_ERR; + goto done; + } + } + d[slen] = b->slen; + + if (BSTR_OK == (ret = balloc (b, b->slen + acc + 1))) { + b->slen += acc; + for (i = slen-1; i >= 0; i--) { + int s, l; + s = d[i] + auxf->slen; + l = d[i+1] - s; + if (l) { + bstr__memmove (b->data + s + acc, b->data + s, l); + } + if (auxr->slen) { + bstr__memmove (b->data + s + acc - auxr->slen, + auxr->data, auxr->slen); + } + acc += delta; + } + b->data[b->slen] = (unsigned char) '\0'; + } + + done:; + if (static_d == d) d = NULL; + bstr__free (d); + if (auxf != find) bdestroy (auxf); + if (auxr != repl) bdestroy (auxr); + return ret; +} + +/* int bfindreplace (bstring b, const_bstring find, const_bstring repl, + * int pos) + * + * Replace all occurrences of a find string with a replace string after a + * given point in a bstring. + */ +int bfindreplace (bstring b, const_bstring find, const_bstring repl, int pos) { + return findreplaceengine (b, find, repl, pos, binstr); +} + +/* int bfindreplacecaseless (bstring b, const_bstring find, const_bstring repl, + * int pos) + * + * Replace all occurrences of a find string, ignoring case, with a replace + * string after a given point in a bstring. + */ +int bfindreplacecaseless (bstring b, const_bstring find, const_bstring repl, int pos) { + return findreplaceengine (b, find, repl, pos, binstrcaseless); +} + +/* int binsertch (bstring b, int pos, int len, unsigned char fill) + * + * Inserts the character fill repeatedly into b at position pos for a + * length len. If the position pos is past the end of b, then the + * character "fill" is appended as necessary to make up the gap between the + * end of b and the position pos + len. + */ +int binsertch (bstring b, int pos, int len, unsigned char fill) { +int d, l, i; + + if (pos < 0 || b == NULL || b->slen < 0 || b->mlen < b->slen || + b->mlen <= 0 || len < 0) return BSTR_ERR; + + /* Compute the two possible end pointers */ + d = b->slen + len; + l = pos + len; + if ((d|l) < 0) return BSTR_ERR; + + if (l > d) { + /* Inserting past the end of the string */ + if (balloc (b, l + 1) != BSTR_OK) return BSTR_ERR; + pos = b->slen; + b->slen = l; + } else { + /* Inserting in the middle of the string */ + if (balloc (b, d + 1) != BSTR_OK) return BSTR_ERR; + for (i = d - 1; i >= l; i--) { + b->data[i] = b->data[i - len]; + } + b->slen = d; + } + + for (i=pos; i < l; i++) b->data[i] = fill; + b->data[b->slen] = (unsigned char) '\0'; + return BSTR_OK; +} + +/* int bpattern (bstring b, int len) + * + * Replicate the bstring, b in place, end to end repeatedly until it + * surpasses len characters, then chop the result to exactly len characters. + * This function operates in-place. The function will return with BSTR_ERR + * if b is NULL or of length 0, otherwise BSTR_OK is returned. + */ +int bpattern (bstring b, int len) { +int i, d; + + d = blength (b); + if (d <= 0 || len < 0 || balloc (b, len + 1) != BSTR_OK) return BSTR_ERR; + if (len > 0) { + if (d == 1) return bsetstr (b, len, NULL, b->data[0]); + for (i = d; i < len; i++) b->data[i] = b->data[i - d]; + } + b->data[len] = (unsigned char) '\0'; + b->slen = len; + return BSTR_OK; +} + +#define BS_BUFF_SZ (1024) + +/* int breada (bstring b, bNread readPtr, void * parm) + * + * Use a finite buffer fread-like function readPtr to concatenate to the + * bstring b the entire contents of file-like source data in a roughly + * efficient way. + */ +int breada (bstring b, bNread readPtr, void * parm) { +int i, l, n; + + if (b == NULL || b->mlen <= 0 || b->slen < 0 || b->mlen < b->slen || + b->mlen <= 0 || readPtr == NULL) return BSTR_ERR; + + i = b->slen; + for (n=i+16; ; n += ((n < BS_BUFF_SZ) ? n : BS_BUFF_SZ)) { + if (BSTR_OK != balloc (b, n + 1)) return BSTR_ERR; + l = (int) readPtr ((void *) (b->data + i), 1, n - i, parm); + i += l; + b->slen = i; + if (i < n) break; + } + + b->data[i] = (unsigned char) '\0'; + return BSTR_OK; +} + +/* bstring bread (bNread readPtr, void * parm) + * + * Use a finite buffer fread-like function readPtr to create a bstring + * filled with the entire contents of file-like source data in a roughly + * efficient way. + */ +bstring bread (bNread readPtr, void * parm) { +bstring buff; + + if (0 > breada (buff = bfromcstr (""), readPtr, parm)) { + bdestroy (buff); + return NULL; + } + return buff; +} + +/* int bassigngets (bstring b, bNgetc getcPtr, void * parm, char terminator) + * + * Use an fgetc-like single character stream reading function (getcPtr) to + * obtain a sequence of characters which are concatenated to the end of the + * bstring b. The stream read is terminated by the passed in terminator + * parameter. + * + * If getcPtr returns with a negative number, or the terminator character + * (which is appended) is read, then the stream reading is halted and the + * function returns with a partial result in b. If there is an empty partial + * result, 1 is returned. If no characters are read, or there is some other + * detectable error, BSTR_ERR is returned. + */ +int bassigngets (bstring b, bNgetc getcPtr, void * parm, char terminator) { +int c, d, e; + + if (b == NULL || b->mlen <= 0 || b->slen < 0 || b->mlen < b->slen || + b->mlen <= 0 || getcPtr == NULL) return BSTR_ERR; + d = 0; + e = b->mlen - 2; + + while ((c = getcPtr (parm)) >= 0) { + if (d > e) { + b->slen = d; + if (balloc (b, d + 2) != BSTR_OK) return BSTR_ERR; + e = b->mlen - 2; + } + b->data[d] = (unsigned char) c; + d++; + if (c == terminator) break; + } + + b->data[d] = (unsigned char) '\0'; + b->slen = d; + + return d == 0 && c < 0; +} + +/* int bgetsa (bstring b, bNgetc getcPtr, void * parm, char terminator) + * + * Use an fgetc-like single character stream reading function (getcPtr) to + * obtain a sequence of characters which are concatenated to the end of the + * bstring b. The stream read is terminated by the passed in terminator + * parameter. + * + * If getcPtr returns with a negative number, or the terminator character + * (which is appended) is read, then the stream reading is halted and the + * function returns with a partial result concatentated to b. If there is + * an empty partial result, 1 is returned. If no characters are read, or + * there is some other detectable error, BSTR_ERR is returned. + */ +int bgetsa (bstring b, bNgetc getcPtr, void * parm, char terminator) { +int c, d, e; + + if (b == NULL || b->mlen <= 0 || b->slen < 0 || b->mlen < b->slen || + b->mlen <= 0 || getcPtr == NULL) return BSTR_ERR; + d = b->slen; + e = b->mlen - 2; + + while ((c = getcPtr (parm)) >= 0) { + if (d > e) { + b->slen = d; + if (balloc (b, d + 2) != BSTR_OK) return BSTR_ERR; + e = b->mlen - 2; + } + b->data[d] = (unsigned char) c; + d++; + if (c == terminator) break; + } + + b->data[d] = (unsigned char) '\0'; + b->slen = d; + + return d == 0 && c < 0; +} + +/* bstring bgets (bNgetc getcPtr, void * parm, char terminator) + * + * Use an fgetc-like single character stream reading function (getcPtr) to + * obtain a sequence of characters which are concatenated into a bstring. + * The stream read is terminated by the passed in terminator function. + * + * If getcPtr returns with a negative number, or the terminator character + * (which is appended) is read, then the stream reading is halted and the + * result obtained thus far is returned. If no characters are read, or + * there is some other detectable error, NULL is returned. + */ +bstring bgets (bNgetc getcPtr, void * parm, char terminator) { +bstring buff; + + if (0 > bgetsa (buff = bfromcstr (""), getcPtr, parm, terminator) || 0 >= buff->slen) { + bdestroy (buff); + buff = NULL; + } + return buff; +} + +struct bStream { + bstring buff; /* Buffer for over-reads */ + void * parm; /* The stream handle for core stream */ + bNread readFnPtr; /* fread compatible fnptr for core stream */ + int isEOF; /* track file's EOF state */ + int maxBuffSz; +}; + +/* struct bStream * bsopen (bNread readPtr, void * parm) + * + * Wrap a given open stream (described by a fread compatible function + * pointer and stream handle) into an open bStream suitable for the bstring + * library streaming functions. + */ +struct bStream * bsopen (bNread readPtr, void * parm) { +struct bStream * s; + + if (readPtr == NULL) return NULL; + s = (struct bStream *) bstr__alloc (sizeof (struct bStream)); + if (s == NULL) return NULL; + s->parm = parm; + s->buff = bfromcstr (""); + s->readFnPtr = readPtr; + s->maxBuffSz = BS_BUFF_SZ; + s->isEOF = 0; + return s; +} + +/* int bsbufflength (struct bStream * s, int sz) + * + * Set the length of the buffer used by the bStream. If sz is zero, the + * length is not set. This function returns with the previous length. + */ +int bsbufflength (struct bStream * s, int sz) { +int oldSz; + if (s == NULL || sz < 0) return BSTR_ERR; + oldSz = s->maxBuffSz; + if (sz > 0) s->maxBuffSz = sz; + return oldSz; +} + +int bseof (const struct bStream * s) { + if (s == NULL || s->readFnPtr == NULL) return BSTR_ERR; + return s->isEOF && (s->buff->slen == 0); +} + +/* void * bsclose (struct bStream * s) + * + * Close the bStream, and return the handle to the stream that was originally + * used to open the given stream. + */ +void * bsclose (struct bStream * s) { +void * parm; + if (s == NULL) return NULL; + s->readFnPtr = NULL; + if (s->buff) bdestroy (s->buff); + s->buff = NULL; + parm = s->parm; + s->parm = NULL; + s->isEOF = 1; + bstr__free (s); + return parm; +} + +/* int bsreadlna (bstring r, struct bStream * s, char terminator) + * + * Read a bstring terminated by the terminator character or the end of the + * stream from the bStream (s) and return it into the parameter r. This + * function may read additional characters from the core stream that are not + * returned, but will be retained for subsequent read operations. + */ +int bsreadlna (bstring r, struct bStream * s, char terminator) { +int i, l, ret, rlo; +char * b; +struct tagbstring x; + + if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0 || + r->slen < 0 || r->mlen < r->slen) return BSTR_ERR; + l = s->buff->slen; + if (BSTR_OK != balloc (s->buff, s->maxBuffSz + 1)) return BSTR_ERR; + b = (char *) s->buff->data; + x.data = (unsigned char *) b; + + /* First check if the current buffer holds the terminator */ + b[l] = terminator; /* Set sentinel */ + for (i=0; b[i] != terminator; i++) ; + if (i < l) { + x.slen = i + 1; + ret = bconcat (r, &x); + s->buff->slen = l; + if (BSTR_OK == ret) bdelete (s->buff, 0, i + 1); + return BSTR_OK; + } + + rlo = r->slen; + + /* If not then just concatenate the entire buffer to the output */ + x.slen = l; + if (BSTR_OK != bconcat (r, &x)) return BSTR_ERR; + + /* Perform direct in-place reads into the destination to allow for + the minimum of data-copies */ + for (;;) { + if (BSTR_OK != balloc (r, r->slen + s->maxBuffSz + 1)) return BSTR_ERR; + b = (char *) (r->data + r->slen); + l = (int) s->readFnPtr (b, 1, s->maxBuffSz, s->parm); + if (l <= 0) { + r->data[r->slen] = (unsigned char) '\0'; + s->buff->slen = 0; + s->isEOF = 1; + /* If nothing was read return with an error message */ + return BSTR_ERR & -(r->slen == rlo); + } + b[l] = terminator; /* Set sentinel */ + for (i=0; b[i] != terminator; i++) ; + if (i < l) break; + r->slen += l; + } + + /* Terminator found, push over-read back to buffer */ + i++; + r->slen += i; + s->buff->slen = l - i; + bstr__memcpy (s->buff->data, b + i, l - i); + r->data[r->slen] = (unsigned char) '\0'; + return BSTR_OK; +} + +/* int bsreadlnsa (bstring r, struct bStream * s, bstring term) + * + * Read a bstring terminated by any character in the term string or the end + * of the stream from the bStream (s) and return it into the parameter r. + * This function may read additional characters from the core stream that + * are not returned, but will be retained for subsequent read operations. + */ +int bsreadlnsa (bstring r, struct bStream * s, const_bstring term) { +int i, l, ret, rlo; +unsigned char * b; +struct tagbstring x; +struct charField cf; + + if (s == NULL || s->buff == NULL || r == NULL || term == NULL || + term->data == NULL || r->mlen <= 0 || r->slen < 0 || + r->mlen < r->slen) return BSTR_ERR; + if (term->slen == 1) return bsreadlna (r, s, term->data[0]); + if (term->slen < 1 || buildCharField (&cf, term)) return BSTR_ERR; + + l = s->buff->slen; + if (BSTR_OK != balloc (s->buff, s->maxBuffSz + 1)) return BSTR_ERR; + b = (unsigned char *) s->buff->data; + x.data = b; + + /* First check if the current buffer holds the terminator */ + b[l] = term->data[0]; /* Set sentinel */ + for (i=0; !testInCharField (&cf, b[i]); i++) ; + if (i < l) { + x.slen = i + 1; + ret = bconcat (r, &x); + s->buff->slen = l; + if (BSTR_OK == ret) bdelete (s->buff, 0, i + 1); + return BSTR_OK; + } + + rlo = r->slen; + + /* If not then just concatenate the entire buffer to the output */ + x.slen = l; + if (BSTR_OK != bconcat (r, &x)) return BSTR_ERR; + + /* Perform direct in-place reads into the destination to allow for + the minimum of data-copies */ + for (;;) { + if (BSTR_OK != balloc (r, r->slen + s->maxBuffSz + 1)) return BSTR_ERR; + b = (unsigned char *) (r->data + r->slen); + l = (int) s->readFnPtr (b, 1, s->maxBuffSz, s->parm); + if (l <= 0) { + r->data[r->slen] = (unsigned char) '\0'; + s->buff->slen = 0; + s->isEOF = 1; + /* If nothing was read return with an error message */ + return BSTR_ERR & -(r->slen == rlo); + } + + b[l] = term->data[0]; /* Set sentinel */ + for (i=0; !testInCharField (&cf, b[i]); i++) ; + if (i < l) break; + r->slen += l; + } + + /* Terminator found, push over-read back to buffer */ + i++; + r->slen += i; + s->buff->slen = l - i; + bstr__memcpy (s->buff->data, b + i, l - i); + r->data[r->slen] = (unsigned char) '\0'; + return BSTR_OK; +} + +/* int bsreada (bstring r, struct bStream * s, int n) + * + * Read a bstring of length n (or, if it is fewer, as many bytes as is + * remaining) from the bStream. This function may read additional + * characters from the core stream that are not returned, but will be + * retained for subsequent read operations. This function will not read + * additional characters from the core stream beyond virtual stream pointer. + */ +int bsreada (bstring r, struct bStream * s, int n) { +int l, ret, orslen; +char * b; +struct tagbstring x; + + if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0 + || r->slen < 0 || r->mlen < r->slen || n <= 0) return BSTR_ERR; + + n += r->slen; + if (n <= 0) return BSTR_ERR; + + l = s->buff->slen; + + orslen = r->slen; + + if (0 == l) { + if (s->isEOF) return BSTR_ERR; + if (r->mlen > n) { + l = (int) s->readFnPtr (r->data + r->slen, 1, n - r->slen, s->parm); + if (0 >= l || l > n - r->slen) { + s->isEOF = 1; + return BSTR_ERR; + } + r->slen += l; + r->data[r->slen] = (unsigned char) '\0'; + return 0; + } + } + + if (BSTR_OK != balloc (s->buff, s->maxBuffSz + 1)) return BSTR_ERR; + b = (char *) s->buff->data; + x.data = (unsigned char *) b; + + do { + if (l + r->slen >= n) { + x.slen = n - r->slen; + ret = bconcat (r, &x); + s->buff->slen = l; + if (BSTR_OK == ret) bdelete (s->buff, 0, x.slen); + return BSTR_ERR & -(r->slen == orslen); + } + + x.slen = l; + if (BSTR_OK != bconcat (r, &x)) break; + + l = n - r->slen; + if (l > s->maxBuffSz) l = s->maxBuffSz; + + l = (int) s->readFnPtr (b, 1, l, s->parm); + + } while (l > 0); + if (l < 0) l = 0; + if (l == 0) s->isEOF = 1; + s->buff->slen = l; + return BSTR_ERR & -(r->slen == orslen); +} + +/* int bsreadln (bstring r, struct bStream * s, char terminator) + * + * Read a bstring terminated by the terminator character or the end of the + * stream from the bStream (s) and return it into the parameter r. This + * function may read additional characters from the core stream that are not + * returned, but will be retained for subsequent read operations. + */ +int bsreadln (bstring r, struct bStream * s, char terminator) { + if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0) + return BSTR_ERR; + if (BSTR_OK != balloc (s->buff, s->maxBuffSz + 1)) return BSTR_ERR; + r->slen = 0; + return bsreadlna (r, s, terminator); +} + +/* int bsreadlns (bstring r, struct bStream * s, bstring term) + * + * Read a bstring terminated by any character in the term string or the end + * of the stream from the bStream (s) and return it into the parameter r. + * This function may read additional characters from the core stream that + * are not returned, but will be retained for subsequent read operations. + */ +int bsreadlns (bstring r, struct bStream * s, const_bstring term) { + if (s == NULL || s->buff == NULL || r == NULL || term == NULL + || term->data == NULL || r->mlen <= 0) return BSTR_ERR; + if (term->slen == 1) return bsreadln (r, s, term->data[0]); + if (term->slen < 1) return BSTR_ERR; + if (BSTR_OK != balloc (s->buff, s->maxBuffSz + 1)) return BSTR_ERR; + r->slen = 0; + return bsreadlnsa (r, s, term); +} + +/* int bsread (bstring r, struct bStream * s, int n) + * + * Read a bstring of length n (or, if it is fewer, as many bytes as is + * remaining) from the bStream. This function may read additional + * characters from the core stream that are not returned, but will be + * retained for subsequent read operations. This function will not read + * additional characters from the core stream beyond virtual stream pointer. + */ +int bsread (bstring r, struct bStream * s, int n) { + if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0 + || n <= 0) return BSTR_ERR; + if (BSTR_OK != balloc (s->buff, s->maxBuffSz + 1)) return BSTR_ERR; + r->slen = 0; + return bsreada (r, s, n); +} + +/* int bsunread (struct bStream * s, const_bstring b) + * + * Insert a bstring into the bStream at the current position. These + * characters will be read prior to those that actually come from the core + * stream. + */ +int bsunread (struct bStream * s, const_bstring b) { + if (s == NULL || s->buff == NULL) return BSTR_ERR; + return binsert (s->buff, 0, b, (unsigned char) '?'); +} + +/* int bspeek (bstring r, const struct bStream * s) + * + * Return the currently buffered characters from the bStream that will be + * read prior to reads from the core stream. + */ +int bspeek (bstring r, const struct bStream * s) { + if (s == NULL || s->buff == NULL) return BSTR_ERR; + return bassign (r, s->buff); +} + +/* bstring bjoin (const struct bstrList * bl, const_bstring sep); + * + * Join the entries of a bstrList into one bstring by sequentially + * concatenating them with the sep string in between. If there is an error + * NULL is returned, otherwise a bstring with the correct result is returned. + */ +bstring bjoin (const struct bstrList * bl, const_bstring sep) { +bstring b; +int i, c, v; + + if (bl == NULL || bl->qty < 0) return NULL; + if (sep != NULL && (sep->slen < 0 || sep->data == NULL)) return NULL; + + for (i = 0, c = 1; i < bl->qty; i++) { + v = bl->entry[i]->slen; + if (v < 0) return NULL; /* Invalid input */ + c += v; + if (c < 0) return NULL; /* Wrap around ?? */ + } + + if (sep != NULL) c += (bl->qty - 1) * sep->slen; + + b = (bstring) bstr__alloc (sizeof (struct tagbstring)); + if (NULL == b) return NULL; /* Out of memory */ + b->data = (unsigned char *) bstr__alloc (c); + if (b->data == NULL) { + bstr__free (b); + return NULL; + } + + b->mlen = c; + b->slen = c-1; + + for (i = 0, c = 0; i < bl->qty; i++) { + if (i > 0 && sep != NULL) { + bstr__memcpy (b->data + c, sep->data, sep->slen); + c += sep->slen; + } + v = bl->entry[i]->slen; + bstr__memcpy (b->data + c, bl->entry[i]->data, v); + c += v; + } + b->data[c] = (unsigned char) '\0'; + return b; +} + +#define BSSSC_BUFF_LEN (256) + +/* int bssplitscb (struct bStream * s, const_bstring splitStr, + * int (* cb) (void * parm, int ofs, const_bstring entry), void * parm) + * + * Iterate the set of disjoint sequential substrings read from a stream + * divided by any of the characters in splitStr. An empty splitStr causes + * the whole stream to be iterated once. + * + * Note: At the point of calling the cb function, the bStream pointer is + * pointed exactly at the position right after having read the split + * character. The cb function can act on the stream by causing the bStream + * pointer to move, and bssplitscb will continue by starting the next split + * at the position of the pointer after the return from cb. + * + * However, if the cb causes the bStream s to be destroyed then the cb must + * return with a negative value, otherwise bssplitscb will continue in an + * undefined manner. + */ +int bssplitscb (struct bStream * s, const_bstring splitStr, + int (* cb) (void * parm, int ofs, const_bstring entry), void * parm) { +struct charField chrs; +bstring buff; +int i, p, ret; + + if (cb == NULL || s == NULL || s->readFnPtr == NULL + || splitStr == NULL || splitStr->slen < 0) return BSTR_ERR; + + if (NULL == (buff = bfromcstr (""))) return BSTR_ERR; + + if (splitStr->slen == 0) { + while (bsreada (buff, s, BSSSC_BUFF_LEN) >= 0) ; + if ((ret = cb (parm, 0, buff)) > 0) + ret = 0; + } else { + buildCharField (&chrs, splitStr); + ret = p = i = 0; + for (;;) { + if (i >= buff->slen) { + bsreada (buff, s, BSSSC_BUFF_LEN); + if (i >= buff->slen) { + if (0 < (ret = cb (parm, p, buff))) ret = 0; + break; + } + } + if (testInCharField (&chrs, buff->data[i])) { + struct tagbstring t; + unsigned char c; + + blk2tbstr (t, buff->data + i + 1, buff->slen - (i + 1)); + if ((ret = bsunread (s, &t)) < 0) break; + buff->slen = i; + c = buff->data[i]; + buff->data[i] = (unsigned char) '\0'; + if ((ret = cb (parm, p, buff)) < 0) break; + buff->data[i] = c; + buff->slen = 0; + p += i + 1; + i = -1; + } + i++; + } + } + + bdestroy (buff); + return ret; +} + +/* int bssplitstrcb (struct bStream * s, const_bstring splitStr, + * int (* cb) (void * parm, int ofs, const_bstring entry), void * parm) + * + * Iterate the set of disjoint sequential substrings read from a stream + * divided by the entire substring splitStr. An empty splitStr causes + * each character of the stream to be iterated. + * + * Note: At the point of calling the cb function, the bStream pointer is + * pointed exactly at the position right after having read the split + * character. The cb function can act on the stream by causing the bStream + * pointer to move, and bssplitscb will continue by starting the next split + * at the position of the pointer after the return from cb. + * + * However, if the cb causes the bStream s to be destroyed then the cb must + * return with a negative value, otherwise bssplitscb will continue in an + * undefined manner. + */ +int bssplitstrcb (struct bStream * s, const_bstring splitStr, + int (* cb) (void * parm, int ofs, const_bstring entry), void * parm) { +bstring buff; +int i, p, ret; + + if (cb == NULL || s == NULL || s->readFnPtr == NULL + || splitStr == NULL || splitStr->slen < 0) return BSTR_ERR; + + if (splitStr->slen == 1) return bssplitscb (s, splitStr, cb, parm); + + if (NULL == (buff = bfromcstr (""))) return BSTR_ERR; + + if (splitStr->slen == 0) { + for (i=0; bsreada (buff, s, BSSSC_BUFF_LEN) >= 0; i++) { + if ((ret = cb (parm, 0, buff)) < 0) { + bdestroy (buff); + return ret; + } + buff->slen = 0; + } + return BSTR_OK; + } else { + ret = p = i = 0; + for (i=p=0;;) { + if ((ret = binstr (buff, 0, splitStr)) >= 0) { + struct tagbstring t; + blk2tbstr (t, buff->data, ret); + i = ret + splitStr->slen; + if ((ret = cb (parm, p, &t)) < 0) break; + p += i; + bdelete (buff, 0, i); + } else { + bsreada (buff, s, BSSSC_BUFF_LEN); + if (bseof (s)) { + if ((ret = cb (parm, p, buff)) > 0) ret = 0; + break; + } + } + } + } + + bdestroy (buff); + return ret; +} + +/* int bstrListCreate (void) + * + * Create a bstrList. + */ +struct bstrList * bstrListCreate (void) { +struct bstrList * sl = (struct bstrList *) bstr__alloc (sizeof (struct bstrList)); + if (sl) { + sl->entry = (bstring *) bstr__alloc (1*sizeof (bstring)); + if (!sl->entry) { + bstr__free (sl); + sl = NULL; + } else { + sl->qty = 0; + sl->mlen = 1; + } + } + return sl; +} + +/* int bstrListDestroy (struct bstrList * sl) + * + * Destroy a bstrList that has been created by bsplit, bsplits or bstrListCreate. + */ +int bstrListDestroy (struct bstrList * sl) { +int i; + if (sl == NULL || sl->qty < 0) return BSTR_ERR; + for (i=0; i < sl->qty; i++) { + if (sl->entry[i]) { + bdestroy (sl->entry[i]); + sl->entry[i] = NULL; + } + } + sl->qty = -1; + sl->mlen = -1; + bstr__free (sl->entry); + sl->entry = NULL; + bstr__free (sl); + return BSTR_OK; +} + +/* int bstrListAlloc (struct bstrList * sl, int msz) + * + * Ensure that there is memory for at least msz number of entries for the + * list. + */ +int bstrListAlloc (struct bstrList * sl, int msz) { +bstring * l; +int smsz; +size_t nsz; + if (!sl || msz <= 0 || !sl->entry || sl->qty < 0 || sl->mlen <= 0 || sl->qty > sl->mlen) return BSTR_ERR; + if (sl->mlen >= msz) return BSTR_OK; + smsz = snapUpSize (msz); + nsz = ((size_t) smsz) * sizeof (bstring); + if (nsz < (size_t) smsz) return BSTR_ERR; + l = (bstring *) bstr__realloc (sl->entry, nsz); + if (!l) { + smsz = msz; + nsz = ((size_t) smsz) * sizeof (bstring); + l = (bstring *) bstr__realloc (sl->entry, nsz); + if (!l) return BSTR_ERR; + } + sl->mlen = smsz; + sl->entry = l; + return BSTR_OK; +} + +/* int bstrListAllocMin (struct bstrList * sl, int msz) + * + * Try to allocate the minimum amount of memory for the list to include at + * least msz entries or sl->qty whichever is greater. + */ +int bstrListAllocMin (struct bstrList * sl, int msz) { +bstring * l; +size_t nsz; + if (!sl || msz <= 0 || !sl->entry || sl->qty < 0 || sl->mlen <= 0 || sl->qty > sl->mlen) return BSTR_ERR; + if (msz < sl->qty) msz = sl->qty; + if (sl->mlen == msz) return BSTR_OK; + nsz = ((size_t) msz) * sizeof (bstring); + if (nsz < (size_t) msz) return BSTR_ERR; + l = (bstring *) bstr__realloc (sl->entry, nsz); + if (!l) return BSTR_ERR; + sl->mlen = msz; + sl->entry = l; + return BSTR_OK; +} + +/* int bsplitcb (const_bstring str, unsigned char splitChar, int pos, + * int (* cb) (void * parm, int ofs, int len), void * parm) + * + * Iterate the set of disjoint sequential substrings over str divided by the + * character in splitChar. + * + * Note: Non-destructive modification of str from within the cb function + * while performing this split is not undefined. bsplitcb behaves in + * sequential lock step with calls to cb. I.e., after returning from a cb + * that return a non-negative integer, bsplitcb continues from the position + * 1 character after the last detected split character and it will halt + * immediately if the length of str falls below this point. However, if the + * cb function destroys str, then it *must* return with a negative value, + * otherwise bsplitcb will continue in an undefined manner. + */ +int bsplitcb (const_bstring str, unsigned char splitChar, int pos, + int (* cb) (void * parm, int ofs, int len), void * parm) { +int i, p, ret; + + if (cb == NULL || str == NULL || pos < 0 || pos > str->slen) + return BSTR_ERR; + + p = pos; + do { + for (i=p; i < str->slen; i++) { + if (str->data[i] == splitChar) break; + } + if ((ret = cb (parm, p, i - p)) < 0) return ret; + p = i + 1; + } while (p <= str->slen); + return BSTR_OK; +} + +/* int bsplitscb (const_bstring str, const_bstring splitStr, int pos, + * int (* cb) (void * parm, int ofs, int len), void * parm) + * + * Iterate the set of disjoint sequential substrings over str divided by any + * of the characters in splitStr. An empty splitStr causes the whole str to + * be iterated once. + * + * Note: Non-destructive modification of str from within the cb function + * while performing this split is not undefined. bsplitscb behaves in + * sequential lock step with calls to cb. I.e., after returning from a cb + * that return a non-negative integer, bsplitscb continues from the position + * 1 character after the last detected split character and it will halt + * immediately if the length of str falls below this point. However, if the + * cb function destroys str, then it *must* return with a negative value, + * otherwise bsplitscb will continue in an undefined manner. + */ +int bsplitscb (const_bstring str, const_bstring splitStr, int pos, + int (* cb) (void * parm, int ofs, int len), void * parm) { +struct charField chrs; +int i, p, ret; + + if (cb == NULL || str == NULL || pos < 0 || pos > str->slen + || splitStr == NULL || splitStr->slen < 0) return BSTR_ERR; + if (splitStr->slen == 0) { + if ((ret = cb (parm, 0, str->slen)) > 0) ret = 0; + return ret; + } + + if (splitStr->slen == 1) + return bsplitcb (str, splitStr->data[0], pos, cb, parm); + + buildCharField (&chrs, splitStr); + + p = pos; + do { + for (i=p; i < str->slen; i++) { + if (testInCharField (&chrs, str->data[i])) break; + } + if ((ret = cb (parm, p, i - p)) < 0) return ret; + p = i + 1; + } while (p <= str->slen); + return BSTR_OK; +} + +/* int bsplitstrcb (const_bstring str, const_bstring splitStr, int pos, + * int (* cb) (void * parm, int ofs, int len), void * parm) + * + * Iterate the set of disjoint sequential substrings over str divided by the + * substring splitStr. An empty splitStr causes the whole str to be + * iterated once. + * + * Note: Non-destructive modification of str from within the cb function + * while performing this split is not undefined. bsplitstrcb behaves in + * sequential lock step with calls to cb. I.e., after returning from a cb + * that return a non-negative integer, bsplitscb continues from the position + * 1 character after the last detected split character and it will halt + * immediately if the length of str falls below this point. However, if the + * cb function destroys str, then it *must* return with a negative value, + * otherwise bsplitscb will continue in an undefined manner. + */ +int bsplitstrcb (const_bstring str, const_bstring splitStr, int pos, + int (* cb) (void * parm, int ofs, int len), void * parm) { +int i, p, ret; + + if (cb == NULL || str == NULL || pos < 0 || pos > str->slen + || splitStr == NULL || splitStr->slen < 0) return BSTR_ERR; + + if (0 == splitStr->slen) { + for (i=pos; i < str->slen; i++) { + if ((ret = cb (parm, i, 1)) < 0) return ret; + } + return BSTR_OK; + } + + if (splitStr->slen == 1) + return bsplitcb (str, splitStr->data[0], pos, cb, parm); + + for (i=p=pos; i <= str->slen - splitStr->slen; i++) { + if (0 == bstr__memcmp (splitStr->data, str->data + i, splitStr->slen)) { + if ((ret = cb (parm, p, i - p)) < 0) return ret; + i += splitStr->slen; + p = i; + } + } + if ((ret = cb (parm, p, str->slen - p)) < 0) return ret; + return BSTR_OK; +} + +struct genBstrList { + bstring b; + struct bstrList * bl; +}; + +static int bscb (void * parm, int ofs, int len) { +struct genBstrList * g = (struct genBstrList *) parm; + if (g->bl->qty >= g->bl->mlen) { + int mlen = g->bl->mlen * 2; + bstring * tbl; + + while (g->bl->qty >= mlen) { + if (mlen < g->bl->mlen) return BSTR_ERR; + mlen += mlen; + } + + tbl = (bstring *) bstr__realloc (g->bl->entry, sizeof (bstring) * mlen); + if (tbl == NULL) return BSTR_ERR; + + g->bl->entry = tbl; + g->bl->mlen = mlen; + } + + g->bl->entry[g->bl->qty] = bmidstr (g->b, ofs, len); + g->bl->qty++; + return BSTR_OK; +} + +/* struct bstrList * bsplit (const_bstring str, unsigned char splitChar) + * + * Create an array of sequential substrings from str divided by the character + * splitChar. + */ +struct bstrList * bsplit (const_bstring str, unsigned char splitChar) { +struct genBstrList g; + + if (str == NULL || str->data == NULL || str->slen < 0) return NULL; + + g.bl = (struct bstrList *) bstr__alloc (sizeof (struct bstrList)); + if (g.bl == NULL) return NULL; + g.bl->mlen = 4; + g.bl->entry = (bstring *) bstr__alloc (g.bl->mlen * sizeof (bstring)); + if (NULL == g.bl->entry) { + bstr__free (g.bl); + return NULL; + } + + g.b = (bstring) str; + g.bl->qty = 0; + if (bsplitcb (str, splitChar, 0, bscb, &g) < 0) { + bstrListDestroy (g.bl); + return NULL; + } + return g.bl; +} + +/* struct bstrList * bsplitstr (const_bstring str, const_bstring splitStr) + * + * Create an array of sequential substrings from str divided by the entire + * substring splitStr. + */ +struct bstrList * bsplitstr (const_bstring str, const_bstring splitStr) { +struct genBstrList g; + + if (str == NULL || str->data == NULL || str->slen < 0) return NULL; + + g.bl = (struct bstrList *) bstr__alloc (sizeof (struct bstrList)); + if (g.bl == NULL) return NULL; + g.bl->mlen = 4; + g.bl->entry = (bstring *) bstr__alloc (g.bl->mlen * sizeof (bstring)); + if (NULL == g.bl->entry) { + bstr__free (g.bl); + return NULL; + } + + g.b = (bstring) str; + g.bl->qty = 0; + if (bsplitstrcb (str, splitStr, 0, bscb, &g) < 0) { + bstrListDestroy (g.bl); + return NULL; + } + return g.bl; +} + +/* struct bstrList * bsplits (const_bstring str, bstring splitStr) + * + * Create an array of sequential substrings from str divided by any of the + * characters in splitStr. An empty splitStr causes a single entry bstrList + * containing a copy of str to be returned. + */ +struct bstrList * bsplits (const_bstring str, const_bstring splitStr) { +struct genBstrList g; + + if ( str == NULL || str->slen < 0 || str->data == NULL || + splitStr == NULL || splitStr->slen < 0 || splitStr->data == NULL) + return NULL; + + g.bl = (struct bstrList *) bstr__alloc (sizeof (struct bstrList)); + if (g.bl == NULL) return NULL; + g.bl->mlen = 4; + g.bl->entry = (bstring *) bstr__alloc (g.bl->mlen * sizeof (bstring)); + if (NULL == g.bl->entry) { + bstr__free (g.bl); + return NULL; + } + g.b = (bstring) str; + g.bl->qty = 0; + + if (bsplitscb (str, splitStr, 0, bscb, &g) < 0) { + bstrListDestroy (g.bl); + return NULL; + } + return g.bl; +} + +#if defined (__TURBOC__) && !defined (__BORLANDC__) +# ifndef BSTRLIB_NOVSNP +# define BSTRLIB_NOVSNP +# endif +#endif + +/* Give WATCOM C/C++, MSVC some latitude for their non-support of vsnprintf */ +#if defined(__WATCOMC__) || defined(_MSC_VER) +#define exvsnprintf(r,b,n,f,a) {r = _vsnprintf (b,n,f,a);} +#else +#ifdef BSTRLIB_NOVSNP +/* This is just a hack. If you are using a system without a vsnprintf, it is + not recommended that bformat be used at all. */ +#define exvsnprintf(r,b,n,f,a) {vsprintf (b,f,a); r = -1;} +#define START_VSNBUFF (256) +#else + +#ifdef __GNUC__ +/* Something is making gcc complain about this prototype not being here, so + I've just gone ahead and put it in. */ +extern int vsnprintf (char *buf, size_t count, const char *format, va_list arg); +#endif + +#define exvsnprintf(r,b,n,f,a) {r = vsnprintf (b,n,f,a);} +#endif +#endif + +#if !defined (BSTRLIB_NOVSNP) + +#ifndef START_VSNBUFF +#define START_VSNBUFF (16) +#endif + +/* On IRIX vsnprintf returns n-1 when the operation would overflow the target + buffer, WATCOM and MSVC both return -1, while C99 requires that the + returned value be exactly what the length would be if the buffer would be + large enough. This leads to the idea that if the return value is larger + than n, then changing n to the return value will reduce the number of + iterations required. */ + +/* int bformata (bstring b, const char * fmt, ...) + * + * After the first parameter, it takes the same parameters as printf (), but + * rather than outputting results to stdio, it appends the results to + * a bstring which contains what would have been output. Note that if there + * is an early generation of a '\0' character, the bstring will be truncated + * to this end point. + */ +int bformata (bstring b, const char * fmt, ...) { +va_list arglist; +bstring buff; +int n, r; + + if (b == NULL || fmt == NULL || b->data == NULL || b->mlen <= 0 + || b->slen < 0 || b->slen > b->mlen) return BSTR_ERR; + + /* Since the length is not determinable beforehand, a search is + performed using the truncating "vsnprintf" call (to avoid buffer + overflows) on increasing potential sizes for the output result. */ + + if ((n = (int) (2*strlen (fmt))) < START_VSNBUFF) n = START_VSNBUFF; + if (NULL == (buff = bfromcstralloc (n + 2, ""))) { + n = 1; + if (NULL == (buff = bfromcstralloc (n + 2, ""))) return BSTR_ERR; + } + + for (;;) { + va_start (arglist, fmt); + exvsnprintf (r, (char *) buff->data, n + 1, fmt, arglist); + va_end (arglist); + + buff->data[n] = (unsigned char) '\0'; + buff->slen = (int) (strlen) ((char *) buff->data); + + if (buff->slen < n) break; + + if (r > n) n = r; else n += n; + + if (BSTR_OK != balloc (buff, n + 2)) { + bdestroy (buff); + return BSTR_ERR; + } + } + + r = bconcat (b, buff); + bdestroy (buff); + return r; +} + +/* int bassignformat (bstring b, const char * fmt, ...) + * + * After the first parameter, it takes the same parameters as printf (), but + * rather than outputting results to stdio, it outputs the results to + * the bstring parameter b. Note that if there is an early generation of a + * '\0' character, the bstring will be truncated to this end point. + */ +int bassignformat (bstring b, const char * fmt, ...) { +va_list arglist; +bstring buff; +int n, r; + + if (b == NULL || fmt == NULL || b->data == NULL || b->mlen <= 0 + || b->slen < 0 || b->slen > b->mlen) return BSTR_ERR; + + /* Since the length is not determinable beforehand, a search is + performed using the truncating "vsnprintf" call (to avoid buffer + overflows) on increasing potential sizes for the output result. */ + + if ((n = (int) (2*strlen (fmt))) < START_VSNBUFF) n = START_VSNBUFF; + if (NULL == (buff = bfromcstralloc (n + 2, ""))) { + n = 1; + if (NULL == (buff = bfromcstralloc (n + 2, ""))) return BSTR_ERR; + } + + for (;;) { + va_start (arglist, fmt); + exvsnprintf (r, (char *) buff->data, n + 1, fmt, arglist); + va_end (arglist); + + buff->data[n] = (unsigned char) '\0'; + buff->slen = (int) (strlen) ((char *) buff->data); + + if (buff->slen < n) break; + + if (r > n) n = r; else n += n; + + if (BSTR_OK != balloc (buff, n + 2)) { + bdestroy (buff); + return BSTR_ERR; + } + } + + r = bassign (b, buff); + bdestroy (buff); + return r; +} + +/* bstring bformat (const char * fmt, ...) + * + * Takes the same parameters as printf (), but rather than outputting results + * to stdio, it forms a bstring which contains what would have been output. + * Note that if there is an early generation of a '\0' character, the + * bstring will be truncated to this end point. + */ +bstring bformat (const char * fmt, ...) { +va_list arglist; +bstring buff; +int n, r; + + if (fmt == NULL) return NULL; + + /* Since the length is not determinable beforehand, a search is + performed using the truncating "vsnprintf" call (to avoid buffer + overflows) on increasing potential sizes for the output result. */ + + if ((n = (int) (2*strlen (fmt))) < START_VSNBUFF) n = START_VSNBUFF; + if (NULL == (buff = bfromcstralloc (n + 2, ""))) { + n = 1; + if (NULL == (buff = bfromcstralloc (n + 2, ""))) return NULL; + } + + for (;;) { + va_start (arglist, fmt); + exvsnprintf (r, (char *) buff->data, n + 1, fmt, arglist); + va_end (arglist); + + buff->data[n] = (unsigned char) '\0'; + buff->slen = (int) (strlen) ((char *) buff->data); + + if (buff->slen < n) break; + + if (r > n) n = r; else n += n; + + if (BSTR_OK != balloc (buff, n + 2)) { + bdestroy (buff); + return NULL; + } + } + + return buff; +} + +/* int bvcformata (bstring b, int count, const char * fmt, va_list arglist) + * + * The bvcformata function formats data under control of the format control + * string fmt and attempts to append the result to b. The fmt parameter is + * the same as that of the printf function. The variable argument list is + * replaced with arglist, which has been initialized by the va_start macro. + * The size of the output is upper bounded by count. If the required output + * exceeds count, the string b is not augmented with any contents and a value + * below BSTR_ERR is returned. If a value below -count is returned then it + * is recommended that the negative of this value be used as an update to the + * count in a subsequent pass. On other errors, such as running out of + * memory, parameter errors or numeric wrap around BSTR_ERR is returned. + * BSTR_OK is returned when the output is successfully generated and + * appended to b. + * + * Note: There is no sanity checking of arglist, and this function is + * destructive of the contents of b from the b->slen point onward. If there + * is an early generation of a '\0' character, the bstring will be truncated + * to this end point. + */ +int bvcformata (bstring b, int count, const char * fmt, va_list arg) { +int n, r, l; + + if (b == NULL || fmt == NULL || count <= 0 || b->data == NULL + || b->mlen <= 0 || b->slen < 0 || b->slen > b->mlen) return BSTR_ERR; + + if (count > (n = b->slen + count) + 2) return BSTR_ERR; + if (BSTR_OK != balloc (b, n + 2)) return BSTR_ERR; + + exvsnprintf (r, (char *) b->data + b->slen, count + 2, fmt, arg); + + /* Did the operation complete successfully within bounds? */ + + if (n >= (l = b->slen + (int) (strlen) ((const char *) b->data + b->slen))) { + b->slen = l; + return BSTR_OK; + } + + /* Abort, since the buffer was not large enough. The return value + tries to help set what the retry length should be. */ + + b->data[b->slen] = '\0'; + if (r > count+1) l = r; else { + l = count+count; + if (count > l) l = INT_MAX; + } + n = -l; + if (n > BSTR_ERR-1) n = BSTR_ERR-1; + return n; +} + +#endif diff --git a/libatalk/util/Makefile.am b/libatalk/util/Makefile.am index f8eeb6b4..52597e9c 100644 --- a/libatalk/util/Makefile.am +++ b/libatalk/util/Makefile.am @@ -14,6 +14,7 @@ libutil_la_SOURCES = \ locking.c \ logger.c \ module.c \ + queue.c \ server_child.c \ server_ipc.c \ server_lock.c \ diff --git a/libatalk/util/queue.c b/libatalk/util/queue.c new file mode 100644 index 00000000..b7b697f4 --- /dev/null +++ b/libatalk/util/queue.c @@ -0,0 +1,98 @@ +/* + $Id: queue.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +/*! + * @file + * Netatalk utility functions: queue + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include + +#include + +static qnode_t *alloc_init_node(void *data) +{ + qnode_t *node; + if ((node = malloc(sizeof(qnode_t))) == NULL) + return NULL; + node->data = data; + + return node; +} + +/******************************************************************************** + * Interface + *******************************************************************************/ + +queue_t *queue_init(void) +{ + queue_t *queue; + + if ((queue = alloc_init_node(NULL)) == NULL) + return NULL; + + queue->prev = queue->next = queue; + return queue; +} + +qnode_t *enqueue(queue_t *q, void *data) +{ + qnode_t *node; + + if ((node = alloc_init_node(data)) == NULL) + return NULL; + + /* insert at tail */ + node->next = q; + node->prev = q->prev; + q->prev->next = node; + q->prev = node; + + return node; +} + +void *dequeue(queue_t *q) +{ + qnode_t *node; + void *data; + + if (q == NULL || q->next == q) + return NULL; + + /* take first node from head */ + node = q->next; + data = node->data; + q->next = node->next; + node->next->prev = node->prev; + free(node); + + return data; +} + +void queue_destroy(queue_t *q, void (*callback)(void *)) +{ + void *p; + + while ((p = dequeue(q)) != NULL) + callback(p); + + free(q); + q = NULL; +} + diff --git a/test/.cvsignore b/test/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/test/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 00000000..bfd92886 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = afpd diff --git a/test/afpd/.cvsignore b/test/afpd/.cvsignore new file mode 100644 index 00000000..6c97d20b --- /dev/null +++ b/test/afpd/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +.deps +.libs +test.conf +test.default \ No newline at end of file diff --git a/test/afpd/Makefile b/test/afpd/Makefile new file mode 100644 index 00000000..e827d5a6 --- /dev/null +++ b/test/afpd/Makefile @@ -0,0 +1,1115 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# test/afpd/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +# Makefile.am for test/afpd/ + + +pkgdatadir = $(datadir)/netatalk +pkglibdir = $(libdir)/netatalk +pkgincludedir = $(includedir)/netatalk +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = x86_64-unknown-linux-gnu +host_triplet = x86_64-unknown-linux-gnu +target_triplet = x86_64-unknown-linux-gnu +TESTS = test.sh test$(EXEEXT) +check_PROGRAMS = test$(EXEEXT) +subdir = test/afpd +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/afs-check.m4 \ + $(top_srcdir)/macros/cnid-backend.m4 \ + $(top_srcdir)/macros/config-checks.m4 \ + $(top_srcdir)/macros/cups.m4 $(top_srcdir)/macros/db3-check.m4 \ + $(top_srcdir)/macros/grep-check.m4 \ + $(top_srcdir)/macros/gssapi-check.m4 \ + $(top_srcdir)/macros/iconv.m4 \ + $(top_srcdir)/macros/largefile-check.m4 \ + $(top_srcdir)/macros/libgcrypt.m4 \ + $(top_srcdir)/macros/pam-check.m4 \ + $(top_srcdir)/macros/perl-check.m4 \ + $(top_srcdir)/macros/ps-check.m4 \ + $(top_srcdir)/macros/quota-check.m4 \ + $(top_srcdir)/macros/snprintf-check.m4 \ + $(top_srcdir)/macros/srvloc.m4 \ + $(top_srcdir)/macros/ssl-check.m4 \ + $(top_srcdir)/macros/summary.m4 \ + $(top_srcdir)/macros/tcp-wrappers.m4 \ + $(top_srcdir)/macros/util.m4 $(top_srcdir)/macros/webmin.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_test_OBJECTS = test-test.$(OBJEXT) test-subtests.$(OBJEXT) \ + test-afpfunc_helpers.$(OBJEXT) test-afp_config.$(OBJEXT) \ + test-afp_dsi.$(OBJEXT) test-afp_options.$(OBJEXT) \ + test-afp_util.$(OBJEXT) test-afprun.$(OBJEXT) \ + test-appl.$(OBJEXT) test-auth.$(OBJEXT) \ + test-catsearch.$(OBJEXT) test-desktop.$(OBJEXT) \ + test-dircache.$(OBJEXT) test-directory.$(OBJEXT) \ + test-enumerate.$(OBJEXT) test-extattrs.$(OBJEXT) \ + test-file.$(OBJEXT) test-filedir.$(OBJEXT) test-fork.$(OBJEXT) \ + test-gettok.$(OBJEXT) test-hash.$(OBJEXT) \ + test-mangle.$(OBJEXT) test-messages.$(OBJEXT) \ + test-nfsquota.$(OBJEXT) test-ofork.$(OBJEXT) \ + test-quota.$(OBJEXT) test-status.$(OBJEXT) \ + test-switch.$(OBJEXT) test-uam.$(OBJEXT) test-unix.$(OBJEXT) \ + test-volume.$(OBJEXT) +test_OBJECTS = $(am_test_OBJECTS) +test_DEPENDENCIES = $(top_builddir)/libatalk/libatalk.la \ + $(top_builddir)/libatalk/cnid/libcnid.la +test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(test_CFLAGS) $(CFLAGS) $(test_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I. -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(test_SOURCES) +DIST_SOURCES = $(test_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/ralph/netatalk/dir-rewrite/missing --run aclocal-1.10 +AFS_CFLAGS = +AFS_LIBS = +AMTAR = ${SHELL} /home/ralph/netatalk/dir-rewrite/missing --run tar +AR = ar +AUTOCONF = ${SHELL} /home/ralph/netatalk/dir-rewrite/missing --run autoconf +AUTOHEADER = ${SHELL} /home/ralph/netatalk/dir-rewrite/missing --run autoheader +AUTOMAKE = ${SHELL} /home/ralph/netatalk/dir-rewrite/missing --run automake-1.10 +AWK = gawk +BDB_BIN = /usr/local/BerkeleyDB.4.8/bin +BDB_CFLAGS = -I/usr/local/BerkeleyDB.4.8/include/ +BDB_LIBS = -L/usr/local/BerkeleyDB.4.8/lib -ldb-4.8 +BDB_PATH = /usr/local/BerkeleyDB.4.8 +CC = gcc -std=gnu99 +CCDEPMODE = depmode=gcc3 +CFLAGS = -I$(top_srcdir)/include -D_U_="__attribute__((unused))" -g -O0 -Wall -D_PATH_LOCKDIR=\"/usr/local/netatalk/var/run/\" -I$(top_srcdir)/sys +COMPILE_64BIT_KMODULE = +COMPILE_KERNEL_GCC = +CPP = gcc -std=gnu99 -E +CPPFLAGS = +CRYPT_LIBS = -lcrypt +CUPS_CFLAGS = +CUPS_CONFIG = +CUPS_LDFLAGS = +CUPS_LIBS = +CXX = g++ +CXXCPP = g++ -E +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -g -O2 +CYGPATH_W = echo +DEFAULT_CNID_SCHEME = dbd +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DSYMUTIL = +ECHO = echo +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +F77 = +FFLAGS = +GREP = /bin/grep +GSSAPI_CFLAGS = -I/usr/include +GSSAPI_LIBS = -lgssapi -L/usr/lib -lgssapi -lheimntlm -lkrb5 +ICONV_CFLAGS = +ICONV_LIBS = +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +KCFLAGS = +KLDFLAGS = +KRB5_CONFIG = /usr/bin/krb5-config +LDFLAGS = +LIBADD_DL = -ldl +LIBATALK_ACLS = +LIBGCRYPT_CFLAGS = +LIBGCRYPT_CONFIG = /usr/bin/libgcrypt-config +LIBGCRYPT_LIBS = -lgcrypt +LIBOBJS = +LIBS = -L$(top_srcdir)/libatalk +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LN_S = ln -s +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/ralph/netatalk/dir-rewrite/missing --run makeinfo +MKDIR_P = /bin/mkdir -p +NETATALK_VERSION = 2.1dev +NMEDIT = +OBJEXT = o +OVERWRITE_CONFIG = no +PACKAGE = netatalk +PACKAGE_BUGREPORT = +PACKAGE_NAME = +PACKAGE_STRING = +PACKAGE_TARNAME = +PACKAGE_VERSION = +PAMDIR = / +PAM_ACCOUNT = common-account +PAM_AUTH = common-auth +PAM_CFLAGS = +PAM_DIRECTIVE = include +PAM_LIBS = -lpam +PAM_PASSWORD = common-password +PAM_SESSION = common-session +PATH_SEPARATOR = : +PERL = /usr/bin/perl +PKGCONFDIR = ${prefix}/etc/netatalk +PS = /bin/ps +QUOTA_LIBS = -lrpcsvc +RANLIB = ranlib +SED = /bin/sed +SERVERTEXT = ${prefix}/etc/netatalk/msg +SET_MAKE = +SHELL = /bin/sh +SLP_CFLAGS = +SLP_LIBS = +SPOOLDIR = ${prefix}/var/spool/netatalk +SSL_CFLAGS = -I/usr/include/openssl +SSL_LIBS = -L/usr/lib64 -lcrypto +STRIP = strip +UAMS_PATH = ${prefix}/etc/netatalk/uams +VERSION = 2.1dev +WEBMIN_PASS = +WEBMIN_PATH = +WEBMIN_PORT = +WEBMIN_USER = +WEBMIN_VERSION = +WRAP_LIBS = +abs_builddir = /home/ralph/netatalk/dir-rewrite/test/afpd +abs_srcdir = /home/ralph/netatalk/dir-rewrite/test/afpd +abs_top_builddir = /home/ralph/netatalk/dir-rewrite +abs_top_srcdir = /home/ralph/netatalk/dir-rewrite +ac_ct_CC = gcc +ac_ct_CXX = g++ +ac_ct_F77 = +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-linux-gnu +build_alias = +build_cpu = x86_64 +build_os = linux-gnu +build_vendor = unknown +builddir = . +compiled_backends = dbd cdb last +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-unknown-linux-gnu +host_alias = +host_cpu = x86_64 +host_os = linux-gnu +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = $(SHELL) /home/ralph/netatalk/dir-rewrite/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = /bin/mkdir -p +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local/netatalk +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target = x86_64-unknown-linux-gnu +target_alias = +target_cpu = x86_64 +target_os = linux-gnu +target_vendor = unknown +top_builddir = ../.. +top_srcdir = ../.. +pkgconfdir = ${prefix}/etc/netatalk +noinst_HEADERS = test.h subtests.h afpfunc_helpers.h +test_SOURCES = test.c subtests.c afpfunc_helpers.c \ + $(top_builddir)/etc/afpd/afp_config.c \ + $(top_builddir)/etc/afpd/afp_dsi.c \ + $(top_builddir)/etc/afpd/afp_options.c \ + $(top_builddir)/etc/afpd/afp_util.c \ + $(top_builddir)/etc/afpd/afprun.c \ + $(top_builddir)/etc/afpd/appl.c \ + $(top_builddir)/etc/afpd/auth.c \ + $(top_builddir)/etc/afpd/catsearch.c \ + $(top_builddir)/etc/afpd/desktop.c \ + $(top_builddir)/etc/afpd/dircache.c \ + $(top_builddir)/etc/afpd/directory.c \ + $(top_builddir)/etc/afpd/enumerate.c \ + $(top_builddir)/etc/afpd/extattrs.c \ + $(top_builddir)/etc/afpd/file.c \ + $(top_builddir)/etc/afpd/filedir.c \ + $(top_builddir)/etc/afpd/fork.c \ + $(top_builddir)/etc/afpd/gettok.c \ + $(top_builddir)/etc/afpd/hash.c \ + $(top_builddir)/etc/afpd/mangle.c \ + $(top_builddir)/etc/afpd/messages.c \ + $(top_builddir)/etc/afpd/nfsquota.c \ + $(top_builddir)/etc/afpd/ofork.c \ + $(top_builddir)/etc/afpd/quota.c \ + $(top_builddir)/etc/afpd/status.c \ + $(top_builddir)/etc/afpd/switch.c \ + $(top_builddir)/etc/afpd/uam.c \ + $(top_builddir)/etc/afpd/unix.c \ + $(top_builddir)/etc/afpd/volume.c + +test_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/etc/afpd \ + \ + -D_PATH_AFPDDEFVOL=\"$(pkgconfdir)/AppleVolumes.default\" \ + -D_PATH_AFPDSYSVOL=\"$(pkgconfdir)/AppleVolumes.system\" \ + -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \ + -D_PATH_AFPDCONF=\"$(pkgconfdir)/afpd.conf\" \ + -D_PATH_AFPDUAMPATH=\"$(UAMS_PATH)/\" \ + -D_PATH_ACL_LDAPCONF=\"$(pkgconfdir)/afp_ldap.conf\" \ + -DAPPLCNAME \ + -DSERVERTEXT=\"$(SERVERTEXT)/\" + +test_LDADD = $(top_builddir)/libatalk/libatalk.la $(top_builddir)/libatalk/cnid/libcnid.la -lrpcsvc -ldl +test_LDFLAGS = -export-dynamic +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/afpd/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/afpd/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) + @rm -f test$(EXEEXT) + $(test_LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/test-afp_config.Po +include ./$(DEPDIR)/test-afp_dsi.Po +include ./$(DEPDIR)/test-afp_options.Po +include ./$(DEPDIR)/test-afp_util.Po +include ./$(DEPDIR)/test-afpfunc_helpers.Po +include ./$(DEPDIR)/test-afprun.Po +include ./$(DEPDIR)/test-appl.Po +include ./$(DEPDIR)/test-auth.Po +include ./$(DEPDIR)/test-catsearch.Po +include ./$(DEPDIR)/test-desktop.Po +include ./$(DEPDIR)/test-dircache.Po +include ./$(DEPDIR)/test-directory.Po +include ./$(DEPDIR)/test-enumerate.Po +include ./$(DEPDIR)/test-extattrs.Po +include ./$(DEPDIR)/test-file.Po +include ./$(DEPDIR)/test-filedir.Po +include ./$(DEPDIR)/test-fork.Po +include ./$(DEPDIR)/test-gettok.Po +include ./$(DEPDIR)/test-hash.Po +include ./$(DEPDIR)/test-mangle.Po +include ./$(DEPDIR)/test-messages.Po +include ./$(DEPDIR)/test-nfsquota.Po +include ./$(DEPDIR)/test-ofork.Po +include ./$(DEPDIR)/test-quota.Po +include ./$(DEPDIR)/test-status.Po +include ./$(DEPDIR)/test-subtests.Po +include ./$(DEPDIR)/test-switch.Po +include ./$(DEPDIR)/test-test.Po +include ./$(DEPDIR)/test-uam.Po +include ./$(DEPDIR)/test-unix.Po +include ./$(DEPDIR)/test-volume.Po + +.c.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(LTCOMPILE) -c -o $@ $< + +test-test.o: test.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-test.o -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c + mv -f $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po +# source='test.c' object='test-test.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c + +test-test.obj: test.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-test.obj -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi` + mv -f $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po +# source='test.c' object='test-test.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi` + +test-subtests.o: subtests.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-subtests.o -MD -MP -MF $(DEPDIR)/test-subtests.Tpo -c -o test-subtests.o `test -f 'subtests.c' || echo '$(srcdir)/'`subtests.c + mv -f $(DEPDIR)/test-subtests.Tpo $(DEPDIR)/test-subtests.Po +# source='subtests.c' object='test-subtests.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-subtests.o `test -f 'subtests.c' || echo '$(srcdir)/'`subtests.c + +test-subtests.obj: subtests.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-subtests.obj -MD -MP -MF $(DEPDIR)/test-subtests.Tpo -c -o test-subtests.obj `if test -f 'subtests.c'; then $(CYGPATH_W) 'subtests.c'; else $(CYGPATH_W) '$(srcdir)/subtests.c'; fi` + mv -f $(DEPDIR)/test-subtests.Tpo $(DEPDIR)/test-subtests.Po +# source='subtests.c' object='test-subtests.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-subtests.obj `if test -f 'subtests.c'; then $(CYGPATH_W) 'subtests.c'; else $(CYGPATH_W) '$(srcdir)/subtests.c'; fi` + +test-afpfunc_helpers.o: afpfunc_helpers.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afpfunc_helpers.o -MD -MP -MF $(DEPDIR)/test-afpfunc_helpers.Tpo -c -o test-afpfunc_helpers.o `test -f 'afpfunc_helpers.c' || echo '$(srcdir)/'`afpfunc_helpers.c + mv -f $(DEPDIR)/test-afpfunc_helpers.Tpo $(DEPDIR)/test-afpfunc_helpers.Po +# source='afpfunc_helpers.c' object='test-afpfunc_helpers.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afpfunc_helpers.o `test -f 'afpfunc_helpers.c' || echo '$(srcdir)/'`afpfunc_helpers.c + +test-afpfunc_helpers.obj: afpfunc_helpers.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afpfunc_helpers.obj -MD -MP -MF $(DEPDIR)/test-afpfunc_helpers.Tpo -c -o test-afpfunc_helpers.obj `if test -f 'afpfunc_helpers.c'; then $(CYGPATH_W) 'afpfunc_helpers.c'; else $(CYGPATH_W) '$(srcdir)/afpfunc_helpers.c'; fi` + mv -f $(DEPDIR)/test-afpfunc_helpers.Tpo $(DEPDIR)/test-afpfunc_helpers.Po +# source='afpfunc_helpers.c' object='test-afpfunc_helpers.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afpfunc_helpers.obj `if test -f 'afpfunc_helpers.c'; then $(CYGPATH_W) 'afpfunc_helpers.c'; else $(CYGPATH_W) '$(srcdir)/afpfunc_helpers.c'; fi` + +test-afp_config.o: $(top_builddir)/etc/afpd/afp_config.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_config.o -MD -MP -MF $(DEPDIR)/test-afp_config.Tpo -c -o test-afp_config.o `test -f '$(top_builddir)/etc/afpd/afp_config.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_config.c + mv -f $(DEPDIR)/test-afp_config.Tpo $(DEPDIR)/test-afp_config.Po +# source='$(top_builddir)/etc/afpd/afp_config.c' object='test-afp_config.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_config.o `test -f '$(top_builddir)/etc/afpd/afp_config.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_config.c + +test-afp_config.obj: $(top_builddir)/etc/afpd/afp_config.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_config.obj -MD -MP -MF $(DEPDIR)/test-afp_config.Tpo -c -o test-afp_config.obj `if test -f '$(top_builddir)/etc/afpd/afp_config.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_config.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_config.c'; fi` + mv -f $(DEPDIR)/test-afp_config.Tpo $(DEPDIR)/test-afp_config.Po +# source='$(top_builddir)/etc/afpd/afp_config.c' object='test-afp_config.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_config.obj `if test -f '$(top_builddir)/etc/afpd/afp_config.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_config.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_config.c'; fi` + +test-afp_dsi.o: $(top_builddir)/etc/afpd/afp_dsi.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_dsi.o -MD -MP -MF $(DEPDIR)/test-afp_dsi.Tpo -c -o test-afp_dsi.o `test -f '$(top_builddir)/etc/afpd/afp_dsi.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_dsi.c + mv -f $(DEPDIR)/test-afp_dsi.Tpo $(DEPDIR)/test-afp_dsi.Po +# source='$(top_builddir)/etc/afpd/afp_dsi.c' object='test-afp_dsi.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_dsi.o `test -f '$(top_builddir)/etc/afpd/afp_dsi.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_dsi.c + +test-afp_dsi.obj: $(top_builddir)/etc/afpd/afp_dsi.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_dsi.obj -MD -MP -MF $(DEPDIR)/test-afp_dsi.Tpo -c -o test-afp_dsi.obj `if test -f '$(top_builddir)/etc/afpd/afp_dsi.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_dsi.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_dsi.c'; fi` + mv -f $(DEPDIR)/test-afp_dsi.Tpo $(DEPDIR)/test-afp_dsi.Po +# source='$(top_builddir)/etc/afpd/afp_dsi.c' object='test-afp_dsi.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_dsi.obj `if test -f '$(top_builddir)/etc/afpd/afp_dsi.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_dsi.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_dsi.c'; fi` + +test-afp_options.o: $(top_builddir)/etc/afpd/afp_options.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_options.o -MD -MP -MF $(DEPDIR)/test-afp_options.Tpo -c -o test-afp_options.o `test -f '$(top_builddir)/etc/afpd/afp_options.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_options.c + mv -f $(DEPDIR)/test-afp_options.Tpo $(DEPDIR)/test-afp_options.Po +# source='$(top_builddir)/etc/afpd/afp_options.c' object='test-afp_options.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_options.o `test -f '$(top_builddir)/etc/afpd/afp_options.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_options.c + +test-afp_options.obj: $(top_builddir)/etc/afpd/afp_options.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_options.obj -MD -MP -MF $(DEPDIR)/test-afp_options.Tpo -c -o test-afp_options.obj `if test -f '$(top_builddir)/etc/afpd/afp_options.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_options.c'; fi` + mv -f $(DEPDIR)/test-afp_options.Tpo $(DEPDIR)/test-afp_options.Po +# source='$(top_builddir)/etc/afpd/afp_options.c' object='test-afp_options.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_options.obj `if test -f '$(top_builddir)/etc/afpd/afp_options.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_options.c'; fi` + +test-afp_util.o: $(top_builddir)/etc/afpd/afp_util.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_util.o -MD -MP -MF $(DEPDIR)/test-afp_util.Tpo -c -o test-afp_util.o `test -f '$(top_builddir)/etc/afpd/afp_util.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_util.c + mv -f $(DEPDIR)/test-afp_util.Tpo $(DEPDIR)/test-afp_util.Po +# source='$(top_builddir)/etc/afpd/afp_util.c' object='test-afp_util.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_util.o `test -f '$(top_builddir)/etc/afpd/afp_util.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_util.c + +test-afp_util.obj: $(top_builddir)/etc/afpd/afp_util.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_util.obj -MD -MP -MF $(DEPDIR)/test-afp_util.Tpo -c -o test-afp_util.obj `if test -f '$(top_builddir)/etc/afpd/afp_util.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_util.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_util.c'; fi` + mv -f $(DEPDIR)/test-afp_util.Tpo $(DEPDIR)/test-afp_util.Po +# source='$(top_builddir)/etc/afpd/afp_util.c' object='test-afp_util.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_util.obj `if test -f '$(top_builddir)/etc/afpd/afp_util.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_util.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_util.c'; fi` + +test-afprun.o: $(top_builddir)/etc/afpd/afprun.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afprun.o -MD -MP -MF $(DEPDIR)/test-afprun.Tpo -c -o test-afprun.o `test -f '$(top_builddir)/etc/afpd/afprun.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afprun.c + mv -f $(DEPDIR)/test-afprun.Tpo $(DEPDIR)/test-afprun.Po +# source='$(top_builddir)/etc/afpd/afprun.c' object='test-afprun.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afprun.o `test -f '$(top_builddir)/etc/afpd/afprun.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afprun.c + +test-afprun.obj: $(top_builddir)/etc/afpd/afprun.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afprun.obj -MD -MP -MF $(DEPDIR)/test-afprun.Tpo -c -o test-afprun.obj `if test -f '$(top_builddir)/etc/afpd/afprun.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afprun.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afprun.c'; fi` + mv -f $(DEPDIR)/test-afprun.Tpo $(DEPDIR)/test-afprun.Po +# source='$(top_builddir)/etc/afpd/afprun.c' object='test-afprun.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afprun.obj `if test -f '$(top_builddir)/etc/afpd/afprun.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afprun.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afprun.c'; fi` + +test-appl.o: $(top_builddir)/etc/afpd/appl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-appl.o -MD -MP -MF $(DEPDIR)/test-appl.Tpo -c -o test-appl.o `test -f '$(top_builddir)/etc/afpd/appl.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/appl.c + mv -f $(DEPDIR)/test-appl.Tpo $(DEPDIR)/test-appl.Po +# source='$(top_builddir)/etc/afpd/appl.c' object='test-appl.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-appl.o `test -f '$(top_builddir)/etc/afpd/appl.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/appl.c + +test-appl.obj: $(top_builddir)/etc/afpd/appl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-appl.obj -MD -MP -MF $(DEPDIR)/test-appl.Tpo -c -o test-appl.obj `if test -f '$(top_builddir)/etc/afpd/appl.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/appl.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/appl.c'; fi` + mv -f $(DEPDIR)/test-appl.Tpo $(DEPDIR)/test-appl.Po +# source='$(top_builddir)/etc/afpd/appl.c' object='test-appl.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-appl.obj `if test -f '$(top_builddir)/etc/afpd/appl.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/appl.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/appl.c'; fi` + +test-auth.o: $(top_builddir)/etc/afpd/auth.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-auth.o -MD -MP -MF $(DEPDIR)/test-auth.Tpo -c -o test-auth.o `test -f '$(top_builddir)/etc/afpd/auth.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/auth.c + mv -f $(DEPDIR)/test-auth.Tpo $(DEPDIR)/test-auth.Po +# source='$(top_builddir)/etc/afpd/auth.c' object='test-auth.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-auth.o `test -f '$(top_builddir)/etc/afpd/auth.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/auth.c + +test-auth.obj: $(top_builddir)/etc/afpd/auth.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-auth.obj -MD -MP -MF $(DEPDIR)/test-auth.Tpo -c -o test-auth.obj `if test -f '$(top_builddir)/etc/afpd/auth.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/auth.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/auth.c'; fi` + mv -f $(DEPDIR)/test-auth.Tpo $(DEPDIR)/test-auth.Po +# source='$(top_builddir)/etc/afpd/auth.c' object='test-auth.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-auth.obj `if test -f '$(top_builddir)/etc/afpd/auth.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/auth.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/auth.c'; fi` + +test-catsearch.o: $(top_builddir)/etc/afpd/catsearch.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-catsearch.o -MD -MP -MF $(DEPDIR)/test-catsearch.Tpo -c -o test-catsearch.o `test -f '$(top_builddir)/etc/afpd/catsearch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/catsearch.c + mv -f $(DEPDIR)/test-catsearch.Tpo $(DEPDIR)/test-catsearch.Po +# source='$(top_builddir)/etc/afpd/catsearch.c' object='test-catsearch.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-catsearch.o `test -f '$(top_builddir)/etc/afpd/catsearch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/catsearch.c + +test-catsearch.obj: $(top_builddir)/etc/afpd/catsearch.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-catsearch.obj -MD -MP -MF $(DEPDIR)/test-catsearch.Tpo -c -o test-catsearch.obj `if test -f '$(top_builddir)/etc/afpd/catsearch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/catsearch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/catsearch.c'; fi` + mv -f $(DEPDIR)/test-catsearch.Tpo $(DEPDIR)/test-catsearch.Po +# source='$(top_builddir)/etc/afpd/catsearch.c' object='test-catsearch.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-catsearch.obj `if test -f '$(top_builddir)/etc/afpd/catsearch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/catsearch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/catsearch.c'; fi` + +test-desktop.o: $(top_builddir)/etc/afpd/desktop.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-desktop.o -MD -MP -MF $(DEPDIR)/test-desktop.Tpo -c -o test-desktop.o `test -f '$(top_builddir)/etc/afpd/desktop.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/desktop.c + mv -f $(DEPDIR)/test-desktop.Tpo $(DEPDIR)/test-desktop.Po +# source='$(top_builddir)/etc/afpd/desktop.c' object='test-desktop.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-desktop.o `test -f '$(top_builddir)/etc/afpd/desktop.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/desktop.c + +test-desktop.obj: $(top_builddir)/etc/afpd/desktop.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-desktop.obj -MD -MP -MF $(DEPDIR)/test-desktop.Tpo -c -o test-desktop.obj `if test -f '$(top_builddir)/etc/afpd/desktop.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/desktop.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/desktop.c'; fi` + mv -f $(DEPDIR)/test-desktop.Tpo $(DEPDIR)/test-desktop.Po +# source='$(top_builddir)/etc/afpd/desktop.c' object='test-desktop.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-desktop.obj `if test -f '$(top_builddir)/etc/afpd/desktop.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/desktop.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/desktop.c'; fi` + +test-dircache.o: $(top_builddir)/etc/afpd/dircache.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-dircache.o -MD -MP -MF $(DEPDIR)/test-dircache.Tpo -c -o test-dircache.o `test -f '$(top_builddir)/etc/afpd/dircache.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/dircache.c + mv -f $(DEPDIR)/test-dircache.Tpo $(DEPDIR)/test-dircache.Po +# source='$(top_builddir)/etc/afpd/dircache.c' object='test-dircache.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-dircache.o `test -f '$(top_builddir)/etc/afpd/dircache.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/dircache.c + +test-dircache.obj: $(top_builddir)/etc/afpd/dircache.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-dircache.obj -MD -MP -MF $(DEPDIR)/test-dircache.Tpo -c -o test-dircache.obj `if test -f '$(top_builddir)/etc/afpd/dircache.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/dircache.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/dircache.c'; fi` + mv -f $(DEPDIR)/test-dircache.Tpo $(DEPDIR)/test-dircache.Po +# source='$(top_builddir)/etc/afpd/dircache.c' object='test-dircache.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-dircache.obj `if test -f '$(top_builddir)/etc/afpd/dircache.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/dircache.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/dircache.c'; fi` + +test-directory.o: $(top_builddir)/etc/afpd/directory.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-directory.o -MD -MP -MF $(DEPDIR)/test-directory.Tpo -c -o test-directory.o `test -f '$(top_builddir)/etc/afpd/directory.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/directory.c + mv -f $(DEPDIR)/test-directory.Tpo $(DEPDIR)/test-directory.Po +# source='$(top_builddir)/etc/afpd/directory.c' object='test-directory.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-directory.o `test -f '$(top_builddir)/etc/afpd/directory.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/directory.c + +test-directory.obj: $(top_builddir)/etc/afpd/directory.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-directory.obj -MD -MP -MF $(DEPDIR)/test-directory.Tpo -c -o test-directory.obj `if test -f '$(top_builddir)/etc/afpd/directory.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/directory.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/directory.c'; fi` + mv -f $(DEPDIR)/test-directory.Tpo $(DEPDIR)/test-directory.Po +# source='$(top_builddir)/etc/afpd/directory.c' object='test-directory.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-directory.obj `if test -f '$(top_builddir)/etc/afpd/directory.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/directory.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/directory.c'; fi` + +test-enumerate.o: $(top_builddir)/etc/afpd/enumerate.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-enumerate.o -MD -MP -MF $(DEPDIR)/test-enumerate.Tpo -c -o test-enumerate.o `test -f '$(top_builddir)/etc/afpd/enumerate.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/enumerate.c + mv -f $(DEPDIR)/test-enumerate.Tpo $(DEPDIR)/test-enumerate.Po +# source='$(top_builddir)/etc/afpd/enumerate.c' object='test-enumerate.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-enumerate.o `test -f '$(top_builddir)/etc/afpd/enumerate.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/enumerate.c + +test-enumerate.obj: $(top_builddir)/etc/afpd/enumerate.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-enumerate.obj -MD -MP -MF $(DEPDIR)/test-enumerate.Tpo -c -o test-enumerate.obj `if test -f '$(top_builddir)/etc/afpd/enumerate.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/enumerate.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/enumerate.c'; fi` + mv -f $(DEPDIR)/test-enumerate.Tpo $(DEPDIR)/test-enumerate.Po +# source='$(top_builddir)/etc/afpd/enumerate.c' object='test-enumerate.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-enumerate.obj `if test -f '$(top_builddir)/etc/afpd/enumerate.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/enumerate.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/enumerate.c'; fi` + +test-extattrs.o: $(top_builddir)/etc/afpd/extattrs.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-extattrs.o -MD -MP -MF $(DEPDIR)/test-extattrs.Tpo -c -o test-extattrs.o `test -f '$(top_builddir)/etc/afpd/extattrs.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/extattrs.c + mv -f $(DEPDIR)/test-extattrs.Tpo $(DEPDIR)/test-extattrs.Po +# source='$(top_builddir)/etc/afpd/extattrs.c' object='test-extattrs.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-extattrs.o `test -f '$(top_builddir)/etc/afpd/extattrs.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/extattrs.c + +test-extattrs.obj: $(top_builddir)/etc/afpd/extattrs.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-extattrs.obj -MD -MP -MF $(DEPDIR)/test-extattrs.Tpo -c -o test-extattrs.obj `if test -f '$(top_builddir)/etc/afpd/extattrs.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/extattrs.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/extattrs.c'; fi` + mv -f $(DEPDIR)/test-extattrs.Tpo $(DEPDIR)/test-extattrs.Po +# source='$(top_builddir)/etc/afpd/extattrs.c' object='test-extattrs.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-extattrs.obj `if test -f '$(top_builddir)/etc/afpd/extattrs.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/extattrs.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/extattrs.c'; fi` + +test-file.o: $(top_builddir)/etc/afpd/file.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-file.o -MD -MP -MF $(DEPDIR)/test-file.Tpo -c -o test-file.o `test -f '$(top_builddir)/etc/afpd/file.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/file.c + mv -f $(DEPDIR)/test-file.Tpo $(DEPDIR)/test-file.Po +# source='$(top_builddir)/etc/afpd/file.c' object='test-file.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-file.o `test -f '$(top_builddir)/etc/afpd/file.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/file.c + +test-file.obj: $(top_builddir)/etc/afpd/file.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-file.obj -MD -MP -MF $(DEPDIR)/test-file.Tpo -c -o test-file.obj `if test -f '$(top_builddir)/etc/afpd/file.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/file.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/file.c'; fi` + mv -f $(DEPDIR)/test-file.Tpo $(DEPDIR)/test-file.Po +# source='$(top_builddir)/etc/afpd/file.c' object='test-file.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-file.obj `if test -f '$(top_builddir)/etc/afpd/file.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/file.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/file.c'; fi` + +test-filedir.o: $(top_builddir)/etc/afpd/filedir.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-filedir.o -MD -MP -MF $(DEPDIR)/test-filedir.Tpo -c -o test-filedir.o `test -f '$(top_builddir)/etc/afpd/filedir.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/filedir.c + mv -f $(DEPDIR)/test-filedir.Tpo $(DEPDIR)/test-filedir.Po +# source='$(top_builddir)/etc/afpd/filedir.c' object='test-filedir.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-filedir.o `test -f '$(top_builddir)/etc/afpd/filedir.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/filedir.c + +test-filedir.obj: $(top_builddir)/etc/afpd/filedir.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-filedir.obj -MD -MP -MF $(DEPDIR)/test-filedir.Tpo -c -o test-filedir.obj `if test -f '$(top_builddir)/etc/afpd/filedir.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/filedir.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/filedir.c'; fi` + mv -f $(DEPDIR)/test-filedir.Tpo $(DEPDIR)/test-filedir.Po +# source='$(top_builddir)/etc/afpd/filedir.c' object='test-filedir.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-filedir.obj `if test -f '$(top_builddir)/etc/afpd/filedir.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/filedir.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/filedir.c'; fi` + +test-fork.o: $(top_builddir)/etc/afpd/fork.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-fork.o -MD -MP -MF $(DEPDIR)/test-fork.Tpo -c -o test-fork.o `test -f '$(top_builddir)/etc/afpd/fork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/fork.c + mv -f $(DEPDIR)/test-fork.Tpo $(DEPDIR)/test-fork.Po +# source='$(top_builddir)/etc/afpd/fork.c' object='test-fork.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-fork.o `test -f '$(top_builddir)/etc/afpd/fork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/fork.c + +test-fork.obj: $(top_builddir)/etc/afpd/fork.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-fork.obj -MD -MP -MF $(DEPDIR)/test-fork.Tpo -c -o test-fork.obj `if test -f '$(top_builddir)/etc/afpd/fork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/fork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/fork.c'; fi` + mv -f $(DEPDIR)/test-fork.Tpo $(DEPDIR)/test-fork.Po +# source='$(top_builddir)/etc/afpd/fork.c' object='test-fork.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-fork.obj `if test -f '$(top_builddir)/etc/afpd/fork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/fork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/fork.c'; fi` + +test-gettok.o: $(top_builddir)/etc/afpd/gettok.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-gettok.o -MD -MP -MF $(DEPDIR)/test-gettok.Tpo -c -o test-gettok.o `test -f '$(top_builddir)/etc/afpd/gettok.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/gettok.c + mv -f $(DEPDIR)/test-gettok.Tpo $(DEPDIR)/test-gettok.Po +# source='$(top_builddir)/etc/afpd/gettok.c' object='test-gettok.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-gettok.o `test -f '$(top_builddir)/etc/afpd/gettok.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/gettok.c + +test-gettok.obj: $(top_builddir)/etc/afpd/gettok.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-gettok.obj -MD -MP -MF $(DEPDIR)/test-gettok.Tpo -c -o test-gettok.obj `if test -f '$(top_builddir)/etc/afpd/gettok.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/gettok.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/gettok.c'; fi` + mv -f $(DEPDIR)/test-gettok.Tpo $(DEPDIR)/test-gettok.Po +# source='$(top_builddir)/etc/afpd/gettok.c' object='test-gettok.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-gettok.obj `if test -f '$(top_builddir)/etc/afpd/gettok.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/gettok.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/gettok.c'; fi` + +test-hash.o: $(top_builddir)/etc/afpd/hash.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-hash.o -MD -MP -MF $(DEPDIR)/test-hash.Tpo -c -o test-hash.o `test -f '$(top_builddir)/etc/afpd/hash.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/hash.c + mv -f $(DEPDIR)/test-hash.Tpo $(DEPDIR)/test-hash.Po +# source='$(top_builddir)/etc/afpd/hash.c' object='test-hash.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-hash.o `test -f '$(top_builddir)/etc/afpd/hash.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/hash.c + +test-hash.obj: $(top_builddir)/etc/afpd/hash.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-hash.obj -MD -MP -MF $(DEPDIR)/test-hash.Tpo -c -o test-hash.obj `if test -f '$(top_builddir)/etc/afpd/hash.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/hash.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/hash.c'; fi` + mv -f $(DEPDIR)/test-hash.Tpo $(DEPDIR)/test-hash.Po +# source='$(top_builddir)/etc/afpd/hash.c' object='test-hash.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-hash.obj `if test -f '$(top_builddir)/etc/afpd/hash.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/hash.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/hash.c'; fi` + +test-mangle.o: $(top_builddir)/etc/afpd/mangle.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-mangle.o -MD -MP -MF $(DEPDIR)/test-mangle.Tpo -c -o test-mangle.o `test -f '$(top_builddir)/etc/afpd/mangle.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/mangle.c + mv -f $(DEPDIR)/test-mangle.Tpo $(DEPDIR)/test-mangle.Po +# source='$(top_builddir)/etc/afpd/mangle.c' object='test-mangle.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-mangle.o `test -f '$(top_builddir)/etc/afpd/mangle.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/mangle.c + +test-mangle.obj: $(top_builddir)/etc/afpd/mangle.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-mangle.obj -MD -MP -MF $(DEPDIR)/test-mangle.Tpo -c -o test-mangle.obj `if test -f '$(top_builddir)/etc/afpd/mangle.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/mangle.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/mangle.c'; fi` + mv -f $(DEPDIR)/test-mangle.Tpo $(DEPDIR)/test-mangle.Po +# source='$(top_builddir)/etc/afpd/mangle.c' object='test-mangle.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-mangle.obj `if test -f '$(top_builddir)/etc/afpd/mangle.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/mangle.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/mangle.c'; fi` + +test-messages.o: $(top_builddir)/etc/afpd/messages.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-messages.o -MD -MP -MF $(DEPDIR)/test-messages.Tpo -c -o test-messages.o `test -f '$(top_builddir)/etc/afpd/messages.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/messages.c + mv -f $(DEPDIR)/test-messages.Tpo $(DEPDIR)/test-messages.Po +# source='$(top_builddir)/etc/afpd/messages.c' object='test-messages.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-messages.o `test -f '$(top_builddir)/etc/afpd/messages.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/messages.c + +test-messages.obj: $(top_builddir)/etc/afpd/messages.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-messages.obj -MD -MP -MF $(DEPDIR)/test-messages.Tpo -c -o test-messages.obj `if test -f '$(top_builddir)/etc/afpd/messages.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/messages.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/messages.c'; fi` + mv -f $(DEPDIR)/test-messages.Tpo $(DEPDIR)/test-messages.Po +# source='$(top_builddir)/etc/afpd/messages.c' object='test-messages.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-messages.obj `if test -f '$(top_builddir)/etc/afpd/messages.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/messages.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/messages.c'; fi` + +test-nfsquota.o: $(top_builddir)/etc/afpd/nfsquota.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-nfsquota.o -MD -MP -MF $(DEPDIR)/test-nfsquota.Tpo -c -o test-nfsquota.o `test -f '$(top_builddir)/etc/afpd/nfsquota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/nfsquota.c + mv -f $(DEPDIR)/test-nfsquota.Tpo $(DEPDIR)/test-nfsquota.Po +# source='$(top_builddir)/etc/afpd/nfsquota.c' object='test-nfsquota.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-nfsquota.o `test -f '$(top_builddir)/etc/afpd/nfsquota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/nfsquota.c + +test-nfsquota.obj: $(top_builddir)/etc/afpd/nfsquota.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-nfsquota.obj -MD -MP -MF $(DEPDIR)/test-nfsquota.Tpo -c -o test-nfsquota.obj `if test -f '$(top_builddir)/etc/afpd/nfsquota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/nfsquota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/nfsquota.c'; fi` + mv -f $(DEPDIR)/test-nfsquota.Tpo $(DEPDIR)/test-nfsquota.Po +# source='$(top_builddir)/etc/afpd/nfsquota.c' object='test-nfsquota.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-nfsquota.obj `if test -f '$(top_builddir)/etc/afpd/nfsquota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/nfsquota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/nfsquota.c'; fi` + +test-ofork.o: $(top_builddir)/etc/afpd/ofork.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-ofork.o -MD -MP -MF $(DEPDIR)/test-ofork.Tpo -c -o test-ofork.o `test -f '$(top_builddir)/etc/afpd/ofork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/ofork.c + mv -f $(DEPDIR)/test-ofork.Tpo $(DEPDIR)/test-ofork.Po +# source='$(top_builddir)/etc/afpd/ofork.c' object='test-ofork.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-ofork.o `test -f '$(top_builddir)/etc/afpd/ofork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/ofork.c + +test-ofork.obj: $(top_builddir)/etc/afpd/ofork.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-ofork.obj -MD -MP -MF $(DEPDIR)/test-ofork.Tpo -c -o test-ofork.obj `if test -f '$(top_builddir)/etc/afpd/ofork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/ofork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/ofork.c'; fi` + mv -f $(DEPDIR)/test-ofork.Tpo $(DEPDIR)/test-ofork.Po +# source='$(top_builddir)/etc/afpd/ofork.c' object='test-ofork.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-ofork.obj `if test -f '$(top_builddir)/etc/afpd/ofork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/ofork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/ofork.c'; fi` + +test-quota.o: $(top_builddir)/etc/afpd/quota.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-quota.o -MD -MP -MF $(DEPDIR)/test-quota.Tpo -c -o test-quota.o `test -f '$(top_builddir)/etc/afpd/quota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/quota.c + mv -f $(DEPDIR)/test-quota.Tpo $(DEPDIR)/test-quota.Po +# source='$(top_builddir)/etc/afpd/quota.c' object='test-quota.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-quota.o `test -f '$(top_builddir)/etc/afpd/quota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/quota.c + +test-quota.obj: $(top_builddir)/etc/afpd/quota.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-quota.obj -MD -MP -MF $(DEPDIR)/test-quota.Tpo -c -o test-quota.obj `if test -f '$(top_builddir)/etc/afpd/quota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/quota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/quota.c'; fi` + mv -f $(DEPDIR)/test-quota.Tpo $(DEPDIR)/test-quota.Po +# source='$(top_builddir)/etc/afpd/quota.c' object='test-quota.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-quota.obj `if test -f '$(top_builddir)/etc/afpd/quota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/quota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/quota.c'; fi` + +test-status.o: $(top_builddir)/etc/afpd/status.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-status.o -MD -MP -MF $(DEPDIR)/test-status.Tpo -c -o test-status.o `test -f '$(top_builddir)/etc/afpd/status.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/status.c + mv -f $(DEPDIR)/test-status.Tpo $(DEPDIR)/test-status.Po +# source='$(top_builddir)/etc/afpd/status.c' object='test-status.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-status.o `test -f '$(top_builddir)/etc/afpd/status.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/status.c + +test-status.obj: $(top_builddir)/etc/afpd/status.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-status.obj -MD -MP -MF $(DEPDIR)/test-status.Tpo -c -o test-status.obj `if test -f '$(top_builddir)/etc/afpd/status.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/status.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/status.c'; fi` + mv -f $(DEPDIR)/test-status.Tpo $(DEPDIR)/test-status.Po +# source='$(top_builddir)/etc/afpd/status.c' object='test-status.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-status.obj `if test -f '$(top_builddir)/etc/afpd/status.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/status.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/status.c'; fi` + +test-switch.o: $(top_builddir)/etc/afpd/switch.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-switch.o -MD -MP -MF $(DEPDIR)/test-switch.Tpo -c -o test-switch.o `test -f '$(top_builddir)/etc/afpd/switch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/switch.c + mv -f $(DEPDIR)/test-switch.Tpo $(DEPDIR)/test-switch.Po +# source='$(top_builddir)/etc/afpd/switch.c' object='test-switch.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-switch.o `test -f '$(top_builddir)/etc/afpd/switch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/switch.c + +test-switch.obj: $(top_builddir)/etc/afpd/switch.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-switch.obj -MD -MP -MF $(DEPDIR)/test-switch.Tpo -c -o test-switch.obj `if test -f '$(top_builddir)/etc/afpd/switch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/switch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/switch.c'; fi` + mv -f $(DEPDIR)/test-switch.Tpo $(DEPDIR)/test-switch.Po +# source='$(top_builddir)/etc/afpd/switch.c' object='test-switch.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-switch.obj `if test -f '$(top_builddir)/etc/afpd/switch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/switch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/switch.c'; fi` + +test-uam.o: $(top_builddir)/etc/afpd/uam.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-uam.o -MD -MP -MF $(DEPDIR)/test-uam.Tpo -c -o test-uam.o `test -f '$(top_builddir)/etc/afpd/uam.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/uam.c + mv -f $(DEPDIR)/test-uam.Tpo $(DEPDIR)/test-uam.Po +# source='$(top_builddir)/etc/afpd/uam.c' object='test-uam.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-uam.o `test -f '$(top_builddir)/etc/afpd/uam.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/uam.c + +test-uam.obj: $(top_builddir)/etc/afpd/uam.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-uam.obj -MD -MP -MF $(DEPDIR)/test-uam.Tpo -c -o test-uam.obj `if test -f '$(top_builddir)/etc/afpd/uam.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/uam.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/uam.c'; fi` + mv -f $(DEPDIR)/test-uam.Tpo $(DEPDIR)/test-uam.Po +# source='$(top_builddir)/etc/afpd/uam.c' object='test-uam.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-uam.obj `if test -f '$(top_builddir)/etc/afpd/uam.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/uam.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/uam.c'; fi` + +test-unix.o: $(top_builddir)/etc/afpd/unix.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-unix.o -MD -MP -MF $(DEPDIR)/test-unix.Tpo -c -o test-unix.o `test -f '$(top_builddir)/etc/afpd/unix.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/unix.c + mv -f $(DEPDIR)/test-unix.Tpo $(DEPDIR)/test-unix.Po +# source='$(top_builddir)/etc/afpd/unix.c' object='test-unix.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-unix.o `test -f '$(top_builddir)/etc/afpd/unix.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/unix.c + +test-unix.obj: $(top_builddir)/etc/afpd/unix.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-unix.obj -MD -MP -MF $(DEPDIR)/test-unix.Tpo -c -o test-unix.obj `if test -f '$(top_builddir)/etc/afpd/unix.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/unix.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/unix.c'; fi` + mv -f $(DEPDIR)/test-unix.Tpo $(DEPDIR)/test-unix.Po +# source='$(top_builddir)/etc/afpd/unix.c' object='test-unix.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-unix.obj `if test -f '$(top_builddir)/etc/afpd/unix.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/unix.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/unix.c'; fi` + +test-volume.o: $(top_builddir)/etc/afpd/volume.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-volume.o -MD -MP -MF $(DEPDIR)/test-volume.Tpo -c -o test-volume.o `test -f '$(top_builddir)/etc/afpd/volume.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/volume.c + mv -f $(DEPDIR)/test-volume.Tpo $(DEPDIR)/test-volume.Po +# source='$(top_builddir)/etc/afpd/volume.c' object='test-volume.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-volume.o `test -f '$(top_builddir)/etc/afpd/volume.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/volume.c + +test-volume.obj: $(top_builddir)/etc/afpd/volume.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-volume.obj -MD -MP -MF $(DEPDIR)/test-volume.Tpo -c -o test-volume.obj `if test -f '$(top_builddir)/etc/afpd/volume.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/volume.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/volume.c'; fi` + mv -f $(DEPDIR)/test-volume.Tpo $(DEPDIR)/test-volume.Po +# source='$(top_builddir)/etc/afpd/volume.c' object='test-volume.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-volume.obj `if test -f '$(top_builddir)/etc/afpd/volume.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/volume.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/volume.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/afpd/Makefile.am b/test/afpd/Makefile.am new file mode 100644 index 00000000..d16737c5 --- /dev/null +++ b/test/afpd/Makefile.am @@ -0,0 +1,52 @@ +# Makefile.am for test/afpd/ + +pkgconfdir = @PKGCONFDIR@ + +TESTS = test.sh test + +check_PROGRAMS = test +noinst_HEADERS = test.h subtests.h afpfunc_helpers.h + +test_SOURCES = test.c subtests.c afpfunc_helpers.c \ + $(top_builddir)/etc/afpd/afp_config.c \ + $(top_builddir)/etc/afpd/afp_dsi.c \ + $(top_builddir)/etc/afpd/afp_options.c \ + $(top_builddir)/etc/afpd/afp_util.c \ + $(top_builddir)/etc/afpd/afprun.c \ + $(top_builddir)/etc/afpd/appl.c \ + $(top_builddir)/etc/afpd/auth.c \ + $(top_builddir)/etc/afpd/catsearch.c \ + $(top_builddir)/etc/afpd/desktop.c \ + $(top_builddir)/etc/afpd/dircache.c \ + $(top_builddir)/etc/afpd/directory.c \ + $(top_builddir)/etc/afpd/enumerate.c \ + $(top_builddir)/etc/afpd/extattrs.c \ + $(top_builddir)/etc/afpd/file.c \ + $(top_builddir)/etc/afpd/filedir.c \ + $(top_builddir)/etc/afpd/fork.c \ + $(top_builddir)/etc/afpd/gettok.c \ + $(top_builddir)/etc/afpd/hash.c \ + $(top_builddir)/etc/afpd/mangle.c \ + $(top_builddir)/etc/afpd/messages.c \ + $(top_builddir)/etc/afpd/nfsquota.c \ + $(top_builddir)/etc/afpd/ofork.c \ + $(top_builddir)/etc/afpd/quota.c \ + $(top_builddir)/etc/afpd/status.c \ + $(top_builddir)/etc/afpd/switch.c \ + $(top_builddir)/etc/afpd/uam.c \ + $(top_builddir)/etc/afpd/unix.c \ + $(top_builddir)/etc/afpd/volume.c + +test_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/etc/afpd \ + @SLP_CFLAGS@ \ + -D_PATH_AFPDDEFVOL=\"$(pkgconfdir)/AppleVolumes.default\" \ + -D_PATH_AFPDSYSVOL=\"$(pkgconfdir)/AppleVolumes.system\" \ + -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \ + -D_PATH_AFPDCONF=\"$(pkgconfdir)/afpd.conf\" \ + -D_PATH_AFPDUAMPATH=\"$(UAMS_PATH)/\" \ + -D_PATH_ACL_LDAPCONF=\"$(pkgconfdir)/afp_ldap.conf\" \ + -DAPPLCNAME \ + -DSERVERTEXT=\"$(SERVERTEXT)/\" + +test_LDADD = $(top_builddir)/libatalk/libatalk.la $(top_builddir)/libatalk/cnid/libcnid.la @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ +test_LDFLAGS = -export-dynamic diff --git a/test/afpd/Makefile.in b/test/afpd/Makefile.in new file mode 100644 index 00000000..9972b6ca --- /dev/null +++ b/test/afpd/Makefile.in @@ -0,0 +1,1115 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Makefile.am for test/afpd/ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +TESTS = test.sh test$(EXEEXT) +check_PROGRAMS = test$(EXEEXT) +subdir = test/afpd +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/macros/afs-check.m4 \ + $(top_srcdir)/macros/cnid-backend.m4 \ + $(top_srcdir)/macros/config-checks.m4 \ + $(top_srcdir)/macros/cups.m4 $(top_srcdir)/macros/db3-check.m4 \ + $(top_srcdir)/macros/grep-check.m4 \ + $(top_srcdir)/macros/gssapi-check.m4 \ + $(top_srcdir)/macros/iconv.m4 \ + $(top_srcdir)/macros/largefile-check.m4 \ + $(top_srcdir)/macros/libgcrypt.m4 \ + $(top_srcdir)/macros/pam-check.m4 \ + $(top_srcdir)/macros/perl-check.m4 \ + $(top_srcdir)/macros/ps-check.m4 \ + $(top_srcdir)/macros/quota-check.m4 \ + $(top_srcdir)/macros/snprintf-check.m4 \ + $(top_srcdir)/macros/srvloc.m4 \ + $(top_srcdir)/macros/ssl-check.m4 \ + $(top_srcdir)/macros/summary.m4 \ + $(top_srcdir)/macros/tcp-wrappers.m4 \ + $(top_srcdir)/macros/util.m4 $(top_srcdir)/macros/webmin.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_test_OBJECTS = test-test.$(OBJEXT) test-subtests.$(OBJEXT) \ + test-afpfunc_helpers.$(OBJEXT) test-afp_config.$(OBJEXT) \ + test-afp_dsi.$(OBJEXT) test-afp_options.$(OBJEXT) \ + test-afp_util.$(OBJEXT) test-afprun.$(OBJEXT) \ + test-appl.$(OBJEXT) test-auth.$(OBJEXT) \ + test-catsearch.$(OBJEXT) test-desktop.$(OBJEXT) \ + test-dircache.$(OBJEXT) test-directory.$(OBJEXT) \ + test-enumerate.$(OBJEXT) test-extattrs.$(OBJEXT) \ + test-file.$(OBJEXT) test-filedir.$(OBJEXT) test-fork.$(OBJEXT) \ + test-gettok.$(OBJEXT) test-hash.$(OBJEXT) \ + test-mangle.$(OBJEXT) test-messages.$(OBJEXT) \ + test-nfsquota.$(OBJEXT) test-ofork.$(OBJEXT) \ + test-quota.$(OBJEXT) test-status.$(OBJEXT) \ + test-switch.$(OBJEXT) test-uam.$(OBJEXT) test-unix.$(OBJEXT) \ + test-volume.$(OBJEXT) +test_OBJECTS = $(am_test_OBJECTS) +test_DEPENDENCIES = $(top_builddir)/libatalk/libatalk.la \ + $(top_builddir)/libatalk/cnid/libcnid.la +test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(test_CFLAGS) $(CFLAGS) $(test_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(test_SOURCES) +DIST_SOURCES = $(test_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AFS_CFLAGS = @AFS_CFLAGS@ +AFS_LIBS = @AFS_LIBS@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BDB_BIN = @BDB_BIN@ +BDB_CFLAGS = @BDB_CFLAGS@ +BDB_LIBS = @BDB_LIBS@ +BDB_PATH = @BDB_PATH@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILE_64BIT_KMODULE = @COMPILE_64BIT_KMODULE@ +COMPILE_KERNEL_GCC = @COMPILE_KERNEL_GCC@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPT_LIBS = @CRYPT_LIBS@ +CUPS_CFLAGS = @CUPS_CFLAGS@ +CUPS_CONFIG = @CUPS_CONFIG@ +CUPS_LDFLAGS = @CUPS_LDFLAGS@ +CUPS_LIBS = @CUPS_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFAULT_CNID_SCHEME = @DEFAULT_CNID_SCHEME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +GSSAPI_CFLAGS = @GSSAPI_CFLAGS@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +ICONV_CFLAGS = @ICONV_CFLAGS@ +ICONV_LIBS = @ICONV_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KCFLAGS = @KCFLAGS@ +KLDFLAGS = @KLDFLAGS@ +KRB5_CONFIG = @KRB5_CONFIG@ +LDFLAGS = @LDFLAGS@ +LIBADD_DL = @LIBADD_DL@ +LIBATALK_ACLS = @LIBATALK_ACLS@ +LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ +LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ +LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NETATALK_VERSION = @NETATALK_VERSION@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +OVERWRITE_CONFIG = @OVERWRITE_CONFIG@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PAMDIR = @PAMDIR@ +PAM_ACCOUNT = @PAM_ACCOUNT@ +PAM_AUTH = @PAM_AUTH@ +PAM_CFLAGS = @PAM_CFLAGS@ +PAM_DIRECTIVE = @PAM_DIRECTIVE@ +PAM_LIBS = @PAM_LIBS@ +PAM_PASSWORD = @PAM_PASSWORD@ +PAM_SESSION = @PAM_SESSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKGCONFDIR = @PKGCONFDIR@ +PS = @PS@ +QUOTA_LIBS = @QUOTA_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SERVERTEXT = @SERVERTEXT@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SLP_CFLAGS = @SLP_CFLAGS@ +SLP_LIBS = @SLP_LIBS@ +SPOOLDIR = @SPOOLDIR@ +SSL_CFLAGS = @SSL_CFLAGS@ +SSL_LIBS = @SSL_LIBS@ +STRIP = @STRIP@ +UAMS_PATH = @UAMS_PATH@ +VERSION = @VERSION@ +WEBMIN_PASS = @WEBMIN_PASS@ +WEBMIN_PATH = @WEBMIN_PATH@ +WEBMIN_PORT = @WEBMIN_PORT@ +WEBMIN_USER = @WEBMIN_USER@ +WEBMIN_VERSION = @WEBMIN_VERSION@ +WRAP_LIBS = @WRAP_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiled_backends = @compiled_backends@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +pkgconfdir = @PKGCONFDIR@ +noinst_HEADERS = test.h subtests.h afpfunc_helpers.h +test_SOURCES = test.c subtests.c afpfunc_helpers.c \ + $(top_builddir)/etc/afpd/afp_config.c \ + $(top_builddir)/etc/afpd/afp_dsi.c \ + $(top_builddir)/etc/afpd/afp_options.c \ + $(top_builddir)/etc/afpd/afp_util.c \ + $(top_builddir)/etc/afpd/afprun.c \ + $(top_builddir)/etc/afpd/appl.c \ + $(top_builddir)/etc/afpd/auth.c \ + $(top_builddir)/etc/afpd/catsearch.c \ + $(top_builddir)/etc/afpd/desktop.c \ + $(top_builddir)/etc/afpd/dircache.c \ + $(top_builddir)/etc/afpd/directory.c \ + $(top_builddir)/etc/afpd/enumerate.c \ + $(top_builddir)/etc/afpd/extattrs.c \ + $(top_builddir)/etc/afpd/file.c \ + $(top_builddir)/etc/afpd/filedir.c \ + $(top_builddir)/etc/afpd/fork.c \ + $(top_builddir)/etc/afpd/gettok.c \ + $(top_builddir)/etc/afpd/hash.c \ + $(top_builddir)/etc/afpd/mangle.c \ + $(top_builddir)/etc/afpd/messages.c \ + $(top_builddir)/etc/afpd/nfsquota.c \ + $(top_builddir)/etc/afpd/ofork.c \ + $(top_builddir)/etc/afpd/quota.c \ + $(top_builddir)/etc/afpd/status.c \ + $(top_builddir)/etc/afpd/switch.c \ + $(top_builddir)/etc/afpd/uam.c \ + $(top_builddir)/etc/afpd/unix.c \ + $(top_builddir)/etc/afpd/volume.c + +test_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/etc/afpd \ + @SLP_CFLAGS@ \ + -D_PATH_AFPDDEFVOL=\"$(pkgconfdir)/AppleVolumes.default\" \ + -D_PATH_AFPDSYSVOL=\"$(pkgconfdir)/AppleVolumes.system\" \ + -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \ + -D_PATH_AFPDCONF=\"$(pkgconfdir)/afpd.conf\" \ + -D_PATH_AFPDUAMPATH=\"$(UAMS_PATH)/\" \ + -D_PATH_ACL_LDAPCONF=\"$(pkgconfdir)/afp_ldap.conf\" \ + -DAPPLCNAME \ + -DSERVERTEXT=\"$(SERVERTEXT)/\" + +test_LDADD = $(top_builddir)/libatalk/libatalk.la $(top_builddir)/libatalk/cnid/libcnid.la @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ +test_LDFLAGS = -export-dynamic +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/afpd/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/afpd/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) + @rm -f test$(EXEEXT) + $(test_LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-afp_config.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-afp_dsi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-afp_options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-afp_util.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-afpfunc_helpers.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-afprun.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-appl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-auth.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-catsearch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-desktop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-dircache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-directory.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-enumerate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-extattrs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-file.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-filedir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-fork.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-gettok.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-hash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-mangle.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-messages.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-nfsquota.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ofork.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-quota.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-status.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-subtests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-switch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-uam.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unix.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-volume.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +test-test.o: test.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-test.o -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test.c' object='test-test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c + +test-test.obj: test.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-test.obj -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test.c' object='test-test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi` + +test-subtests.o: subtests.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-subtests.o -MD -MP -MF $(DEPDIR)/test-subtests.Tpo -c -o test-subtests.o `test -f 'subtests.c' || echo '$(srcdir)/'`subtests.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-subtests.Tpo $(DEPDIR)/test-subtests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='subtests.c' object='test-subtests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-subtests.o `test -f 'subtests.c' || echo '$(srcdir)/'`subtests.c + +test-subtests.obj: subtests.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-subtests.obj -MD -MP -MF $(DEPDIR)/test-subtests.Tpo -c -o test-subtests.obj `if test -f 'subtests.c'; then $(CYGPATH_W) 'subtests.c'; else $(CYGPATH_W) '$(srcdir)/subtests.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-subtests.Tpo $(DEPDIR)/test-subtests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='subtests.c' object='test-subtests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-subtests.obj `if test -f 'subtests.c'; then $(CYGPATH_W) 'subtests.c'; else $(CYGPATH_W) '$(srcdir)/subtests.c'; fi` + +test-afpfunc_helpers.o: afpfunc_helpers.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afpfunc_helpers.o -MD -MP -MF $(DEPDIR)/test-afpfunc_helpers.Tpo -c -o test-afpfunc_helpers.o `test -f 'afpfunc_helpers.c' || echo '$(srcdir)/'`afpfunc_helpers.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afpfunc_helpers.Tpo $(DEPDIR)/test-afpfunc_helpers.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='afpfunc_helpers.c' object='test-afpfunc_helpers.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afpfunc_helpers.o `test -f 'afpfunc_helpers.c' || echo '$(srcdir)/'`afpfunc_helpers.c + +test-afpfunc_helpers.obj: afpfunc_helpers.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afpfunc_helpers.obj -MD -MP -MF $(DEPDIR)/test-afpfunc_helpers.Tpo -c -o test-afpfunc_helpers.obj `if test -f 'afpfunc_helpers.c'; then $(CYGPATH_W) 'afpfunc_helpers.c'; else $(CYGPATH_W) '$(srcdir)/afpfunc_helpers.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afpfunc_helpers.Tpo $(DEPDIR)/test-afpfunc_helpers.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='afpfunc_helpers.c' object='test-afpfunc_helpers.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afpfunc_helpers.obj `if test -f 'afpfunc_helpers.c'; then $(CYGPATH_W) 'afpfunc_helpers.c'; else $(CYGPATH_W) '$(srcdir)/afpfunc_helpers.c'; fi` + +test-afp_config.o: $(top_builddir)/etc/afpd/afp_config.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_config.o -MD -MP -MF $(DEPDIR)/test-afp_config.Tpo -c -o test-afp_config.o `test -f '$(top_builddir)/etc/afpd/afp_config.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_config.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_config.Tpo $(DEPDIR)/test-afp_config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_config.c' object='test-afp_config.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_config.o `test -f '$(top_builddir)/etc/afpd/afp_config.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_config.c + +test-afp_config.obj: $(top_builddir)/etc/afpd/afp_config.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_config.obj -MD -MP -MF $(DEPDIR)/test-afp_config.Tpo -c -o test-afp_config.obj `if test -f '$(top_builddir)/etc/afpd/afp_config.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_config.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_config.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_config.Tpo $(DEPDIR)/test-afp_config.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_config.c' object='test-afp_config.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_config.obj `if test -f '$(top_builddir)/etc/afpd/afp_config.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_config.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_config.c'; fi` + +test-afp_dsi.o: $(top_builddir)/etc/afpd/afp_dsi.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_dsi.o -MD -MP -MF $(DEPDIR)/test-afp_dsi.Tpo -c -o test-afp_dsi.o `test -f '$(top_builddir)/etc/afpd/afp_dsi.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_dsi.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_dsi.Tpo $(DEPDIR)/test-afp_dsi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_dsi.c' object='test-afp_dsi.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_dsi.o `test -f '$(top_builddir)/etc/afpd/afp_dsi.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_dsi.c + +test-afp_dsi.obj: $(top_builddir)/etc/afpd/afp_dsi.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_dsi.obj -MD -MP -MF $(DEPDIR)/test-afp_dsi.Tpo -c -o test-afp_dsi.obj `if test -f '$(top_builddir)/etc/afpd/afp_dsi.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_dsi.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_dsi.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_dsi.Tpo $(DEPDIR)/test-afp_dsi.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_dsi.c' object='test-afp_dsi.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_dsi.obj `if test -f '$(top_builddir)/etc/afpd/afp_dsi.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_dsi.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_dsi.c'; fi` + +test-afp_options.o: $(top_builddir)/etc/afpd/afp_options.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_options.o -MD -MP -MF $(DEPDIR)/test-afp_options.Tpo -c -o test-afp_options.o `test -f '$(top_builddir)/etc/afpd/afp_options.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_options.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_options.Tpo $(DEPDIR)/test-afp_options.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_options.c' object='test-afp_options.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_options.o `test -f '$(top_builddir)/etc/afpd/afp_options.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_options.c + +test-afp_options.obj: $(top_builddir)/etc/afpd/afp_options.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_options.obj -MD -MP -MF $(DEPDIR)/test-afp_options.Tpo -c -o test-afp_options.obj `if test -f '$(top_builddir)/etc/afpd/afp_options.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_options.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_options.Tpo $(DEPDIR)/test-afp_options.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_options.c' object='test-afp_options.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_options.obj `if test -f '$(top_builddir)/etc/afpd/afp_options.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_options.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_options.c'; fi` + +test-afp_util.o: $(top_builddir)/etc/afpd/afp_util.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_util.o -MD -MP -MF $(DEPDIR)/test-afp_util.Tpo -c -o test-afp_util.o `test -f '$(top_builddir)/etc/afpd/afp_util.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_util.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_util.Tpo $(DEPDIR)/test-afp_util.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_util.c' object='test-afp_util.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_util.o `test -f '$(top_builddir)/etc/afpd/afp_util.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afp_util.c + +test-afp_util.obj: $(top_builddir)/etc/afpd/afp_util.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afp_util.obj -MD -MP -MF $(DEPDIR)/test-afp_util.Tpo -c -o test-afp_util.obj `if test -f '$(top_builddir)/etc/afpd/afp_util.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_util.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_util.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afp_util.Tpo $(DEPDIR)/test-afp_util.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afp_util.c' object='test-afp_util.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afp_util.obj `if test -f '$(top_builddir)/etc/afpd/afp_util.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afp_util.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afp_util.c'; fi` + +test-afprun.o: $(top_builddir)/etc/afpd/afprun.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afprun.o -MD -MP -MF $(DEPDIR)/test-afprun.Tpo -c -o test-afprun.o `test -f '$(top_builddir)/etc/afpd/afprun.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afprun.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afprun.Tpo $(DEPDIR)/test-afprun.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afprun.c' object='test-afprun.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afprun.o `test -f '$(top_builddir)/etc/afpd/afprun.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/afprun.c + +test-afprun.obj: $(top_builddir)/etc/afpd/afprun.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-afprun.obj -MD -MP -MF $(DEPDIR)/test-afprun.Tpo -c -o test-afprun.obj `if test -f '$(top_builddir)/etc/afpd/afprun.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afprun.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afprun.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-afprun.Tpo $(DEPDIR)/test-afprun.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/afprun.c' object='test-afprun.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-afprun.obj `if test -f '$(top_builddir)/etc/afpd/afprun.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/afprun.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/afprun.c'; fi` + +test-appl.o: $(top_builddir)/etc/afpd/appl.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-appl.o -MD -MP -MF $(DEPDIR)/test-appl.Tpo -c -o test-appl.o `test -f '$(top_builddir)/etc/afpd/appl.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/appl.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-appl.Tpo $(DEPDIR)/test-appl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/appl.c' object='test-appl.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-appl.o `test -f '$(top_builddir)/etc/afpd/appl.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/appl.c + +test-appl.obj: $(top_builddir)/etc/afpd/appl.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-appl.obj -MD -MP -MF $(DEPDIR)/test-appl.Tpo -c -o test-appl.obj `if test -f '$(top_builddir)/etc/afpd/appl.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/appl.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/appl.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-appl.Tpo $(DEPDIR)/test-appl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/appl.c' object='test-appl.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-appl.obj `if test -f '$(top_builddir)/etc/afpd/appl.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/appl.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/appl.c'; fi` + +test-auth.o: $(top_builddir)/etc/afpd/auth.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-auth.o -MD -MP -MF $(DEPDIR)/test-auth.Tpo -c -o test-auth.o `test -f '$(top_builddir)/etc/afpd/auth.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/auth.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-auth.Tpo $(DEPDIR)/test-auth.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/auth.c' object='test-auth.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-auth.o `test -f '$(top_builddir)/etc/afpd/auth.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/auth.c + +test-auth.obj: $(top_builddir)/etc/afpd/auth.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-auth.obj -MD -MP -MF $(DEPDIR)/test-auth.Tpo -c -o test-auth.obj `if test -f '$(top_builddir)/etc/afpd/auth.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/auth.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/auth.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-auth.Tpo $(DEPDIR)/test-auth.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/auth.c' object='test-auth.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-auth.obj `if test -f '$(top_builddir)/etc/afpd/auth.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/auth.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/auth.c'; fi` + +test-catsearch.o: $(top_builddir)/etc/afpd/catsearch.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-catsearch.o -MD -MP -MF $(DEPDIR)/test-catsearch.Tpo -c -o test-catsearch.o `test -f '$(top_builddir)/etc/afpd/catsearch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/catsearch.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-catsearch.Tpo $(DEPDIR)/test-catsearch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/catsearch.c' object='test-catsearch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-catsearch.o `test -f '$(top_builddir)/etc/afpd/catsearch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/catsearch.c + +test-catsearch.obj: $(top_builddir)/etc/afpd/catsearch.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-catsearch.obj -MD -MP -MF $(DEPDIR)/test-catsearch.Tpo -c -o test-catsearch.obj `if test -f '$(top_builddir)/etc/afpd/catsearch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/catsearch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/catsearch.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-catsearch.Tpo $(DEPDIR)/test-catsearch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/catsearch.c' object='test-catsearch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-catsearch.obj `if test -f '$(top_builddir)/etc/afpd/catsearch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/catsearch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/catsearch.c'; fi` + +test-desktop.o: $(top_builddir)/etc/afpd/desktop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-desktop.o -MD -MP -MF $(DEPDIR)/test-desktop.Tpo -c -o test-desktop.o `test -f '$(top_builddir)/etc/afpd/desktop.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/desktop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-desktop.Tpo $(DEPDIR)/test-desktop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/desktop.c' object='test-desktop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-desktop.o `test -f '$(top_builddir)/etc/afpd/desktop.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/desktop.c + +test-desktop.obj: $(top_builddir)/etc/afpd/desktop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-desktop.obj -MD -MP -MF $(DEPDIR)/test-desktop.Tpo -c -o test-desktop.obj `if test -f '$(top_builddir)/etc/afpd/desktop.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/desktop.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/desktop.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-desktop.Tpo $(DEPDIR)/test-desktop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/desktop.c' object='test-desktop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-desktop.obj `if test -f '$(top_builddir)/etc/afpd/desktop.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/desktop.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/desktop.c'; fi` + +test-dircache.o: $(top_builddir)/etc/afpd/dircache.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-dircache.o -MD -MP -MF $(DEPDIR)/test-dircache.Tpo -c -o test-dircache.o `test -f '$(top_builddir)/etc/afpd/dircache.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/dircache.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-dircache.Tpo $(DEPDIR)/test-dircache.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/dircache.c' object='test-dircache.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-dircache.o `test -f '$(top_builddir)/etc/afpd/dircache.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/dircache.c + +test-dircache.obj: $(top_builddir)/etc/afpd/dircache.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-dircache.obj -MD -MP -MF $(DEPDIR)/test-dircache.Tpo -c -o test-dircache.obj `if test -f '$(top_builddir)/etc/afpd/dircache.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/dircache.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/dircache.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-dircache.Tpo $(DEPDIR)/test-dircache.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/dircache.c' object='test-dircache.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-dircache.obj `if test -f '$(top_builddir)/etc/afpd/dircache.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/dircache.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/dircache.c'; fi` + +test-directory.o: $(top_builddir)/etc/afpd/directory.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-directory.o -MD -MP -MF $(DEPDIR)/test-directory.Tpo -c -o test-directory.o `test -f '$(top_builddir)/etc/afpd/directory.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/directory.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-directory.Tpo $(DEPDIR)/test-directory.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/directory.c' object='test-directory.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-directory.o `test -f '$(top_builddir)/etc/afpd/directory.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/directory.c + +test-directory.obj: $(top_builddir)/etc/afpd/directory.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-directory.obj -MD -MP -MF $(DEPDIR)/test-directory.Tpo -c -o test-directory.obj `if test -f '$(top_builddir)/etc/afpd/directory.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/directory.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/directory.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-directory.Tpo $(DEPDIR)/test-directory.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/directory.c' object='test-directory.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-directory.obj `if test -f '$(top_builddir)/etc/afpd/directory.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/directory.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/directory.c'; fi` + +test-enumerate.o: $(top_builddir)/etc/afpd/enumerate.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-enumerate.o -MD -MP -MF $(DEPDIR)/test-enumerate.Tpo -c -o test-enumerate.o `test -f '$(top_builddir)/etc/afpd/enumerate.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/enumerate.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-enumerate.Tpo $(DEPDIR)/test-enumerate.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/enumerate.c' object='test-enumerate.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-enumerate.o `test -f '$(top_builddir)/etc/afpd/enumerate.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/enumerate.c + +test-enumerate.obj: $(top_builddir)/etc/afpd/enumerate.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-enumerate.obj -MD -MP -MF $(DEPDIR)/test-enumerate.Tpo -c -o test-enumerate.obj `if test -f '$(top_builddir)/etc/afpd/enumerate.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/enumerate.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/enumerate.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-enumerate.Tpo $(DEPDIR)/test-enumerate.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/enumerate.c' object='test-enumerate.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-enumerate.obj `if test -f '$(top_builddir)/etc/afpd/enumerate.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/enumerate.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/enumerate.c'; fi` + +test-extattrs.o: $(top_builddir)/etc/afpd/extattrs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-extattrs.o -MD -MP -MF $(DEPDIR)/test-extattrs.Tpo -c -o test-extattrs.o `test -f '$(top_builddir)/etc/afpd/extattrs.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/extattrs.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-extattrs.Tpo $(DEPDIR)/test-extattrs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/extattrs.c' object='test-extattrs.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-extattrs.o `test -f '$(top_builddir)/etc/afpd/extattrs.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/extattrs.c + +test-extattrs.obj: $(top_builddir)/etc/afpd/extattrs.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-extattrs.obj -MD -MP -MF $(DEPDIR)/test-extattrs.Tpo -c -o test-extattrs.obj `if test -f '$(top_builddir)/etc/afpd/extattrs.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/extattrs.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/extattrs.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-extattrs.Tpo $(DEPDIR)/test-extattrs.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/extattrs.c' object='test-extattrs.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-extattrs.obj `if test -f '$(top_builddir)/etc/afpd/extattrs.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/extattrs.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/extattrs.c'; fi` + +test-file.o: $(top_builddir)/etc/afpd/file.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-file.o -MD -MP -MF $(DEPDIR)/test-file.Tpo -c -o test-file.o `test -f '$(top_builddir)/etc/afpd/file.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/file.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-file.Tpo $(DEPDIR)/test-file.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/file.c' object='test-file.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-file.o `test -f '$(top_builddir)/etc/afpd/file.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/file.c + +test-file.obj: $(top_builddir)/etc/afpd/file.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-file.obj -MD -MP -MF $(DEPDIR)/test-file.Tpo -c -o test-file.obj `if test -f '$(top_builddir)/etc/afpd/file.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/file.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/file.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-file.Tpo $(DEPDIR)/test-file.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/file.c' object='test-file.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-file.obj `if test -f '$(top_builddir)/etc/afpd/file.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/file.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/file.c'; fi` + +test-filedir.o: $(top_builddir)/etc/afpd/filedir.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-filedir.o -MD -MP -MF $(DEPDIR)/test-filedir.Tpo -c -o test-filedir.o `test -f '$(top_builddir)/etc/afpd/filedir.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/filedir.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-filedir.Tpo $(DEPDIR)/test-filedir.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/filedir.c' object='test-filedir.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-filedir.o `test -f '$(top_builddir)/etc/afpd/filedir.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/filedir.c + +test-filedir.obj: $(top_builddir)/etc/afpd/filedir.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-filedir.obj -MD -MP -MF $(DEPDIR)/test-filedir.Tpo -c -o test-filedir.obj `if test -f '$(top_builddir)/etc/afpd/filedir.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/filedir.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/filedir.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-filedir.Tpo $(DEPDIR)/test-filedir.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/filedir.c' object='test-filedir.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-filedir.obj `if test -f '$(top_builddir)/etc/afpd/filedir.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/filedir.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/filedir.c'; fi` + +test-fork.o: $(top_builddir)/etc/afpd/fork.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-fork.o -MD -MP -MF $(DEPDIR)/test-fork.Tpo -c -o test-fork.o `test -f '$(top_builddir)/etc/afpd/fork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/fork.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-fork.Tpo $(DEPDIR)/test-fork.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/fork.c' object='test-fork.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-fork.o `test -f '$(top_builddir)/etc/afpd/fork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/fork.c + +test-fork.obj: $(top_builddir)/etc/afpd/fork.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-fork.obj -MD -MP -MF $(DEPDIR)/test-fork.Tpo -c -o test-fork.obj `if test -f '$(top_builddir)/etc/afpd/fork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/fork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/fork.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-fork.Tpo $(DEPDIR)/test-fork.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/fork.c' object='test-fork.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-fork.obj `if test -f '$(top_builddir)/etc/afpd/fork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/fork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/fork.c'; fi` + +test-gettok.o: $(top_builddir)/etc/afpd/gettok.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-gettok.o -MD -MP -MF $(DEPDIR)/test-gettok.Tpo -c -o test-gettok.o `test -f '$(top_builddir)/etc/afpd/gettok.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/gettok.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-gettok.Tpo $(DEPDIR)/test-gettok.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/gettok.c' object='test-gettok.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-gettok.o `test -f '$(top_builddir)/etc/afpd/gettok.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/gettok.c + +test-gettok.obj: $(top_builddir)/etc/afpd/gettok.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-gettok.obj -MD -MP -MF $(DEPDIR)/test-gettok.Tpo -c -o test-gettok.obj `if test -f '$(top_builddir)/etc/afpd/gettok.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/gettok.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/gettok.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-gettok.Tpo $(DEPDIR)/test-gettok.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/gettok.c' object='test-gettok.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-gettok.obj `if test -f '$(top_builddir)/etc/afpd/gettok.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/gettok.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/gettok.c'; fi` + +test-hash.o: $(top_builddir)/etc/afpd/hash.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-hash.o -MD -MP -MF $(DEPDIR)/test-hash.Tpo -c -o test-hash.o `test -f '$(top_builddir)/etc/afpd/hash.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/hash.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-hash.Tpo $(DEPDIR)/test-hash.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/hash.c' object='test-hash.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-hash.o `test -f '$(top_builddir)/etc/afpd/hash.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/hash.c + +test-hash.obj: $(top_builddir)/etc/afpd/hash.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-hash.obj -MD -MP -MF $(DEPDIR)/test-hash.Tpo -c -o test-hash.obj `if test -f '$(top_builddir)/etc/afpd/hash.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/hash.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/hash.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-hash.Tpo $(DEPDIR)/test-hash.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/hash.c' object='test-hash.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-hash.obj `if test -f '$(top_builddir)/etc/afpd/hash.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/hash.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/hash.c'; fi` + +test-mangle.o: $(top_builddir)/etc/afpd/mangle.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-mangle.o -MD -MP -MF $(DEPDIR)/test-mangle.Tpo -c -o test-mangle.o `test -f '$(top_builddir)/etc/afpd/mangle.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/mangle.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-mangle.Tpo $(DEPDIR)/test-mangle.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/mangle.c' object='test-mangle.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-mangle.o `test -f '$(top_builddir)/etc/afpd/mangle.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/mangle.c + +test-mangle.obj: $(top_builddir)/etc/afpd/mangle.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-mangle.obj -MD -MP -MF $(DEPDIR)/test-mangle.Tpo -c -o test-mangle.obj `if test -f '$(top_builddir)/etc/afpd/mangle.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/mangle.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/mangle.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-mangle.Tpo $(DEPDIR)/test-mangle.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/mangle.c' object='test-mangle.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-mangle.obj `if test -f '$(top_builddir)/etc/afpd/mangle.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/mangle.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/mangle.c'; fi` + +test-messages.o: $(top_builddir)/etc/afpd/messages.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-messages.o -MD -MP -MF $(DEPDIR)/test-messages.Tpo -c -o test-messages.o `test -f '$(top_builddir)/etc/afpd/messages.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/messages.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-messages.Tpo $(DEPDIR)/test-messages.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/messages.c' object='test-messages.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-messages.o `test -f '$(top_builddir)/etc/afpd/messages.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/messages.c + +test-messages.obj: $(top_builddir)/etc/afpd/messages.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-messages.obj -MD -MP -MF $(DEPDIR)/test-messages.Tpo -c -o test-messages.obj `if test -f '$(top_builddir)/etc/afpd/messages.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/messages.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/messages.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-messages.Tpo $(DEPDIR)/test-messages.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/messages.c' object='test-messages.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-messages.obj `if test -f '$(top_builddir)/etc/afpd/messages.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/messages.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/messages.c'; fi` + +test-nfsquota.o: $(top_builddir)/etc/afpd/nfsquota.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-nfsquota.o -MD -MP -MF $(DEPDIR)/test-nfsquota.Tpo -c -o test-nfsquota.o `test -f '$(top_builddir)/etc/afpd/nfsquota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/nfsquota.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-nfsquota.Tpo $(DEPDIR)/test-nfsquota.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/nfsquota.c' object='test-nfsquota.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-nfsquota.o `test -f '$(top_builddir)/etc/afpd/nfsquota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/nfsquota.c + +test-nfsquota.obj: $(top_builddir)/etc/afpd/nfsquota.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-nfsquota.obj -MD -MP -MF $(DEPDIR)/test-nfsquota.Tpo -c -o test-nfsquota.obj `if test -f '$(top_builddir)/etc/afpd/nfsquota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/nfsquota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/nfsquota.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-nfsquota.Tpo $(DEPDIR)/test-nfsquota.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/nfsquota.c' object='test-nfsquota.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-nfsquota.obj `if test -f '$(top_builddir)/etc/afpd/nfsquota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/nfsquota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/nfsquota.c'; fi` + +test-ofork.o: $(top_builddir)/etc/afpd/ofork.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-ofork.o -MD -MP -MF $(DEPDIR)/test-ofork.Tpo -c -o test-ofork.o `test -f '$(top_builddir)/etc/afpd/ofork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/ofork.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-ofork.Tpo $(DEPDIR)/test-ofork.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/ofork.c' object='test-ofork.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-ofork.o `test -f '$(top_builddir)/etc/afpd/ofork.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/ofork.c + +test-ofork.obj: $(top_builddir)/etc/afpd/ofork.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-ofork.obj -MD -MP -MF $(DEPDIR)/test-ofork.Tpo -c -o test-ofork.obj `if test -f '$(top_builddir)/etc/afpd/ofork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/ofork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/ofork.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-ofork.Tpo $(DEPDIR)/test-ofork.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/ofork.c' object='test-ofork.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-ofork.obj `if test -f '$(top_builddir)/etc/afpd/ofork.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/ofork.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/ofork.c'; fi` + +test-quota.o: $(top_builddir)/etc/afpd/quota.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-quota.o -MD -MP -MF $(DEPDIR)/test-quota.Tpo -c -o test-quota.o `test -f '$(top_builddir)/etc/afpd/quota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/quota.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-quota.Tpo $(DEPDIR)/test-quota.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/quota.c' object='test-quota.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-quota.o `test -f '$(top_builddir)/etc/afpd/quota.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/quota.c + +test-quota.obj: $(top_builddir)/etc/afpd/quota.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-quota.obj -MD -MP -MF $(DEPDIR)/test-quota.Tpo -c -o test-quota.obj `if test -f '$(top_builddir)/etc/afpd/quota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/quota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/quota.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-quota.Tpo $(DEPDIR)/test-quota.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/quota.c' object='test-quota.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-quota.obj `if test -f '$(top_builddir)/etc/afpd/quota.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/quota.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/quota.c'; fi` + +test-status.o: $(top_builddir)/etc/afpd/status.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-status.o -MD -MP -MF $(DEPDIR)/test-status.Tpo -c -o test-status.o `test -f '$(top_builddir)/etc/afpd/status.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/status.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-status.Tpo $(DEPDIR)/test-status.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/status.c' object='test-status.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-status.o `test -f '$(top_builddir)/etc/afpd/status.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/status.c + +test-status.obj: $(top_builddir)/etc/afpd/status.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-status.obj -MD -MP -MF $(DEPDIR)/test-status.Tpo -c -o test-status.obj `if test -f '$(top_builddir)/etc/afpd/status.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/status.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/status.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-status.Tpo $(DEPDIR)/test-status.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/status.c' object='test-status.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-status.obj `if test -f '$(top_builddir)/etc/afpd/status.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/status.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/status.c'; fi` + +test-switch.o: $(top_builddir)/etc/afpd/switch.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-switch.o -MD -MP -MF $(DEPDIR)/test-switch.Tpo -c -o test-switch.o `test -f '$(top_builddir)/etc/afpd/switch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/switch.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-switch.Tpo $(DEPDIR)/test-switch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/switch.c' object='test-switch.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-switch.o `test -f '$(top_builddir)/etc/afpd/switch.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/switch.c + +test-switch.obj: $(top_builddir)/etc/afpd/switch.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-switch.obj -MD -MP -MF $(DEPDIR)/test-switch.Tpo -c -o test-switch.obj `if test -f '$(top_builddir)/etc/afpd/switch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/switch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/switch.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-switch.Tpo $(DEPDIR)/test-switch.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/switch.c' object='test-switch.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-switch.obj `if test -f '$(top_builddir)/etc/afpd/switch.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/switch.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/switch.c'; fi` + +test-uam.o: $(top_builddir)/etc/afpd/uam.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-uam.o -MD -MP -MF $(DEPDIR)/test-uam.Tpo -c -o test-uam.o `test -f '$(top_builddir)/etc/afpd/uam.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/uam.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-uam.Tpo $(DEPDIR)/test-uam.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/uam.c' object='test-uam.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-uam.o `test -f '$(top_builddir)/etc/afpd/uam.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/uam.c + +test-uam.obj: $(top_builddir)/etc/afpd/uam.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-uam.obj -MD -MP -MF $(DEPDIR)/test-uam.Tpo -c -o test-uam.obj `if test -f '$(top_builddir)/etc/afpd/uam.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/uam.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/uam.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-uam.Tpo $(DEPDIR)/test-uam.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/uam.c' object='test-uam.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-uam.obj `if test -f '$(top_builddir)/etc/afpd/uam.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/uam.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/uam.c'; fi` + +test-unix.o: $(top_builddir)/etc/afpd/unix.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-unix.o -MD -MP -MF $(DEPDIR)/test-unix.Tpo -c -o test-unix.o `test -f '$(top_builddir)/etc/afpd/unix.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/unix.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-unix.Tpo $(DEPDIR)/test-unix.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/unix.c' object='test-unix.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-unix.o `test -f '$(top_builddir)/etc/afpd/unix.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/unix.c + +test-unix.obj: $(top_builddir)/etc/afpd/unix.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-unix.obj -MD -MP -MF $(DEPDIR)/test-unix.Tpo -c -o test-unix.obj `if test -f '$(top_builddir)/etc/afpd/unix.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/unix.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/unix.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-unix.Tpo $(DEPDIR)/test-unix.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/unix.c' object='test-unix.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-unix.obj `if test -f '$(top_builddir)/etc/afpd/unix.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/unix.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/unix.c'; fi` + +test-volume.o: $(top_builddir)/etc/afpd/volume.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-volume.o -MD -MP -MF $(DEPDIR)/test-volume.Tpo -c -o test-volume.o `test -f '$(top_builddir)/etc/afpd/volume.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/volume.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-volume.Tpo $(DEPDIR)/test-volume.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/volume.c' object='test-volume.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-volume.o `test -f '$(top_builddir)/etc/afpd/volume.c' || echo '$(srcdir)/'`$(top_builddir)/etc/afpd/volume.c + +test-volume.obj: $(top_builddir)/etc/afpd/volume.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -MT test-volume.obj -MD -MP -MF $(DEPDIR)/test-volume.Tpo -c -o test-volume.obj `if test -f '$(top_builddir)/etc/afpd/volume.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/volume.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/volume.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-volume.Tpo $(DEPDIR)/test-volume.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_builddir)/etc/afpd/volume.c' object='test-volume.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_CFLAGS) $(CFLAGS) -c -o test-volume.obj `if test -f '$(top_builddir)/etc/afpd/volume.c'; then $(CYGPATH_W) '$(top_builddir)/etc/afpd/volume.c'; else $(CYGPATH_W) '$(srcdir)/$(top_builddir)/etc/afpd/volume.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *$$ws$$tst$$ws*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/afpd/afpfunc_helpers.c b/test/afpd/afpfunc_helpers.c new file mode 100644 index 00000000..b5b8165f --- /dev/null +++ b/test/afpd/afpfunc_helpers.c @@ -0,0 +1,237 @@ +/* + $Id: afpfunc_helpers.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "file.h" +#include "filedir.h" +#include "directory.h" +#include "dircache.h" +#include "hash.h" +#include "globals.h" +#include "afp_config.h" +#include "volume.h" + +#include "test.h" +#include "subtests.h" + + +#define rbufsize 128000 +static char rbuf[rbufsize]; +static size_t rbuflen; + +#define ADD(a, b, c) (a) += (c); \ + (b) += (c) + +#define PUSHBUF(p, val, size, len) \ + memcpy((p), (val), (size)); \ + (p) += (size); \ + (len) += (size) + +#define PUSHVAL(p, type, val, len) \ + { \ + type type = val; \ + memcpy(p, &type, sizeof(type)); \ + (p) += sizeof(type); \ + (len) += sizeof(type); \ + } + +static int push_path(char **bufp, const char *name) +{ + int len = 0; + int slen = strlen(name); + char *p = *bufp; + + PUSHVAL(p, uint8_t, 3, len); /* path type */ + PUSHVAL(p, uint32_t, kTextEncodingUTF8, len); /* text encoding hint */ + PUSHVAL(p, uint16_t, htons(slen), len); + if (slen) { + for (int i = 0; i < slen; i++) { + if (name[i] == '/') + p[i] = 0; + else + p[i] = name[i]; + } + len += slen; + } + + *bufp += len; + return len; +} + +/*********************************************************************************** + * Interface + ***********************************************************************************/ + +char **cnamewrap(const char *name) +{ + static char buf[256]; + static char *p = buf; + int len = 0; + + PUSHVAL(p, uint8_t, 3, len); /* path type */ + PUSHVAL(p, uint32_t, kTextEncodingUTF8, len); /* text encoding hint */ + PUSHVAL(p, uint16_t, ntohs(strlen(name)), len); + strcpy(p, name); + + p = buf; + return &p; +} + +int getfiledirparms(AFPObj *obj, uint16_t vid, cnid_t did, const char *name) +{ + const int bufsize = 256; + char buf[bufsize]; + char *p = buf; + int len = 0; + + ADD(p, len , 2); + + PUSHVAL(p, uint16_t, vid, len); + PUSHVAL(p, cnid_t, did, len); + PUSHVAL(p, uint16_t, htons(FILPBIT_FNUM | FILPBIT_PDINFO), len); + PUSHVAL(p, uint16_t, htons(DIRPBIT_DID | DIRPBIT_PDINFO), len); + + len += push_path(&p, name); + + return afp_getfildirparams(obj, buf, len, rbuf, &rbuflen); +} + +int createdir(AFPObj *obj, uint16_t vid, cnid_t did, const char *name) +{ + const int bufsize = 256; + char buf[bufsize]; + char *p = buf; + int len = 0; + + ADD(p, len , 2); + + PUSHVAL(p, uint16_t, vid, len); + PUSHVAL(p, cnid_t, did, len); + len += push_path(&p, name); + + return afp_createdir(obj, buf, len, rbuf, &rbuflen); +} + +int createfile(AFPObj *obj, uint16_t vid, cnid_t did, const char *name) +{ + const int bufsize = 256; + char buf[bufsize]; + char *p = buf; + int len = 0; + + PUSHVAL(p, uint16_t, htons(128), len); /* hard create */ + PUSHVAL(p, uint16_t, vid, len); + PUSHVAL(p, cnid_t, did, len); + len += push_path(&p, name); + + return afp_createfile(obj, buf, len, rbuf, &rbuflen); +} + +int delete(AFPObj *obj, uint16_t vid, cnid_t did, const char *name) +{ + const int bufsize = 256; + char buf[bufsize]; + char *p = buf; + int len = 0; + + PUSHVAL(p, uint16_t, htons(128), len); /* hard create */ + PUSHVAL(p, uint16_t, vid, len); + PUSHVAL(p, cnid_t, did, len); + len += push_path(&p, name); + + return afp_delete(obj, buf, len, rbuf, &rbuflen); +} + +int enumerate(AFPObj *obj, uint16_t vid, cnid_t did) +{ + const int bufsize = 256; + char buf[bufsize]; + char *p = buf; + int len = 0; + + ADD(p, len , 2); + + PUSHVAL(p, uint16_t, vid, len); + PUSHVAL(p, cnid_t, did, len); + PUSHVAL(p, uint16_t, htons(FILPBIT_PDID | FILPBIT_FNUM | FILPBIT_PDINFO), len); + PUSHVAL(p, uint16_t, htons(DIRPBIT_PDID | DIRPBIT_DID | DIRPBIT_PDINFO), len); + PUSHVAL(p, uint16_t, htons(20), len); /* reqcount */ + PUSHVAL(p, uint32_t, htonl(1), len); /* startindex */ + PUSHVAL(p, uint32_t, htonl(rbufsize), len); /* max replysize */ + + len += push_path(&p, ""); + + return afp_enumerate_ext2(obj, buf, len, rbuf, &rbuflen); +} + +uint16_t openvol(AFPObj *obj, const char *name) +{ + int ret; + uint16_t bitmap; + uint16_t vid; + const int bufsize = 32; + char buf[bufsize]; + char *p = buf; + char len = strlen(name); + + memset(p, 0, bufsize); + p += 2; + + /* bitmap */ + bitmap = htons(1< + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifndef AFPFUNC_HELPERS +#define AFPFUNC_HELPERS + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "file.h" +#include "filedir.h" +#include "directory.h" +#include "dircache.h" +#include "hash.h" +#include "globals.h" +#include "afp_config.h" +#include "volume.h" + +#include "test.h" +#include "subtests.h" + +extern char **cnamewrap(const char *name); + +extern int getfiledirparms(AFPObj *obj, uint16_t vid, cnid_t did, const char *name); +extern int createdir(AFPObj *obj, uint16_t vid, cnid_t did, const char *name); +extern int createfile(AFPObj *obj, uint16_t vid, cnid_t did, const char *name); +extern int delete(AFPObj *obj, uint16_t vid, cnid_t did, const char *name); +extern int enumerate(AFPObj *obj, uint16_t vid, cnid_t did); +extern uint16_t openvol(AFPObj *obj, const char *name); + +#endif /* AFPFUNC_HELPERS */ diff --git a/test/afpd/subtests.c b/test/afpd/subtests.c new file mode 100644 index 00000000..d606be80 --- /dev/null +++ b/test/afpd/subtests.c @@ -0,0 +1,71 @@ +/* + $Id: subtests.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "directory.h" +#include "dircache.h" +#include "hash.h" +#include "globals.h" +#include "afp_config.h" +#include "volume.h" + +#include "test.h" +#include "subtests.h" + +static int reti; /* for the TEST_int macro */ + +int test001_add_x_dirs(const struct vol *vol, cnid_t start, cnid_t end) +{ + struct dir *dir; + char dirname[20]; + while (start++ < end) { + sprintf(dirname, "dir%04u", start); + dir = dir_new(dirname, dirname, vol, DIRDID_ROOT, htonl(start), bfromcstr(vol->v_path)); + if (dir == NULL) + return -1; + if (dircache_add(dir) != 0) + return -1; + } + + return 0; +} + +int test002_rem_x_dirs(const struct vol *vol, cnid_t start, cnid_t end) +{ + struct dir *dir; + while (start++ < end) { + if ((dir = dircache_search_by_did(vol, htonl(start)))) + if (dir_remove(vol, dir) != 0) + return -1; + } + + return 0; +} diff --git a/test/afpd/subtests.h b/test/afpd/subtests.h new file mode 100644 index 00000000..1ce10a06 --- /dev/null +++ b/test/afpd/subtests.h @@ -0,0 +1,45 @@ +/* + $Id: subtests.h,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifndef SUBTESTS_H +#define SUBTESTS_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "directory.h" +#include "dircache.h" +#include "hash.h" +#include "globals.h" +#include "afp_config.h" +#include "volume.h" + +extern int test001_add_x_dirs(const struct vol *vol, cnid_t start, cnid_t end); +extern int test002_rem_x_dirs(const struct vol *vol, cnid_t start, cnid_t end); +#endif /* SUBTESTS_H */ diff --git a/test/afpd/test.c b/test/afpd/test.c new file mode 100644 index 00000000..20feba6d --- /dev/null +++ b/test/afpd/test.c @@ -0,0 +1,124 @@ +/* + $Id: test.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "file.h" +#include "filedir.h" +#include "directory.h" +#include "dircache.h" +#include "hash.h" +#include "globals.h" +#include "afp_config.h" +#include "volume.h" + +#include "test.h" +#include "subtests.h" +#include "afpfunc_helpers.h" + +/* Stuff from main.c which of cource can't be added as source to testbin */ +unsigned char nologin = 0; +struct afp_options default_options; +static AFPConfig *configs; + +/* Static variables */ + +int main(int argc, char **argv) +{ + #define ARGNUM 7 + char *args[ARGNUM] = {"test", "-F", "test.conf", "-f", "test.default", "-s" ,"test.system"}; + int reti; + uint16_t vid; + struct vol *vol; + struct dir *dir; + struct dir *retdir; + struct path *path; + + /* initialize */ + afp_version = 32; + printf("Initializing\n============\n"); + TEST(setuplog("default log_note /dev/tty")); + TEST(afp_options_init(&default_options)); + TEST_int(afp_options_parse( ARGNUM, args, &default_options), 1); + TEST_expr(configs = configinit(&default_options), configs != NULL); + TEST(cnid_init()); + TEST(load_volumes(&configs->obj)); + TEST_int(dircache_init(8192), 0); + + printf("\n"); + + /* now run tests */ + printf("Running tests\n=============\n"); + + TEST_expr(vid = openvol(&configs->obj, "test"), vid != 0); + TEST_expr(vol = getvolbyvid(vid), vol != NULL); + + /* test dircache.c stuff*/ + TEST_expr(dir = dir_new("dir", "dir", vol, DIRDID_ROOT, htonl(20), bfromcstr(vol->v_path)), + dir != NULL); + TEST_int(dircache_add(dir), 0); + TEST_expr(retdir = dircache_search_by_did(vol, dir->d_did ), + retdir != NULL && retdir == dir && bstrcmp(retdir->d_u_name, dir->d_u_name) == 0); + TEST_expr(retdir = dircache_search_by_name(vol, DIRDID_ROOT, "dir", strlen("dir")), + retdir != NULL && retdir == dir && bstrcmp(retdir->d_u_name, dir->d_u_name) == 0); + TEST_int(dir_remove(vol, dir), 0); + TEST_int(test001_add_x_dirs(vol, 100, 100000), 0); + TEST_int(test002_rem_x_dirs(vol, 100, 100000), 0); + + /* test directory.c stuff */ + TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT_PARENT), retdir != NULL); + TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL); + TEST_expr(path = cname(vol, retdir, cnamewrap("Network Trash Folder")), path != NULL); + + TEST_expr(retdir = dirlookup(vol, DIRDID_ROOT), retdir != NULL); + TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT_PARENT, "test"), 0); + TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, ""), 0); + + TEST_expr(reti = createdir(&configs->obj, vid, DIRDID_ROOT, "dir1"), + reti == 0 || reti == AFPERR_EXIST); + TEST_expr(retdir = dircache_search_by_name(vol, DIRDID_ROOT, "dir1", strlen("dir1")), + retdir != NULL); + + TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "dir1"), 0); + TEST_int(getfiledirparms(&configs->obj, vid, retdir->d_did, "//"), 0); + + + TEST_int(createfile(&configs->obj, vid, DIRDID_ROOT, "dir1/file1"), 0); + TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "dir1/file1"), 0); + TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "dir1"), 0); + + TEST_int(createfile(&configs->obj, vid, DIRDID_ROOT, "file1"), 0); + TEST_int(getfiledirparms(&configs->obj, vid, DIRDID_ROOT, "file1"), 0); + TEST_int(delete(&configs->obj, vid, DIRDID_ROOT, "file1"), 0); + + + /* test enumerate.c stuff */ + TEST_int(enumerate(&configs->obj, vid, DIRDID_ROOT), 0); +} diff --git a/test/afpd/test.h b/test/afpd/test.h new file mode 100644 index 00000000..802120a2 --- /dev/null +++ b/test/afpd/test.h @@ -0,0 +1,77 @@ +/* + $Id: test.h,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $ + Copyright (c) 2010 Frank Lahm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +*/ + +#ifndef TEST_H +#define TEST_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "directory.h" +#include "dircache.h" +#include "hash.h" +#include "globals.h" +#include "afp_config.h" +#include "volume.h" +#include "subtests.h" + +static inline void alignok(int len) +{ + int i = 1; + if (len < 80) + i = 80 - len; + while (i--) + printf(" "); +} + +#define TEST(a) \ + printf("Testing: %s ... ", (#a) ); \ + alignok(strlen(#a)); \ + a; \ + printf("[ok]\n"); + +#define TEST_int(a, b) \ + printf("Testing: %s ... ", (#a) ); \ + alignok(strlen(#a)); \ + if ((reti = (a)) != b) { \ + printf("[error]\n"); \ + exit(1); \ + } else { printf("[ok]\n"); } + +#define TEST_expr(a, b) \ + printf("Testing: %s ... ", (#a) ); \ + alignok(strlen(#a)); \ + a; \ + if (b) { \ + printf("[ok]\n"); \ + } else { \ + printf("[error]\n"); \ + exit(1); \ + } +#endif /* TEST_H */ diff --git a/test/afpd/test.sh b/test/afpd/test.sh new file mode 100755 index 00000000..80066b6e --- /dev/null +++ b/test/afpd/test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +if [ ! -d /tmp/AFPtestvolume ] ; then + mkdir -p /tmp/AFPtestvolume + if [ $? -ne 0 ] ; then + echo Error creating AFP test volume /tmp/AFPtestvolume + exit 1 + fi +fi + +if [ ! -f test.conf ] ; then + echo -n "Creating configuration template ... " + cat > test.conf < test.default <