3 * Copyright (C) 1990, 1993 Regents of The University of Michigan
4 * All Rights Reserved. See COPYRIGHT
9 * This file contains FPCatSearch implementation. FPCatSearch performs
10 * file/directory search based on specified criteria. It is used by client
11 * to perform fast searches on (propably) big volumes. So, it has to be
14 * This implementation bypasses most of adouble/libatalk stuff as long as
15 * possible and does a standard filesystem search. It calls higher-level
16 * libatalk/afpd functions only when it is really needed, mainly while
17 * returning some non-UNIX information or filtering by non-UNIX criteria.
19 * Initial version written by Rafal Lewczuk <rlewczuk@pronet.pl>
25 #endif /* HAVE_CONFIG_H */
38 #define memcpy(d,s,n) bcopy ((s), (d), (n))
39 #define memmove(d,s,n) bcopy ((s), (d), (n))
40 #endif /* ! HAVE_MEMCPY */
44 #include <netinet/in.h>
46 #include <atalk/afp.h>
47 #include <atalk/adouble.h>
48 #include <atalk/logger.h>
50 #include <atalk/cnid.h>
53 #include <atalk/util.h>
54 #include <atalk/bstradd.h>
57 #include "directory.h"
69 u_int16_t attrs; /* File attributes (high 8 bits)*/
70 u_int16_t label; /* Label (low 8 bits )*/
71 char reserved[22]; /* Unknown (at least for now...) */
74 typedef char packed_finder[ADEDLEN_FINDERI];
77 * 0x04 - has a custom icon
78 * 0x20 - name/icon is locked
92 /* This is our search-criteria structure. */
94 u_int32_t rbitmap; /* Request bitmap - which values should we check ? */
95 u_int16_t fbitmap, dbitmap; /* file & directory bitmap - which values should we return ? */
96 u_int16_t attr; /* File attributes */
97 time_t cdate; /* Creation date */
98 time_t mdate; /* Last modification date */
99 time_t bdate; /* Last backup date */
100 u_int32_t pdid; /* Parent DID */
101 u_int16_t offcnt; /* Offspring count */
102 struct finderinfo finfo; /* Finder info */
103 char lname[64]; /* Long name */
104 char utf8name[514]; /* UTF8 or UCS2 name */ /* for convert_charset dest_len parameter +2 */
108 * Directory tree search is recursive by its nature. But AFP specification
109 * requires FPCatSearch to pause after returning n results and be able to
110 * resume the search later. So we have to do recursive search using flat
111 * (iterative) algorithm and remember all directories to look into in an
112 * stack-like structure. The structure below is one item of directory stack.
116 struct dir *dir; /* Structure describing this directory */
117 int pidx; /* Parent's dsitem structure index. */
118 int checked; /* Have we checked this directory ? */
120 char *path; /* absolute UNIX path to this directory */
125 static int save_cidx = -1; /* Saved index of currently scanned directory. */
127 static struct dsitem *dstack = NULL; /* Directory stack data... */
128 static int dssize = 0; /* Directory stack (allocated) size... */
129 static int dsidx = 0; /* First free item index... */
131 static struct scrit c1, c2; /* search criteria */
133 /* Puts new item onto directory stack. */
134 static int addstack(char *uname, struct dir *dir, int pidx)
139 /* check if we have some space on stack... */
140 if (dsidx >= dssize) {
142 dstack = realloc(dstack, dssize * sizeof(struct dsitem));
147 /* Put new element. Allocate and copy lname and path. */
148 ds = dstack + dsidx++;
150 dir->d_flags |= DIRF_CACHELOCK;
154 l = dstack[pidx].path_len;
155 u = strlen(uname) +1;
156 if (!(ds->path = malloc(l + u + 1) ))
158 memcpy(ds->path, dstack[pidx].path, l);
160 memcpy(&ds->path[l+1], uname, u);
164 ds->path = strdup(uname);
165 ds->path_len = strlen(uname);
170 /* Removes checked items from top of directory stack. Returns index of the first unchecked elements or -1. */
171 static int reducestack(void)
174 if (save_cidx != -1) {
181 if (dstack[dsidx-1].checked) {
183 dstack[dsidx].dir->d_flags &= ~DIRF_CACHELOCK;
184 free(dstack[dsidx].path);
191 /* Clears directory stack. */
192 static void clearstack(void)
197 dstack[dsidx].dir->d_flags &= ~DIRF_CACHELOCK;
198 free(dstack[dsidx].path);
202 /* Looks up for an opened adouble structure, opens resource fork of selected file.
203 * FIXME What about noadouble?
205 static struct adouble *adl_lkup(struct vol *vol, struct path *path, struct adouble *adp)
207 static struct adouble ad;
215 isdir = S_ISDIR(path->st.st_mode);
217 if (!isdir && (of = of_findname(path))) {
220 ad_init(&ad, vol->v_adouble, vol->v_ad_options);
224 if ( ad_metadata( path->u_name, ((isdir) ? ADFLAGS_DIR : 0), adp) < 0 ) {
225 adp = NULL; /* FIXME without resource fork adl_lkup will be call again */
231 /* -------------------- */
232 static struct finderinfo *unpack_buffer(struct finderinfo *finfo, char *buffer)
234 memcpy(&finfo->f_type, buffer +FINDERINFO_FRTYPEOFF, sizeof(finfo->f_type));
235 memcpy(&finfo->creator, buffer +FINDERINFO_FRCREATOFF, sizeof(finfo->creator));
236 memcpy(&finfo->attrs, buffer +FINDERINFO_FRFLAGOFF, sizeof(finfo->attrs));
237 memcpy(&finfo->label, buffer +FINDERINFO_FRFLAGOFF, sizeof(finfo->label));
238 finfo->attrs &= 0xff00; /* high 8 bits */
239 finfo->label &= 0xff; /* low 8 bits */
244 /* -------------------- */
245 static struct finderinfo *
246 unpack_finderinfo(struct vol *vol, struct path *path, struct adouble **adp, struct finderinfo *finfo, int islnk)
251 *adp = adl_lkup(vol, path, *adp);
252 ptr = get_finderinfo(vol, path->u_name, *adp, &buf,islnk);
253 return unpack_buffer(finfo, ptr);
256 /* -------------------- */
257 #define CATPBIT_PARTIAL 31
258 /* Criteria checker. This function returns a 2-bit value. */
259 /* bit 0 means if checked file meets given criteria. */
260 /* bit 1 means if it is a directory and we should descent into it. */
262 * fname - our fname (translated to UNIX)
263 * cidx - index in directory stack
265 static int crit_check(struct vol *vol, struct path *path) {
267 u_int16_t attr, flags = CONV_PRECOMPOSE;
268 struct finderinfo *finfo = NULL, finderinfo;
269 struct adouble *adp = NULL;
270 time_t c_date, b_date;
271 u_int32_t ac_date, ab_date;
272 static char convbuf[514]; /* for convert_charset dest_len parameter +2 */
275 islnk=S_ISLNK(path->st.st_mode);
277 if (S_ISDIR(path->st.st_mode)) {
285 /* compute the Mac name
286 * first try without id (it's slow to find it)
287 * An other option would be to call get_id in utompath but
288 * we need to pass parent dir
290 if (!(path->m_name = utompath(vol, path->u_name, 0 , utf8_encoding()) )) {
291 /*retry with the right id */
295 adp = adl_lkup(vol, path, adp);
296 id = get_id(vol, adp, &path->st, path->d_dir->d_did, path->u_name, strlen(path->u_name));
301 /* save the id for getfilparm */
303 if (!(path->m_name = utompath(vol, path->u_name, id , utf8_encoding()))) {
309 /* Kind of optimization:
310 * -- first check things we've already have - filename
311 * -- last check things we get from ad_open()
312 * FIXME strmcp strstr (icase)
315 /* Check for filename */
316 if ((c1.rbitmap & (1<<DIRPBIT_LNAME))) {
317 if ( (size_t)(-1) == (len = convert_string(vol->v_maccharset, CH_UCS2, path->m_name, -1, convbuf, 512)) )
320 if ((c1.rbitmap & (1<<CATPBIT_PARTIAL))) {
321 if (strcasestr_w( (ucs2_t*) convbuf, (ucs2_t*) c1.lname) == NULL)
324 if (strcasecmp_w((ucs2_t*) convbuf, (ucs2_t*) c1.lname) != 0)
328 if ((c1.rbitmap & (1<<FILPBIT_PDINFO))) {
329 if ( (size_t)(-1) == (len = convert_charset( CH_UTF8_MAC, CH_UCS2, CH_UTF8, path->m_name, strlen(path->m_name), convbuf, 512, &flags))) {
333 if (c1.rbitmap & (1<<CATPBIT_PARTIAL)) {
334 if (strcasestr_w((ucs2_t *) convbuf, (ucs2_t*)c1.utf8name) == NULL)
337 if (strcasecmp_w((ucs2_t *)convbuf, (ucs2_t*)c1.utf8name) != 0)
343 if ((unsigned)c2.mdate > 0x7fffffff)
344 c2.mdate = 0x7fffffff;
345 if ((unsigned)c2.cdate > 0x7fffffff)
346 c2.cdate = 0x7fffffff;
347 if ((unsigned)c2.bdate > 0x7fffffff)
348 c2.bdate = 0x7fffffff;
350 /* Check for modification date */
351 if ((c1.rbitmap & (1<<DIRPBIT_MDATE))) {
352 if (path->st.st_mtime < c1.mdate || path->st.st_mtime > c2.mdate)
356 /* Check for creation date... */
357 if ((c1.rbitmap & (1<<DIRPBIT_CDATE))) {
358 c_date = path->st.st_mtime;
359 adp = adl_lkup(vol, path, adp);
360 if (adp && ad_getdate(adp, AD_DATE_CREATE, &ac_date) >= 0)
361 c_date = AD_DATE_TO_UNIX(ac_date);
363 if (c_date < c1.cdate || c_date > c2.cdate)
367 /* Check for backup date... */
368 if ((c1.rbitmap & (1<<DIRPBIT_BDATE))) {
369 b_date = path->st.st_mtime;
370 adp = adl_lkup(vol, path, adp);
371 if (adp && ad_getdate(adp, AD_DATE_BACKUP, &ab_date) >= 0)
372 b_date = AD_DATE_TO_UNIX(ab_date);
374 if (b_date < c1.bdate || b_date > c2.bdate)
378 /* Check attributes */
379 if ((c1.rbitmap & (1<<DIRPBIT_ATTR)) && c2.attr != 0) {
380 if ((adp = adl_lkup(vol, path, adp))) {
381 ad_getattr(adp, &attr);
382 if ((attr & c2.attr) != c1.attr)
388 /* Check file type ID */
389 if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.f_type != 0) {
390 finfo = unpack_finderinfo(vol, path, &adp, &finderinfo,islnk);
391 if (finfo->f_type != c1.finfo.f_type)
395 /* Check creator ID */
396 if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.creator != 0) {
398 finfo = unpack_finderinfo(vol, path, &adp, &finderinfo,islnk);
400 if (finfo->creator != c1.finfo.creator)
404 /* Check finder info attributes */
405 if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.attrs != 0) {
407 finfo = unpack_finderinfo(vol, path, &adp, &finderinfo,islnk);
410 if ((finfo->attrs & c2.finfo.attrs) != c1.finfo.attrs)
415 if ((c1.rbitmap & (1<<DIRPBIT_FINFO)) && c2.finfo.label != 0) {
417 finfo = unpack_finderinfo(vol, path, &adp, &finderinfo,islnk);
419 if ((finfo->label & c2.finfo.label) != c1.finfo.label)
422 /* FIXME: Attributes check ! */
424 /* All criteria are met. */
428 ad_close_metadata(adp);
432 /* ------------------------------ */
433 static int rslt_add ( struct vol *vol, struct path *path, char **buf, int ext)
439 u_int16_t resultsize;
440 int isdir = S_ISDIR(path->st.st_mode);
442 /* Skip resultsize */
444 p += sizeof(resultsize);
449 *p++ = isdir ? FILDIRBIT_ISDIR : FILDIRBIT_ISFILE; /* IsDir ? */
456 ret = getdirparams(vol, c1.dbitmap, path, path->d_dir, p , &tbuf );
459 /* FIXME slow if we need the file ID, we already know it, done ? */
460 ret = getfilparams ( vol, c1.fbitmap, path, path->d_dir, p, &tbuf);
466 /* Make sure entry length is even */
473 resultsize = htons(tbuf);
474 memcpy ( *buf, &resultsize, sizeof(resultsize) );
486 "./../.AppleDouble/.AppleDB/Network Trash Folder/TheVolumeSettingsFolder/TheFindByContentFolder/.AppleDesktop/.Parent/"
488 /* This function performs search. It is called directly from afp_catsearch
489 * vol - volume we are searching on ...
490 * dir - directory we are starting from ...
491 * c1, c2 - search criteria
492 * rmatches - maximum number of matches we can return
493 * pos - position we've stopped recently
494 * rbuf - output buffer
495 * rbuflen - output buffer length
497 #define NUM_ROUNDS 200
498 static int catsearch(struct vol *vol, struct dir *dir,
499 int rmatches, u_int32_t *pos, char *rbuf, u_int32_t *nrecs, int *rsize, int ext)
501 static u_int32_t cur_pos; /* Saved position index (ID) - used to remember "position" across FPCatSearch calls */
502 static DIR *dirpos; /* UNIX structure describing currently opened directory. */
504 struct dirent *entry;
508 char *vpath = vol->v_path;
511 int num_rounds = NUM_ROUNDS;
515 if (*pos != 0 && *pos != cur_pos) {
516 result = AFPERR_CATCHNG;
520 /* FIXME: Category "offspring count ! */
523 /* We need to initialize all mandatory structures/variables and change working directory appropriate... */
526 if (dirpos != NULL) {
531 if (addstack(vpath, dir, -1) == -1) {
532 result = AFPERR_MISC;
535 /* FIXME: Sometimes DID is given by client ! (correct this one above !) */
538 /* Save current path */
539 if ((cwd = open(".", O_RDONLY)) < 0) {
540 result = AFPERR_MISC;
544 /* So we are beginning... */
545 start_time = time(NULL);
547 while ((cidx = reducestack()) != -1) {
548 error = lchdir(dstack[cidx].path);
550 if (!error && dirpos == NULL)
551 dirpos = opendir(".");
554 dirpos = opendir(dstack[cidx].path);
556 if (error || dirpos == NULL) {
559 dstack[cidx].checked = 1;
564 result = AFPERR_NFILE;
569 result = AFPERR_MISC;
570 } /* switch (errno) */
574 while ((entry=readdir(dirpos)) != NULL) {
577 if (!check_dirent(vol, entry->d_name))
580 memset(&path, 0, sizeof(path));
581 path.u_name = entry->d_name;
582 if (of_stat(&path) != 0) {
593 result = AFPERR_MISC;
597 if (S_ISDIR(path.st.st_mode)) {
598 /* here we can short cut
599 ie if in the same loop the parent dir wasn't in the cache
600 ALL dirsearch_byname will fail.
602 int unlen = strlen(path.u_name);
603 path.d_dir = dircache_search_by_name(vol, dstack[cidx].dir, path.u_name, unlen);
604 if (path.d_dir == NULL) {
605 /* path.m_name is set by adddir */
606 if (NULL == (path.d_dir = dir_add( vol, dstack[cidx].dir, &path, unlen) ) ) {
607 result = AFPERR_MISC;
611 path.m_name = cfrombstring(path.d_dir->d_m_name);
613 if (addstack(path.u_name, path.d_dir, cidx) == -1) {
614 result = AFPERR_MISC;
619 /* yes it sucks for directory d_dir is the directory, for file it's the parent directory*/
620 path.d_dir = dstack[cidx].dir;
622 ccr = crit_check(vol, &path);
624 /* bit 0 means that criteria has been met */
626 r = rslt_add ( vol, &path, &rrbuf, ext);
629 result = AFPERR_MISC;
633 /* Number of matches limit */
635 goto catsearch_pause;
636 /* Block size limit */
637 if (rrbuf - rbuf >= 448)
638 goto catsearch_pause;
640 /* MacOS 9 doesn't like servers executing commands longer than few seconds */
641 if (--num_rounds <= 0) {
642 if (start_time != time(NULL)) {
644 goto catsearch_pause;
646 num_rounds = NUM_ROUNDS;
648 } /* while ((entry=readdir(dirpos)) != NULL) */
651 dstack[cidx].checked = 1;
652 } /* while (current_idx = reducestack()) != -1) */
654 /* We have finished traversing our tree. Return EOF here. */
662 catsearch_end: /* Exiting catsearch: error condition */
663 *rsize = rrbuf - rbuf;
665 if ((fchdir(cwd)) != 0) {
666 LOG(log_debug, logtype_afpd, "error chdiring back: %s", strerror(errno));
673 /* -------------------------- */
674 static int catsearch_afp(AFPObj *obj _U_, char *ibuf, size_t ibuflen,
675 char *rbuf, size_t *rbuflen, int ext)
680 u_int32_t rmatches, reserved;
685 unsigned char *spec1, *spec2, *bspec1, *bspec2;
693 /* min header size */
698 memset(&c1, 0, sizeof(c1));
699 memset(&c2, 0, sizeof(c2));
702 memcpy(&vid, ibuf, sizeof(vid));
705 if ((vol = getvolbyvid(vid)) == NULL) {
709 memcpy(&rmatches, ibuf, sizeof(rmatches));
710 rmatches = ntohl(rmatches);
711 ibuf += sizeof(rmatches);
713 /* FIXME: (rl) should we check if reserved == 0 ? */
714 ibuf += sizeof(reserved);
716 memcpy(catpos, ibuf, sizeof(catpos));
717 ibuf += sizeof(catpos);
719 memcpy(&c1.fbitmap, ibuf, sizeof(c1.fbitmap));
720 c1.fbitmap = c2.fbitmap = ntohs(c1.fbitmap);
721 ibuf += sizeof(c1.fbitmap);
723 memcpy(&c1.dbitmap, ibuf, sizeof(c1.dbitmap));
724 c1.dbitmap = c2.dbitmap = ntohs(c1.dbitmap);
725 ibuf += sizeof(c1.dbitmap);
727 memcpy(&c1.rbitmap, ibuf, sizeof(c1.rbitmap));
728 c1.rbitmap = c2.rbitmap = ntohl(c1.rbitmap);
729 ibuf += sizeof(c1.rbitmap);
731 if (! (c1.fbitmap || c1.dbitmap)) {
732 return AFPERR_BITMAP;
736 memcpy(&spec_len, ibuf, sizeof(spec_len));
737 spec_len = ntohs(spec_len);
740 /* with catsearch only name and parent id are allowed */
741 c1.fbitmap &= (1<<FILPBIT_LNAME) | (1<<FILPBIT_PDID);
742 c1.dbitmap &= (1<<DIRPBIT_LNAME) | (1<<DIRPBIT_PDID);
743 spec_len = *(unsigned char*)ibuf;
746 /* Parse file specifications */
747 spec1 = (unsigned char*)ibuf;
748 spec2 = (unsigned char*)ibuf + spec_len + 2;
755 /* File attribute bits... */
756 if (c1.rbitmap & (1 << FILPBIT_ATTR)) {
757 memcpy(&c1.attr, spec1, sizeof(c1.attr));
758 spec1 += sizeof(c1.attr);
759 memcpy(&c2.attr, spec2, sizeof(c2.attr));
760 spec2 += sizeof(c1.attr);
764 if (c1.rbitmap & (1 << FILPBIT_PDID)) {
765 memcpy(&c1.pdid, spec1, sizeof(pdid));
766 spec1 += sizeof(c1.pdid);
767 memcpy(&c2.pdid, spec2, sizeof(pdid));
768 spec2 += sizeof(c2.pdid);
769 } /* FIXME: PDID - do we demarshall this argument ? */
772 if (c1.rbitmap & (1 << FILPBIT_CDATE)) {
773 memcpy(&c1.cdate, spec1, sizeof(c1.cdate));
774 spec1 += sizeof(c1.cdate);
775 c1.cdate = AD_DATE_TO_UNIX(c1.cdate);
776 memcpy(&c2.cdate, spec2, sizeof(c2.cdate));
777 spec2 += sizeof(c1.cdate);
778 ibuf += sizeof(c1.cdate);;
779 c2.cdate = AD_DATE_TO_UNIX(c2.cdate);
782 /* Modification date */
783 if (c1.rbitmap & (1 << FILPBIT_MDATE)) {
784 memcpy(&c1.mdate, spec1, sizeof(c1.mdate));
785 c1.mdate = AD_DATE_TO_UNIX(c1.mdate);
786 spec1 += sizeof(c1.mdate);
787 memcpy(&c2.mdate, spec2, sizeof(c2.mdate));
788 c2.mdate = AD_DATE_TO_UNIX(c2.mdate);
789 spec2 += sizeof(c1.mdate);
793 if (c1.rbitmap & (1 << FILPBIT_BDATE)) {
794 memcpy(&c1.bdate, spec1, sizeof(c1.bdate));
795 spec1 += sizeof(c1.bdate);
796 c1.bdate = AD_DATE_TO_UNIX(c1.bdate);
797 memcpy(&c2.bdate, spec2, sizeof(c2.bdate));
798 spec2 += sizeof(c2.bdate);
799 c1.bdate = AD_DATE_TO_UNIX(c2.bdate);
803 if (c1.rbitmap & (1 << FILPBIT_FINFO)) {
806 memcpy(buf, spec1, sizeof(buf));
807 unpack_buffer(&c1.finfo, buf);
808 spec1 += sizeof(buf);
810 memcpy(buf, spec2, sizeof(buf));
811 unpack_buffer(&c2.finfo, buf);
812 spec2 += sizeof(buf);
815 if ((c1.rbitmap & (1 << DIRPBIT_OFFCNT)) != 0) {
816 /* Offspring count - only directories */
817 if (c1.fbitmap == 0) {
818 memcpy(&c1.offcnt, spec1, sizeof(c1.offcnt));
819 spec1 += sizeof(c1.offcnt);
820 c1.offcnt = ntohs(c1.offcnt);
821 memcpy(&c2.offcnt, spec2, sizeof(c2.offcnt));
822 spec2 += sizeof(c2.offcnt);
823 c2.offcnt = ntohs(c2.offcnt);
825 else if (c1.dbitmap == 0) {
826 /* ressource fork length */
829 return AFPERR_BITMAP; /* error */
831 } /* Offspring count/ressource fork length */
834 if (c1.rbitmap & (1 << FILPBIT_LNAME)) {
835 /* Get the long filename */
836 memcpy(tmppath, bspec1 + spec1[1] + 1, (bspec1 + spec1[1])[0]);
837 tmppath[(bspec1 + spec1[1])[0]]= 0;
838 len = convert_string ( vol->v_maccharset, CH_UCS2, tmppath, -1, c1.lname, sizeof(c1.lname));
839 if (len == (size_t)(-1))
843 /* FIXME: do we need it ? It's always null ! */
844 memcpy(c2.lname, bspec2 + spec2[1] + 1, (bspec2 + spec2[1])[0]);
845 c2.lname[(bspec2 + spec2[1])[0]]= 0;
849 if (c1.rbitmap & (1 << FILPBIT_PDINFO)) {
852 memcpy(&namelen, spec1, sizeof(namelen));
853 namelen = ntohs (namelen);
855 spec1 = bspec1+namelen+4; /* Skip Unicode Hint */
858 memcpy(&namelen, spec1, sizeof(namelen));
859 namelen = ntohs (namelen);
860 if (namelen > 255) /* Safeguard */
863 memcpy (c1.utf8name, spec1+2, namelen);
864 c1.utf8name[(namelen+1)] =0;
866 /* convert charset */
867 flags = CONV_PRECOMPOSE;
868 len = convert_charset(CH_UTF8_MAC, CH_UCS2, CH_UTF8, c1.utf8name, namelen, c1.utf8name, 512, &flags);
869 if (len == (size_t)(-1))
875 ret = catsearch(vol, vol->v_root, rmatches, &catpos[0], rbuf+24, &nrecs, &rsize, ext);
876 memcpy(rbuf, catpos, sizeof(catpos));
877 rbuf += sizeof(catpos);
879 c1.fbitmap = htons(c1.fbitmap);
880 memcpy(rbuf, &c1.fbitmap, sizeof(c1.fbitmap));
881 rbuf += sizeof(c1.fbitmap);
883 c1.dbitmap = htons(c1.dbitmap);
884 memcpy(rbuf, &c1.dbitmap, sizeof(c1.dbitmap));
885 rbuf += sizeof(c1.dbitmap);
887 nrecs = htonl(nrecs);
888 memcpy(rbuf, &nrecs, sizeof(nrecs));
889 rbuf += sizeof(nrecs);
893 } /* catsearch_afp */
895 /* -------------------------- */
896 int afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen,
897 char *rbuf, size_t *rbuflen)
899 return catsearch_afp( obj, ibuf, ibuflen, rbuf, rbuflen, 0);
903 int afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen,
904 char *rbuf, size_t *rbuflen)
906 return catsearch_afp( obj, ibuf, ibuflen, rbuf, rbuflen, 1);
909 /* FIXME: we need a clean separation between afp stubs and 'real' implementation */
910 /* (so, all buffer packing/unpacking should be done in stub, everything else
911 should be done in other functions) */