version 1.29, 2005/05/26 22:25:31 |
version 1.30, 2005/05/27 17:04:59 |
|
|
char buf[32], ms[4], *sp, *ep; |
char buf[32], ms[4], *sp, *ep; |
|
|
m = 0; |
m = 0; |
strlcpy(buf, str, sizeof(buf)); |
if (strlcpy(buf, str, sizeof(buf)) >= sizeof(buf)) { |
|
return (-1); |
|
} |
sp = buf; |
sp = buf; |
ep = sp; |
ep = sp; |
|
|
|
|
/* |
/* |
* cvs_modetostr() |
* cvs_modetostr() |
* |
* |
|
* Generate a CVS-format string to represent the permissions mask on a file |
|
* from the mode <mode> and store the result in <buf>, which can accept up to |
|
* <len> bytes (including the terminating NUL byte). The result is guaranteed |
|
* to be NUL-terminated. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
int |
int |
|
|
return (0); |
return (0); |
} |
} |
|
|
|
|
/* |
/* |
* cvs_cksum() |
* cvs_cksum() |
* |
* |
|
|
return (0); |
return (0); |
} |
} |
|
|
|
|
/* |
/* |
* cvs_splitpath() |
* cvs_splitpath() |
* |
* |
|
|
* Allocate an argument vector large enough to accommodate for all the |
* Allocate an argument vector large enough to accommodate for all the |
* arguments found in <line> and return it. |
* arguments found in <line> and return it. |
*/ |
*/ |
|
|
char** |
char** |
cvs_makeargv(const char *line, int *argc) |
cvs_makeargv(const char *line, int *argc) |
{ |
{ |
|
|
} |
} |
|
|
/* |
/* |
* remove a directory tree from disk. |
* cvs_remove_dir() |
|
* |
|
* Remove a directory tree from disk. |
|
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
int |
int |
cvs_remove_dir(const char *path) |
cvs_remove_dir(const char *path) |
{ |
{ |
int l, ret; |
size_t len; |
DIR *dirp; |
DIR *dirp; |
struct dirent *ent; |
struct dirent *ent; |
char fpath[MAXPATHLEN]; |
char fpath[MAXPATHLEN]; |
|
|
if ((dirp = opendir(path)) == NULL) { |
if ((dirp = opendir(path)) == NULL) { |
cvs_log(LP_ERRNO, "failed to open '%s'", path); |
cvs_log(LP_ERRNO, "failed to open '%s'", path); |
return (CVS_EX_FILE); |
return (-1); |
} |
} |
|
|
while ((ent = readdir(dirp)) != NULL) { |
while ((ent = readdir(dirp)) != NULL) { |
|
|
!strcmp(ent->d_name, "..")) |
!strcmp(ent->d_name, "..")) |
continue; |
continue; |
|
|
l = snprintf(fpath, sizeof(fpath), "%s/%s", path, ent->d_name); |
len = cvs_path_cat(path, ent->d_name, fpath, sizeof(fpath)); |
if (l == -1 || l >= (int)sizeof(fpath)) { |
if (len >= sizeof(fpath)) { |
errno = ENAMETOOLONG; |
errno = ENAMETOOLONG; |
cvs_log(LP_ERRNO, "%s", fpath); |
cvs_log(LP_ERRNO, "%s", fpath); |
closedir(dirp); |
closedir(dirp); |
return (CVS_EX_FILE); |
return (-1); |
} |
} |
|
|
if (ent->d_type == DT_DIR) { |
if (ent->d_type == DT_DIR) { |
if ((ret = cvs_remove_dir(fpath)) != CVS_EX_OK) { |
if (cvs_remove_dir(fpath) == -1) { |
closedir(dirp); |
closedir(dirp); |
return (ret); |
return (-1); |
} |
} |
} else { |
} else if ((unlink(fpath) == -1) && (errno != ENOENT)) { |
if ((unlink(fpath) == -1) && (errno != ENOENT)) |
cvs_log(LP_ERRNO, "failed to remove '%s'", fpath); |
cvs_log(LP_ERRNO, "failed to remove '%s'", |
return (-1); |
fpath); |
|
} |
} |
} |
} |
|
|
closedir(dirp); |
closedir(dirp); |
|
|
if ((rmdir(path) == -1) && (errno != ENOENT)) |
if ((rmdir(path) == -1) && (errno != ENOENT)) { |
cvs_log(LP_ERRNO, "failed to remove '%s'", path); |
cvs_log(LP_ERRNO, "failed to remove '%s'", path); |
|
return (-1); |
|
} |
|
|
return (CVS_EX_OK); |
return (0); |
} |
} |
|
|
|
/* |
|
* cvs_path_cat() |
|
* |
|
* Concatenate the two paths <base> and <end> and store the generated path |
|
* into the buffer <dst>, which can accept up to <dlen> bytes, including the |
|
* NUL byte. The result is guaranteed to be NUL-terminated. |
|
* Returns the number of bytes necessary to store the full resulting path, |
|
* not including the NUL byte (a value equal to or larger than <dlen> |
|
* indicates truncation). |
|
*/ |
size_t |
size_t |
cvs_path_cat(const char *base, const char *end, char *dst, size_t dlen) |
cvs_path_cat(const char *base, const char *end, char *dst, size_t dlen) |
{ |
{ |