version 1.25, 2005/04/19 00:55:07 |
version 1.26, 2005/04/27 04:42:40 |
|
|
#include "proto.h" |
#include "proto.h" |
|
|
|
|
int cvs_update_file(CVSFILE *, void *); |
static int cvs_update_remote (CVSFILE *, void *); |
int cvs_update_prune(CVSFILE *, void *); |
static int cvs_update_local (CVSFILE *, void *); |
int cvs_update_options(char *, int, char **, int *); |
static int cvs_update_options (char *, int, char **, int *); |
int cvs_update_sendflags(struct cvsroot *); |
static int cvs_update_sendflags (struct cvsroot *); |
|
|
struct cvs_cmd_info cvs_update = { |
struct cvs_cmd_info cvs_update = { |
cvs_update_options, |
cvs_update_options, |
cvs_update_sendflags, |
cvs_update_sendflags, |
cvs_update_file, |
cvs_update_remote, |
NULL, NULL, |
NULL, NULL, |
CF_SORT | CF_RECURSE | CF_IGNORE | CF_KNOWN | CF_NOSYMS, |
CF_SORT | CF_RECURSE | CF_IGNORE | CF_KNOWN | CF_NOSYMS, |
CVS_REQ_UPDATE, |
CVS_REQ_UPDATE, |
|
|
|
|
static int Pflag, dflag, Aflag; |
static int Pflag, dflag, Aflag; |
|
|
int |
static int |
cvs_update_options(char *opt, int argc, char **argv, int *arg) |
cvs_update_options(char *opt, int argc, char **argv, int *arg) |
{ |
{ |
int ch; |
int ch; |
|
|
return (0); |
return (0); |
} |
} |
|
|
int |
static int |
cvs_update_sendflags(struct cvsroot *root) |
cvs_update_sendflags(struct cvsroot *root) |
{ |
{ |
if (Pflag && cvs_sendarg(root, "-P", 0) < 0) |
if (Pflag && cvs_sendarg(root, "-P", 0) < 0) |
|
|
} |
} |
|
|
/* |
/* |
* cvs_update_file() |
* cvs_update_remote() |
* |
* |
* Update a single file. In the case where we act as client, send any |
* Update a single file. In the case where we act as client, send any |
* pertinent information about that file to the server. |
* pertinent information about that file to the server. |
*/ |
*/ |
int |
static int |
cvs_update_file(CVSFILE *cf, void *arg) |
cvs_update_remote(CVSFILE *cf, void *arg) |
{ |
{ |
int ret, l; |
int ret; |
char *fname, *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN]; |
char *repo, fpath[MAXPATHLEN]; |
RCSFILE *rf; |
|
struct cvsroot *root; |
struct cvsroot *root; |
|
|
ret = 0; |
ret = 0; |
rf = NULL; |
|
root = CVS_DIR_ROOT(cf); |
root = CVS_DIR_ROOT(cf); |
repo = CVS_DIR_REPO(cf); |
repo = CVS_DIR_REPO(cf); |
fname = CVS_FILE_NAME(cf); |
|
|
|
if (cf->cf_type == DT_DIR) { |
if (cf->cf_type == DT_DIR) { |
if (root->cr_method != CVS_METHOD_LOCAL) { |
if (cf->cf_cvstat == CVS_FST_UNKNOWN) |
if (cf->cf_cvstat == CVS_FST_UNKNOWN) |
ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, |
ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, |
cf->cf_name); |
CVS_FILE_NAME(cf)); |
else |
else |
ret = cvs_senddir(root, cf); |
ret = cvs_senddir(root, cf); |
|
} |
|
|
|
return (ret); |
return (ret); |
} |
} |
|
|
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
|
|
if (root->cr_method != CVS_METHOD_LOCAL) { |
if (cvs_sendentry(root, cf) < 0) |
if (cvs_sendentry(root, cf) < 0) { |
return (CVS_EX_PROTO); |
return (CVS_EX_PROTO); |
|
} |
|
|
|
switch (cf->cf_cvstat) { |
switch (cf->cf_cvstat) { |
case CVS_FST_UNKNOWN: |
case CVS_FST_UNKNOWN: |
ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, fname); |
ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name); |
break; |
break; |
case CVS_FST_UPTODATE: |
case CVS_FST_UPTODATE: |
ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, fname); |
ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name); |
break; |
break; |
case CVS_FST_ADDED: |
case CVS_FST_ADDED: |
case CVS_FST_MODIFIED: |
case CVS_FST_MODIFIED: |
ret = cvs_sendreq(root, CVS_REQ_MODIFIED, fname); |
ret = cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name); |
if (ret == 0) |
if (ret == 0) |
ret = cvs_sendfile(root, fpath); |
ret = cvs_sendfile(root, fpath); |
break; |
break; |
default: |
default: |
break; |
break; |
} |
|
} else { |
|
if (cf->cf_cvstat == CVS_FST_UNKNOWN) { |
|
cvs_printf("? %s\n", fpath); |
|
return (0); |
|
} |
|
|
|
l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", |
|
root->cr_dir, repo, fname, RCS_FILE_EXT); |
|
if (l == -1 || l >= (int)sizeof(rcspath)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", rcspath); |
|
return (-1); |
|
} |
|
|
|
rf = rcs_open(rcspath, RCS_READ); |
|
if (rf == NULL) { |
|
return (CVS_EX_DATA); |
|
} |
|
|
|
rcs_close(rf); |
|
} |
} |
|
|
return (ret); |
return (ret); |
} |
} |
|
|
|
|
/* |
/* |
* cvs_update_prune() |
* cvs_update_local() |
* |
|
* Prune all directories which contain no more files known to CVS. |
|
*/ |
*/ |
int |
static int |
cvs_update_prune(CVSFILE *cf, void *arg) |
cvs_update_local(CVSFILE *cf, void *arg) |
{ |
{ |
|
int ret, l; |
|
char *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN]; |
|
RCSFILE *rf; |
|
struct cvsroot *root; |
|
|
return (0); |
ret = 0; |
|
rf = NULL; |
|
root = CVS_DIR_ROOT(cf); |
|
repo = CVS_DIR_REPO(cf); |
|
|
|
if (cf->cf_type == DT_DIR) { |
|
return (CVS_EX_OK); |
|
} |
|
|
|
cvs_file_getpath(cf, fpath, sizeof(fpath)); |
|
|
|
if (cf->cf_cvstat == CVS_FST_UNKNOWN) { |
|
cvs_printf("? %s\n", fpath); |
|
return (0); |
|
} |
|
|
|
l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", |
|
root->cr_dir, repo, cf->cf_name, RCS_FILE_EXT); |
|
if (l == -1 || l >= (int)sizeof(rcspath)) { |
|
errno = ENAMETOOLONG; |
|
cvs_log(LP_ERRNO, "%s", rcspath); |
|
return (-1); |
|
} |
|
|
|
rf = rcs_open(rcspath, RCS_RDWR); |
|
if (rf == NULL) { |
|
return (CVS_EX_DATA); |
|
} |
|
|
|
rcs_close(rf); |
|
|
|
return (ret); |
} |
} |