version 1.51, 2005/07/26 14:58:58 |
version 1.52, 2005/08/02 12:06:38 |
|
|
*/ |
*/ |
static char cvs_resp_lastdir[MAXPATHLEN] = ""; |
static char cvs_resp_lastdir[MAXPATHLEN] = ""; |
static CVSENTRIES *cvs_resp_lastent = NULL; |
static CVSENTRIES *cvs_resp_lastent = NULL; |
static int resp_check_dir(const char *); |
static int resp_check_dir(struct cvsroot *, const char *); |
|
|
/* |
/* |
* The MT command uses scoping to tag the data. Whenever we encouter a '+', |
* The MT command uses scoping to tag the data. Whenever we encouter a '+', |
|
|
struct cvs_ent *ent; |
struct cvs_ent *ent; |
char *file, subdir[MAXPATHLEN], buf[MAXPATHLEN]; |
char *file, subdir[MAXPATHLEN], buf[MAXPATHLEN]; |
|
|
|
entf = NULL; |
|
cf = NULL; |
cvs_splitpath(line, subdir, sizeof(subdir), &file); |
cvs_splitpath(line, subdir, sizeof(subdir), &file); |
base = cvs_file_loadinfo(subdir, CF_NOFILES, NULL, NULL, 1); |
base = cvs_file_loadinfo(subdir, CF_NOFILES, NULL, NULL, 1); |
if (base == NULL) |
if (base == NULL) |
|
|
} |
} |
|
|
cf = cvs_file_create(base, line, DT_DIR, 0755); |
cf = cvs_file_create(base, line, DT_DIR, 0755); |
if (cf == NULL) { |
} else { |
cvs_file_free(base); |
cf = cvs_file_loadinfo(line, CF_NOFILES, NULL, NULL, 1); |
return (-1); |
} |
} |
|
|
|
/* |
if (cf == NULL) { |
* If the Entries file for the parent is already |
cvs_file_free(base); |
* open, operate on that, instead of reopening it |
return (-1); |
* and invalidating the opened list. |
} |
*/ |
|
if (!strcmp(subdir, cvs_resp_lastdir)) |
|
entf = cvs_resp_lastent; |
|
else |
|
entf = cvs_ent_open(subdir, O_WRONLY); |
|
|
|
/* add a directory entry to the parent */ |
/* |
if (entf != NULL) { |
* If the Entries file for the parent is already |
if ((ent = cvs_ent_get(entf, cf->cf_name)) == NULL) { |
* open, operate on that, instead of reopening it |
snprintf(buf, sizeof(buf), "D/%s////", |
* and invalidating the opened list. |
cf->cf_name); |
*/ |
ent = cvs_ent_parse(buf); |
if (!strcmp(subdir, cvs_resp_lastdir)) |
if (ent == NULL) |
entf = cvs_resp_lastent; |
cvs_log(LP_ERR, |
else |
"failed to create directory entry"); |
entf = cvs_ent_open(subdir, O_WRONLY); |
else |
|
cvs_ent_add(entf, ent); |
/* |
|
* see if the entry is still present. If not, we add it again. |
|
*/ |
|
if (entf != NULL) { |
|
if ((ent = cvs_ent_get(entf, cf->cf_name)) == NULL) { |
|
l = snprintf(buf, sizeof(buf), "D/%s////", cf->cf_name); |
|
if (l == -1 || l >= (int)sizeof(buf)) { |
|
cvs_file_free(cf); |
|
cvs_file_free(base); |
|
return (-1); |
} |
} |
|
|
if (strcmp(subdir, cvs_resp_lastdir)) |
ent = cvs_ent_parse(buf); |
cvs_ent_close(entf); |
if (ent == NULL) |
|
cvs_log(LP_ERR, |
|
"failed to create directory entry"); |
|
else |
|
cvs_ent_add(entf, ent); |
} |
} |
|
|
cvs_file_free(cf); |
if (strcmp(subdir, cvs_resp_lastdir)) |
|
cvs_ent_close(entf); |
} |
} |
|
|
|
cvs_file_free(cf); |
cvs_file_free(base); |
cvs_file_free(base); |
return (0); |
return (0); |
} |
} |
|
|
if (cvs_getln(root, entbuf, sizeof(entbuf)) < 0) |
if (cvs_getln(root, entbuf, sizeof(entbuf)) < 0) |
return (-1); |
return (-1); |
|
|
if (resp_check_dir(line) < 0) |
if (resp_check_dir(root, line) < 0) |
return (-1); |
return (-1); |
|
|
if (type == CVS_RESP_NEWENTRY) { |
if (type == CVS_RESP_NEWENTRY) { |
|
|
} |
} |
ret = 0; |
ret = 0; |
|
|
if (resp_check_dir(line) < 0) |
/* |
|
* Please be sure the directory does exist. |
|
*/ |
|
if (cvs_resp_createdir(line) < 0) |
return (-1); |
return (-1); |
|
|
|
if (resp_check_dir(root, line) < 0) |
|
return (-1); |
|
|
if (cvs_modtime != CVS_DATE_DMSEC) { |
if (cvs_modtime != CVS_DATE_DMSEC) { |
ent->ce_mtime = cvs_modtime; |
ent->ce_mtime = cvs_modtime; |
} else |
} else |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
if (resp_check_dir(line) < 0) |
if (resp_check_dir(root, line) < 0) |
return (-1); |
return (-1); |
|
|
(void)cvs_ent_remove(cvs_resp_lastent, file); |
(void)cvs_ent_remove(cvs_resp_lastent, file); |
|
|
* received directory, if it's not, switch Entry files. |
* received directory, if it's not, switch Entry files. |
*/ |
*/ |
static int |
static int |
resp_check_dir(const char *dir) |
resp_check_dir(struct cvsroot *root, const char *dir) |
{ |
{ |
|
int l; |
size_t len; |
size_t len; |
|
char cvspath[MAXPATHLEN], repo[MAXPATHLEN]; |
|
struct stat st; |
|
|
|
/* |
|
* Make sure the CVS directory exists. |
|
*/ |
|
l = snprintf(cvspath, sizeof(cvspath), "%s/%s", dir, CVS_PATH_CVSDIR); |
|
if (l == -1 || l >= (int)sizeof(cvspath)) |
|
return (-1); |
|
|
|
if (stat(cvspath, &st) == -1) { |
|
if (errno != ENOENT) |
|
return (-1); |
|
if (cvs_repo_base != NULL) { |
|
l = snprintf(repo, sizeof(repo), "%s/%s", cvs_repo_base, |
|
dir); |
|
if (l == -1 || l >= (int)sizeof(repo)) |
|
return (-1); |
|
} else { |
|
strlcpy(repo, dir, sizeof(repo)); |
|
} |
|
|
|
if (cvs_mkadmin(dir, root->cr_str, repo) < 0) |
|
return (-1); |
|
} |
|
|
if (strcmp(dir, cvs_resp_lastdir)) { |
if (strcmp(dir, cvs_resp_lastdir)) { |
if (cvs_resp_lastent != NULL) |
if (cvs_resp_lastent != NULL) |