FPCatSearch implementation. More...
#include <ctype.h>#include <errno.h>#include <netinet/in.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/file.h>#include <sys/stat.h>#include <sys/types.h>#include <time.h>#include <unistd.h>#include <atalk/adouble.h>#include <atalk/afp.h>#include <atalk/cnid_bdb_private.h>#include <atalk/cnid.h>#include <atalk/globals.h>#include <atalk/logger.h>#include <atalk/netatalk_conf.h>#include <atalk/unicode.h>#include <atalk/util.h>#include "desktop.h"#include "dircache.h"#include "directory.h"#include "file.h"#include "filedir.h"#include "fork.h"#include "volume.h"Data Structures | |
| struct | finderinfo |
| struct | scrit |
| struct | dsitem |
Macros | |
| #define | DS_BSIZE 128 |
| #define | CATPBIT_PARTIAL 31 |
| #define | VETO_STR "./../.AppleDouble/.AppleDB/Network Trash Folder/TheVolumeSettingsFolder/TheFindByContentFolder/.AppleDesktop/.Parent/" |
| #define | NUM_ROUNDS 200 |
Typedefs | |
| typedef char | packed_finder[ADEDLEN_FINDERI] |
Functions | |
| static void | clearstack (void) |
| Clears directory stack. | |
| static int | addstack (char *uname, struct dir *dir, int pidx) |
| static int | reducestack (void) |
| Removes checked items from top of directory stack. | |
| static struct adouble * | adl_lkup (struct vol *vol, struct path *path, struct adouble *adp) |
| static struct finderinfo * | unpack_buffer (struct finderinfo *finfo, char *buffer) |
| static struct finderinfo * | unpack_finderinfo (struct vol *vol, struct path *path, struct adouble **adp, struct finderinfo *finfo, int islnk) |
| static int | crit_check (struct vol *vol, struct path *path) |
| Criteria checker. | |
| static int | rslt_add (const AFPObj *obj, struct vol *vol, struct path *path, char **buf, int ext) |
| static int | catsearch (const AFPObj *obj, struct vol *vol, struct dir *dir, int rmatches, uint32_t *pos, char *rbuf, uint32_t *nrecs, int *rsize, int ext) |
| This function performs a filesystem search. | |
| static int | catsearch_db (const AFPObj *obj, struct vol *vol, const char *uname, int rmatches, uint32_t *pos, char *rbuf, uint32_t *nrecs, int *rsize, int ext) |
| This function performs a CNID db search. | |
| static int | catsearch_afp (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen, int ext) |
| int | afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
Variables | |
| static int | save_cidx = -1 |
| static struct dsitem * | dstack = NULL |
| static int | dssize = 0 |
| static int | dsidx = 0 |
| static struct scrit c1 | c2 |
FPCatSearch implementation.
This file contains FPCatSearch implementation. FPCatSearch performs file/directory search based on specified criteria. It is used by client to perform fast searches on (propably) big volumes. So, it has to be pretty fast.
This implementation bypasses most of adouble/libatalk stuff as long as possible and does a standard filesystem search. It calls higher-level libatalk/afpd functions only when it is really needed, mainly while returning some non-UNIX information or filtering by non-UNIX criteria.
| #define CATPBIT_PARTIAL 31 |
| #define DS_BSIZE 128 |
| #define NUM_ROUNDS 200 |
| #define VETO_STR "./../.AppleDouble/.AppleDB/Network Trash Folder/TheVolumeSettingsFolder/TheFindByContentFolder/.AppleDesktop/.Parent/" |
| typedef char packed_finder[ADEDLEN_FINDERI] |
|
static |
Puts new item onto directory stack.
Looks up for an opened adouble structure, opens resource fork of selected file.
| int afp_catsearch | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_catsearch_ext | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
|
static |
This function performs a filesystem search.
Uses globals c1, c2, the search criteria
| [in] | obj | AFP connection object |
| [in] | vol | volume we are searching on ... |
| [in,out] | dir | directory we are starting from ... |
| [in] | rmatches | maximum number of matches we can return |
| [in] | pos | position we've stopped recently |
| [out] | rbuf | output buffer |
| [out] | nrecs | number of matches |
| [out] | rsize | length of data written to output buffer |
| [in] | ext | extended search flag |
|
static |
|
static |
This function performs a CNID db search.
Uses globals c1, c2, the search criteria Always searches the whole volume, not a subtree
| [in] | obj | AFP connection object |
| [in] | vol | volume we are searching on ... |
| [in] | uname | UNIX name of object to search |
| [in] | rmatches | maximum number of matches we can return |
| [in] | pos | position we've stopped recently |
| [out] | rbuf | output buffer |
| [out] | nrecs | number of matches |
| [out] | rsize | length of data written to output buffer |
| [in] | ext | extended search flag |
|
static |
Clears directory stack.
Criteria checker.
|
static |
Removes checked items from top of directory stack.
|
static |
|
static |
|
static |
|
static |
search criteria
|
static |
First free item index...
|
static |
Directory stack (allocated) size...
|
static |
Directory stack data...
|
static |
Saved index of currently scanned directory.