version 1.20, 2004/12/22 00:38:26 |
version 1.21, 2005/04/16 18:07:35 |
|
|
int |
int |
cvs_readrepo(const char *dir, char *dst, size_t len) |
cvs_readrepo(const char *dir, char *dst, size_t len) |
{ |
{ |
|
int l; |
size_t dlen; |
size_t dlen; |
FILE *fp; |
FILE *fp; |
char repo_path[MAXPATHLEN]; |
char repo_path[MAXPATHLEN]; |
|
|
snprintf(repo_path, sizeof(repo_path), "%s/CVS/Repository", dir); |
l = snprintf(repo_path, sizeof(repo_path), "%s/CVS/Repository", dir); |
|
if (l == -1 || l >= (int)sizeof(repo_path)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", repo_path); |
|
return (NULL); |
|
} |
|
|
fp = fopen(repo_path, "r"); |
fp = fopen(repo_path, "r"); |
if (fp == NULL) { |
if (fp == NULL) |
return (-1); |
return (-1); |
} |
|
|
|
if (fgets(dst, (int)len, fp) == NULL) { |
if (fgets(dst, (int)len, fp) == NULL) { |
if (ferror(fp)) { |
if (ferror(fp)) { |
|
|
int |
int |
cvs_mkadmin(CVSFILE *cdir, mode_t mode) |
cvs_mkadmin(CVSFILE *cdir, mode_t mode) |
{ |
{ |
|
int l; |
char dpath[MAXPATHLEN], path[MAXPATHLEN]; |
char dpath[MAXPATHLEN], path[MAXPATHLEN]; |
FILE *fp; |
FILE *fp; |
CVSENTRIES *ef; |
CVSENTRIES *ef; |
|
|
|
|
cvs_file_getpath(cdir, dpath, sizeof(dpath)); |
cvs_file_getpath(cdir, dpath, sizeof(dpath)); |
|
|
snprintf(path, sizeof(path), "%s/" CVS_PATH_CVSDIR, dpath); |
l = snprintf(path, sizeof(path), "%s/" CVS_PATH_CVSDIR, dpath); |
|
if (l == -1 || l >= (int)sizeof(path)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", path); |
|
return (-1); |
|
} |
|
|
if ((mkdir(path, mode) == -1) && (errno != EEXIST)) { |
if ((mkdir(path, mode) == -1) && (errno != EEXIST)) { |
cvs_log(LP_ERRNO, "failed to create directory %s", path); |
cvs_log(LP_ERRNO, "failed to create directory %s", path); |
return (-1); |
return (-1); |
|
|
(void)cvs_ent_close(ef); |
(void)cvs_ent_close(ef); |
|
|
root = cdir->cf_ddat->cd_root; |
root = cdir->cf_ddat->cd_root; |
snprintf(path, sizeof(path), "%s/" CVS_PATH_ROOTSPEC, dpath); |
l = snprintf(path, sizeof(path), "%s/" CVS_PATH_ROOTSPEC, dpath); |
|
if (l == -1 || l >= (int)sizeof(path)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", path); |
|
return (-1); |
|
} |
|
|
if ((root != NULL) && (stat(path, &st) != 0) && (errno == ENOENT)) { |
if ((root != NULL) && (stat(path, &st) != 0) && (errno == ENOENT)) { |
fp = fopen(path, "w"); |
fp = fopen(path, "w"); |
if (fp == NULL) { |
if (fp == NULL) { |
|
|
} |
} |
|
|
snprintf(path, sizeof(path), "%s/" CVS_PATH_REPOSITORY, dpath); |
snprintf(path, sizeof(path), "%s/" CVS_PATH_REPOSITORY, dpath); |
|
if (l == -1 || l >= (int)sizeof(path)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", path); |
|
return (-1); |
|
} |
|
|
if ((stat(path, &st) != 0) && (errno == ENOENT) && |
if ((stat(path, &st) != 0) && (errno == ENOENT) && |
(cdir->cf_ddat->cd_repo != NULL)) { |
(cdir->cf_ddat->cd_repo != NULL)) { |
fp = fopen(path, "w"); |
fp = fopen(path, "w"); |