version 1.114, 2005/08/17 08:35:53 |
version 1.115, 2005/08/17 16:23:19 |
|
|
static int cvs_file_cmp(const void *, const void *); |
static int cvs_file_cmp(const void *, const void *); |
static int cvs_file_cmpname(const char *, const char *); |
static int cvs_file_cmpname(const char *, const char *); |
static CVSFILE *cvs_file_alloc(const char *, u_int); |
static CVSFILE *cvs_file_alloc(const char *, u_int); |
static CVSFILE *cvs_file_lget(const char *, int, CVSFILE *, struct cvs_ent *); |
static CVSFILE *cvs_file_lget(const char *, int, CVSFILE *, CVSENTRIES *, |
|
struct cvs_ent *); |
|
|
|
|
/* |
/* |
|
|
* Fetch the needed information about ".", so we can setup a few |
* Fetch the needed information about ".", so we can setup a few |
* things to get ourselfs going. |
* things to get ourselfs going. |
*/ |
*/ |
cf = cvs_file_lget(".", 0, NULL, NULL); |
cf = cvs_file_lget(".", 0, NULL, NULL, NULL); |
if (cf == NULL) { |
if (cf == NULL) { |
cvs_log(LP_ERR, "arrrr i failed captain!"); |
cvs_log(LP_ERR, "arrrr i failed captain!"); |
return (-1); |
return (-1); |
|
|
* There might not be an Entries file, so do not fail if there |
* There might not be an Entries file, so do not fail if there |
* is none available to get the info from. |
* is none available to get the info from. |
*/ |
*/ |
entf = cvs_ent_open(parent, O_RDONLY); |
entf = cvs_ent_open(parent, O_RDWR); |
|
|
/* |
/* |
* Load the Entry if we successfully opened the Entries file. |
* Load the Entry if we successfully opened the Entries file. |
|
|
* <path> for a directory. |
* <path> for a directory. |
*/ |
*/ |
if (type == DT_DIR) |
if (type == DT_DIR) |
base = cvs_file_lget(path, flags, NULL, ent); |
base = cvs_file_lget(path, flags, NULL, entf, ent); |
else |
else |
base = cvs_file_lget(parent, flags, NULL, NULL); |
base = cvs_file_lget(parent, flags, NULL, entf, NULL); |
|
|
if (base == NULL) { |
if (base == NULL) { |
cvs_log(LP_ERR, "failed to obtain directory info for '%s'", |
cvs_log(LP_ERR, "failed to obtain directory info for '%s'", |
|
|
* to the base. |
* to the base. |
*/ |
*/ |
if (type != DT_DIR) { |
if (type != DT_DIR) { |
cf = cvs_file_lget(path, flags, base, ent); |
cf = cvs_file_lget(path, flags, base, entf, ent); |
if (cf == NULL) { |
if (cf == NULL) { |
cvs_error = CVS_EX_DATA; |
cvs_error = CVS_EX_DATA; |
goto fail; |
goto fail; |
|
|
cvs_file_attach(base, cf); |
cvs_file_attach(base, cf); |
} |
} |
|
|
if (entf != NULL) { |
|
cvs_ent_close(entf); |
|
entf = NULL; |
|
} |
|
|
|
/* |
/* |
* Always pass the base directory, unless: |
* Always pass the base directory, unless: |
* - we are running in server or local mode and the path is not "." |
* - we are running in server or local mode and the path is not "." |
|
|
((cvs_error = cb(base, arg)) != CVS_EX_OK)) |
((cvs_error = cb(base, arg)) != CVS_EX_OK)) |
goto fail; |
goto fail; |
|
|
|
if (entf != NULL) { |
|
cvs_ent_close(entf); |
|
entf = NULL; |
|
} |
|
|
/* |
/* |
* If we have a normal file, pass it as well. |
* If we have a normal file, pass it as well. |
*/ |
*/ |
|
|
} |
} |
|
|
ret = -1; |
ret = -1; |
entf = cvs_ent_open(fpath, O_RDONLY); |
entf = cvs_ent_open(fpath, O_RDWR); |
while ((de = readdir(dp)) != NULL) { |
while ((de = readdir(dp)) != NULL) { |
if (!strcmp(de->d_name, ".") || |
if (!strcmp(de->d_name, ".") || |
!strcmp(de->d_name, "..")) |
!strcmp(de->d_name, "..")) |
|
|
else |
else |
ent = NULL; |
ent = NULL; |
|
|
cfp = cvs_file_lget(pbuf, flags, cf, ent); |
cfp = cvs_file_lget(pbuf, flags, cf, entf, ent); |
if (cfp == NULL) { |
if (cfp == NULL) { |
cvs_log(LP_ERR, "failed to get '%s'", pbuf); |
cvs_log(LP_ERR, "failed to get '%s'", pbuf); |
goto done; |
goto done; |
|
|
if (len >= sizeof(pbuf)) |
if (len >= sizeof(pbuf)) |
goto done; |
goto done; |
|
|
cfp = cvs_file_lget(pbuf, flags, cf, ent); |
cfp = cvs_file_lget(pbuf, flags, cf, entf, ent); |
if (cfp == NULL) { |
if (cfp == NULL) { |
cvs_log(LP_ERR, "failed to fetch '%s'", pbuf); |
cvs_log(LP_ERR, "failed to fetch '%s'", pbuf); |
goto done; |
goto done; |
|
|
* failure. |
* failure. |
*/ |
*/ |
static CVSFILE * |
static CVSFILE * |
cvs_file_lget(const char *path, int flags, CVSFILE *parent, struct cvs_ent *ent) |
cvs_file_lget(const char *path, int flags, CVSFILE *parent, CVSENTRIES *pent, |
|
struct cvs_ent *ent) |
{ |
{ |
int ret; |
int ret; |
u_int type; |
u_int type; |
|
|
if ((cfp = cvs_file_alloc(path, type)) == NULL) |
if ((cfp = cvs_file_alloc(path, type)) == NULL) |
return (NULL); |
return (NULL); |
cfp->cf_parent = parent; |
cfp->cf_parent = parent; |
|
cfp->cf_entry = pent; |
|
|
if ((cfp->cf_type == DT_DIR) && (cfp->cf_parent == NULL)) |
if ((cfp->cf_type == DT_DIR) && (cfp->cf_parent == NULL)) |
cfp->cf_flags |= CVS_DIRF_BASE; |
cfp->cf_flags |= CVS_DIRF_BASE; |
|
|
} |
} |
} |
} |
|
|
if ((cfp->cf_type == DT_DIR) && (cvs_load_dirinfo(cfp, flags) < 0)) { |
if (cfp->cf_type == DT_DIR) { |
cvs_file_free(cfp); |
if (cvs_load_dirinfo(cfp, flags) < 0) { |
return (NULL); |
cvs_file_free(cfp); |
|
return (NULL); |
|
} |
} |
} |
|
|
if ((cfp->cf_repo != NULL) && (cfp->cf_type == DT_DIR) && |
if ((cfp->cf_repo != NULL) && (cfp->cf_type == DT_DIR) && |