version 1.50, 2005/05/09 19:24:07 |
version 1.51, 2005/05/12 23:01:35 |
|
|
int |
int |
cvs_sendfile(struct cvsroot *root, const char *path) |
cvs_sendfile(struct cvsroot *root, const char *path) |
{ |
{ |
int fd; |
int fd, l; |
ssize_t ret; |
ssize_t ret; |
char buf[4096]; |
char buf[4096]; |
struct stat st; |
struct stat st; |
|
|
(void)close(fd); |
(void)close(fd); |
return (-1); |
return (-1); |
} |
} |
snprintf(buf, sizeof(buf), "%lld\n", st.st_size); |
l = snprintf(buf, sizeof(buf), "%lld\n", st.st_size); |
|
if (l == -1 || l >= (int)sizeof(buf)) |
|
return (-1); |
|
|
if (cvs_sendln(root, buf) < 0) { |
if (cvs_sendln(root, buf) < 0) { |
(void)close(fd); |
(void)close(fd); |
return (-1); |
return (-1); |
|
|
int |
int |
cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg) |
cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg) |
{ |
{ |
int ret; |
int ret, l; |
struct cvs_req *req; |
struct cvs_req *req; |
|
|
if (root->cr_srvin == NULL) { |
if (root->cr_srvin == NULL) { |
|
|
return (-1); |
return (-1); |
} |
} |
|
|
snprintf(cvs_proto_buf, sizeof(cvs_proto_buf), "%s%s%s\n", |
l = snprintf(cvs_proto_buf, sizeof(cvs_proto_buf), "%s%s%s\n", |
req->req_str, (arg == NULL) ? "" : " ", (arg == NULL) ? "" : arg); |
req->req_str, (arg == NULL) ? "" : " ", (arg == NULL) ? "" : arg); |
|
if (l == -1 || l >= (int)sizeof(cvs_proto_buf)) |
|
return (-1); |
|
|
if (cvs_server_inlog != NULL) |
if (cvs_server_inlog != NULL) |
fputs(cvs_proto_buf, cvs_server_inlog); |
fputs(cvs_proto_buf, cvs_server_inlog); |
|
|
int |
int |
cvs_senddir(struct cvsroot *root, CVSFILE *dir) |
cvs_senddir(struct cvsroot *root, CVSFILE *dir) |
{ |
{ |
|
int l; |
char lbuf[MAXPATHLEN], rbuf[MAXPATHLEN]; |
char lbuf[MAXPATHLEN], rbuf[MAXPATHLEN]; |
|
|
if (dir->cf_type != DT_DIR) |
if (dir->cf_type != DT_DIR) |
|
|
|
|
if (dir->cf_repo == NULL) |
if (dir->cf_repo == NULL) |
strlcpy(rbuf, root->cr_dir, sizeof(rbuf)); |
strlcpy(rbuf, root->cr_dir, sizeof(rbuf)); |
else |
else { |
snprintf(rbuf, sizeof(rbuf), "%s/%s", root->cr_dir, |
l = snprintf(rbuf, sizeof(rbuf), "%s/%s", root->cr_dir, |
dir->cf_repo); |
dir->cf_repo); |
|
if (l == -1 || l >= (int)sizeof(rbuf)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", rbuf); |
|
return (-1); |
|
} |
|
} |
|
|
|
|
if ((cvs_sendreq(root, CVS_REQ_DIRECTORY, lbuf) < 0) || |
if ((cvs_sendreq(root, CVS_REQ_DIRECTORY, lbuf) < 0) || |
|
|
int |
int |
cvs_sendentry(struct cvsroot *root, const CVSFILE *file) |
cvs_sendentry(struct cvsroot *root, const CVSFILE *file) |
{ |
{ |
|
int l; |
char ebuf[128], numbuf[64]; |
char ebuf[128], numbuf[64]; |
|
|
if (file->cf_type != DT_REG) { |
if (file->cf_type != DT_REG) { |
|
|
if (file->cf_cvstat == CVS_FST_UNKNOWN) |
if (file->cf_cvstat == CVS_FST_UNKNOWN) |
return (0); |
return (0); |
|
|
snprintf(ebuf, sizeof(ebuf), "/%s/%s%s///", file->cf_name, |
l = snprintf(ebuf, sizeof(ebuf), "/%s/%s%s///", file->cf_name, |
(file->cf_cvstat == CVS_FST_REMOVED) ? "-" : "", |
(file->cf_cvstat == CVS_FST_REMOVED) ? "-" : "", |
rcsnum_tostr(file->cf_lrev, numbuf, sizeof(numbuf))); |
rcsnum_tostr(file->cf_lrev, numbuf, sizeof(numbuf))); |
|
if (l == -1 || l >= (int)sizeof(ebuf)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", ebuf); |
|
return (-1); |
|
} |
|
|
return cvs_sendreq(root, CVS_REQ_ENTRY, ebuf); |
return cvs_sendreq(root, CVS_REQ_ENTRY, ebuf); |
} |
} |