version 1.30, 2004/12/06 21:03:12 |
version 1.31, 2004/12/07 17:10:56 |
|
|
#define CVS_REQF_RESP 0x01 |
#define CVS_REQF_RESP 0x01 |
|
|
|
|
|
|
|
|
extern int verbosity; |
extern int verbosity; |
extern int cvs_compress; |
extern int cvs_compress; |
extern char *cvs_rsh; |
extern char *cvs_rsh; |
|
|
extern int cvs_readonly; |
extern int cvs_readonly; |
extern int cvs_cmdop; |
extern int cvs_cmdop; |
|
|
|
|
|
|
static int cvs_initlog (void); |
static int cvs_initlog (void); |
|
|
|
|
struct cvs_req cvs_requests[] = { |
struct cvs_req cvs_requests[] = { |
{ CVS_REQ_DIRECTORY, "Directory", 0 }, |
{ CVS_REQ_DIRECTORY, "Directory", 0 }, |
{ CVS_REQ_MAXDOTDOT, "Max-dotdot", 0 }, |
{ CVS_REQ_MAXDOTDOT, "Max-dotdot", 0 }, |
|
|
{ CVS_REQ_CI, "ci", CVS_REQF_RESP }, |
{ CVS_REQ_CI, "ci", CVS_REQF_RESP }, |
}; |
}; |
|
|
|
|
struct cvs_resp cvs_responses[] = { |
struct cvs_resp cvs_responses[] = { |
{ CVS_RESP_OK, "ok" }, |
{ CVS_RESP_OK, "ok" }, |
{ CVS_RESP_ERROR, "error" }, |
{ CVS_RESP_ERROR, "error" }, |
|
|
/* hack to receive the remote version without outputting it */ |
/* hack to receive the remote version without outputting it */ |
u_int cvs_version_sent = 0; |
u_int cvs_version_sent = 0; |
|
|
|
|
static char cvs_proto_buf[4096]; |
static char cvs_proto_buf[4096]; |
|
|
/* |
/* |
|
|
* server. Then, a version request is sent and various global flags are sent. |
* server. Then, a version request is sent and various global flags are sent. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvs_connect(struct cvsroot *root) |
cvs_connect(struct cvsroot *root) |
{ |
{ |
|
|
* |
* |
* Disconnect from the cvs server. |
* Disconnect from the cvs server. |
*/ |
*/ |
|
|
void |
void |
cvs_disconnect(struct cvsroot *root) |
cvs_disconnect(struct cvsroot *root) |
{ |
{ |
|
|
* cvs_req_getbyid() |
* cvs_req_getbyid() |
* |
* |
*/ |
*/ |
|
|
struct cvs_req* |
struct cvs_req* |
cvs_req_getbyid(int reqid) |
cvs_req_getbyid(int reqid) |
{ |
{ |
|
|
for (i = 0; i < CVS_NBREQ; i++) |
for (i = 0; i < CVS_NBREQ; i++) |
if (cvs_requests[i].req_id == reqid) |
if (cvs_requests[i].req_id == reqid) |
return &(cvs_requests[i]); |
return &(cvs_requests[i]); |
|
|
return (NULL); |
return (NULL); |
} |
} |
|
|
|
|
/* |
/* |
* cvs_req_getbyname() |
* cvs_req_getbyname() |
*/ |
*/ |
|
|
struct cvs_req* |
struct cvs_req* |
cvs_req_getbyname(const char *rname) |
cvs_req_getbyname(const char *rname) |
{ |
{ |
|
|
* Build a space-separated list of all the requests that this protocol |
* Build a space-separated list of all the requests that this protocol |
* implementation supports. |
* implementation supports. |
*/ |
*/ |
|
|
char* |
char* |
cvs_req_getvalid(void) |
cvs_req_getvalid(void) |
{ |
{ |
|
|
* cvs_resp_getbyid() |
* cvs_resp_getbyid() |
* |
* |
*/ |
*/ |
|
|
struct cvs_resp* |
struct cvs_resp* |
cvs_resp_getbyid(int respid) |
cvs_resp_getbyid(int respid) |
{ |
{ |
|
|
for (i = 0; i < CVS_NBREQ; i++) |
for (i = 0; i < CVS_NBREQ; i++) |
if (cvs_responses[i].resp_id == (u_int)respid) |
if (cvs_responses[i].resp_id == (u_int)respid) |
return &(cvs_responses[i]); |
return &(cvs_responses[i]); |
|
|
return (NULL); |
return (NULL); |
} |
} |
|
|
|
|
/* |
/* |
* cvs_resp_getbyname() |
* cvs_resp_getbyname() |
*/ |
*/ |
|
|
struct cvs_resp* |
struct cvs_resp* |
cvs_resp_getbyname(const char *rname) |
cvs_resp_getbyname(const char *rname) |
{ |
{ |
|
|
* Send the mode and size of a file followed by the file's contents. |
* Send the mode and size of a file followed by the file's contents. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvs_sendfile(struct cvsroot *root, const char *path) |
cvs_sendfile(struct cvsroot *root, const char *path) |
{ |
{ |
|
|
* create or update the file whose path is <path> with the received |
* create or update the file whose path is <path> with the received |
* information. |
* information. |
*/ |
*/ |
|
|
BUF* |
BUF* |
cvs_recvfile(struct cvsroot *root, mode_t *mode) |
cvs_recvfile(struct cvsroot *root, mode_t *mode) |
{ |
{ |
|
|
* contained in <arg>, which should not be terminated by a newline. |
* contained in <arg>, which should not be terminated by a newline. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg) |
cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg) |
{ |
{ |
|
|
* non-zero (either an error occured or the end of the response was reached). |
* non-zero (either an error occured or the end of the response was reached). |
* Returns the number of handled commands on success, or -1 on failure. |
* Returns the number of handled commands on success, or -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvs_getresp(struct cvsroot *root) |
cvs_getresp(struct cvsroot *root) |
{ |
{ |
|
|
* Get a line from the remote end and store it in <lbuf>. The terminating |
* Get a line from the remote end and store it in <lbuf>. The terminating |
* newline character is stripped from the result. |
* newline character is stripped from the result. |
*/ |
*/ |
|
|
int |
int |
cvs_getln(struct cvsroot *root, char *lbuf, size_t len) |
cvs_getln(struct cvsroot *root, char *lbuf, size_t len) |
{ |
{ |
|
|
* contained in <arg>, which should not be terminated by a newline. |
* contained in <arg>, which should not be terminated by a newline. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvs_sendresp(u_int rid, const char *arg) |
cvs_sendresp(u_int rid, const char *arg) |
{ |
{ |
|
|
* |
* |
* Get a request from the client. |
* Get a request from the client. |
*/ |
*/ |
|
|
int |
int |
cvs_getreq(void) |
cvs_getreq(void) |
{ |
{ |
|
|
* without any modifications. |
* without any modifications. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
|
|
int |
int |
cvs_sendln(struct cvsroot *root, const char *line) |
cvs_sendln(struct cvsroot *root, const char *line) |
{ |
{ |
|
|
* |
* |
* Send the first <len> bytes from the buffer <src> to the server. |
* Send the first <len> bytes from the buffer <src> to the server. |
*/ |
*/ |
|
|
int |
int |
cvs_sendraw(struct cvsroot *root, const void *src, size_t len) |
cvs_sendraw(struct cvsroot *root, const void *src, size_t len) |
{ |
{ |
|
|
* |
* |
* Receive the first <len> bytes from the buffer <src> to the server. |
* Receive the first <len> bytes from the buffer <src> to the server. |
*/ |
*/ |
|
|
ssize_t |
ssize_t |
cvs_recvraw(struct cvsroot *root, void *dst, size_t len) |
cvs_recvraw(struct cvsroot *root, void *dst, size_t len) |
{ |
{ |
|
|
* |
* |
* Send a `Directory' request along with the 2 paths that follow it. |
* Send a `Directory' request along with the 2 paths that follow it. |
*/ |
*/ |
|
|
int |
int |
cvs_senddir(struct cvsroot *root, CVSFILE *dir) |
cvs_senddir(struct cvsroot *root, CVSFILE *dir) |
{ |
{ |
char lbuf[MAXPATHLEN], rbuf[MAXPATHLEN]; |
char lbuf[MAXPATHLEN], rbuf[MAXPATHLEN]; |
|
|
|
|
* determine if the argument should be simply appended to the last argument |
* determine if the argument should be simply appended to the last argument |
* sent or if it should be created as a new argument (0). |
* sent or if it should be created as a new argument (0). |
*/ |
*/ |
|
|
int |
int |
cvs_sendarg(struct cvsroot *root, const char *arg, int append) |
cvs_sendarg(struct cvsroot *root, const char *arg, int append) |
{ |
{ |
|
|
* Send an `Entry' request to the server along with the mandatory fields from |
* Send an `Entry' request to the server along with the mandatory fields from |
* the CVS entry <ent> (which are the name and revision). |
* the CVS entry <ent> (which are the name and revision). |
*/ |
*/ |
|
|
int |
int |
cvs_sendentry(struct cvsroot *root, const struct cvs_ent *ent) |
cvs_sendentry(struct cvsroot *root, const struct cvs_ent *ent) |
{ |
{ |
|
|
* output. |
* output. |
* Returns 0 on success, or -1 on failure. |
* Returns 0 on success, or -1 on failure. |
*/ |
*/ |
|
|
static int |
static int |
cvs_initlog(void) |
cvs_initlog(void) |
{ |
{ |