=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.72 retrieving revision 1.73 diff -c -r1.72 -r1.73 *** src/usr.bin/cvs/file.c 2005/05/20 05:01:34 1.72 --- src/usr.bin/cvs/file.c 2005/05/20 05:13:44 1.73 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.72 2005/05/20 05:01:34 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.73 2005/05/20 05:13:44 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 107,114 **** TAILQ_HEAD(, cvs_ignpat) cvs_ign_pats; static int cvs_load_dirinfo (CVSFILE *, int); - static int cvs_file_getdir (CVSFILE *, int, char *); static int cvs_file_sort (struct cvs_flist *, u_int); static int cvs_file_cmp (const void *, const void *); static int cvs_file_cmpname (const char *, const char *); --- 107,114 ---- TAILQ_HEAD(, cvs_ignpat) cvs_ign_pats; + static int cvs_file_getdir(CVSFILE *, int, char *, int (*)(CVSFILE *, void *), void *); static int cvs_load_dirinfo (CVSFILE *, int); static int cvs_file_sort (struct cvs_flist *, u_int); static int cvs_file_cmp (const void *, const void *); static int cvs_file_cmpname (const char *, const char *); *************** *** 345,356 **** */ CVSFILE* ! cvs_file_get(const char *path, int flags) { char *files[1]; files[0] = path; ! return cvs_file_getspec(files, 1, flags); } --- 345,357 ---- */ CVSFILE* ! cvs_file_get(const char *path, int flags, int (*cb)(CVSFILE *, void *), ! void *arg) { char *files[1]; files[0] = path; ! return cvs_file_getspec(files, 1, flags, cb, arg); } *************** *** 363,369 **** * files. */ CVSFILE* ! cvs_file_getspec(char **fspec, int fsn, int flags) { int i; int pwd; --- 364,371 ---- * files. */ CVSFILE* ! cvs_file_getspec(char **fspec, int fsn, int flags, int (*cb)(CVSFILE *, void *), ! void *arg) { int i; int pwd; *************** *** 377,382 **** --- 379,392 ---- if (base == NULL) return (NULL); + /* XXX - needed for some commands */ + if (cb != NULL) { + if (cb(base, arg) != CVS_EX_OK) { + cvs_file_free(base); + return (NULL); + } + } + for (i = 0; i < fsn; i++) { strlcpy(pcopy, fspec[i], sizeof(pcopy)); sp = pcopy; *************** *** 412,421 **** if (np != NULL) *np++; ! if (cvs_file_getdir(nf, flags, np) < 0) { cvs_file_free(base); return (NULL); } } } --- 422,436 ---- if (np != NULL) *np++; ! if (cvs_file_getdir(nf, flags, np, cb, arg) < 0) { cvs_file_free(base); return (NULL); } + } else { + if (cb != NULL) { + if (cb(nf, arg) != CVS_EX_OK) + return (NULL); + } } } *************** *** 591,597 **** * is performed by cvs_file_free(). */ static int ! cvs_file_getdir(CVSFILE *cf, int flags, char *path) { int l; int check_entry; --- 606,612 ---- * is performed by cvs_file_free(). */ static int ! cvs_file_getdir(CVSFILE *cf, int flags, char *path, int (*cb)(CVSFILE *, void *), void *arg) { int l; int check_entry; *************** *** 630,635 **** --- 645,656 ---- if ((flags & CF_KNOWN) && (cf->cf_cvstat == CVS_FST_UNKNOWN)) return (0); + /* callback for the directory entry */ + if (cb != NULL) { + if (cb(cf, arg) != CVS_EX_OK) + return (-1); + } + dirp = opendir(fpath); if (dirp == NULL) { cvs_log(LP_ERRNO, "failed to open directory %s", fpath); *************** *** 699,704 **** --- 720,733 ---- if (cfp->cf_type == DT_DIR) { ndirs++; SIMPLEQ_INSERT_TAIL(&dirs, cfp, cf_list); + } else { + /* callback for the file */ + if (cb != NULL) { + if (cb(cfp, arg) != CVS_EX_OK) { + closedir(dirp); + return (-1); + } + } } if (path != NULL) { *************** *** 743,748 **** --- 772,783 ---- ndirs++; SIMPLEQ_INSERT_TAIL(&dirs, cfp, cf_list); + } else { + /* callback for the file */ + if (cb != NULL) { + if (cb(cfp, arg) != CVS_EX_OK) + return (-1); + } } if (path != NULL) *************** *** 767,773 **** else cfp->cf_flags &= ~CVS_GDIR_IGNORE; ! if (cvs_file_getdir(cfp, flags, np) < 0) { cvs_log(LP_ERROR, "failed to get %s", CVS_FILE_NAME(cfp)); continue; --- 802,808 ---- else cfp->cf_flags &= ~CVS_GDIR_IGNORE; ! if (cvs_file_getdir(cfp, flags, np, cb, arg) < 0) { cvs_log(LP_ERROR, "failed to get %s", CVS_FILE_NAME(cfp)); continue;