=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/Attic/proto.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/cvs/Attic/proto.c 2004/07/25 18:50:30 1.4 --- src/usr.bin/cvs/Attic/proto.c 2004/07/26 16:00:10 1.5 *************** *** 1,4 **** ! /* $OpenBSD: proto.c,v 1.4 2004/07/25 18:50:30 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: proto.c,v 1.5 2004/07/26 16:00:10 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 60,66 **** --- 60,69 ---- #include "log.h" + #define CVS_MTSTK_MAXDEPTH 16 + + extern int verbosity; extern int cvs_compress; extern char *cvs_rsh; *************** *** 72,90 **** - /* - * Local and remote directory used by the `Directory' request. - */ - char cvs_ldir[MAXPATHLEN]; - char cvs_rdir[MAXPATHLEN]; - - - - char *cvs_fcksum = NULL; - - mode_t cvs_lastmode = 0; - - static int cvs_resp_validreq (int, char *); static int cvs_resp_cksum (int, char *); static int cvs_resp_modtime (int, char *); --- 75,80 ---- *************** *** 92,101 **** --- 82,93 ---- static int cvs_resp_ok (int, char *); static int cvs_resp_error (int, char *); static int cvs_resp_statdir (int, char *); + static int cvs_resp_sticky (int, char *); static int cvs_resp_newentry (int, char *); static int cvs_resp_updated (int, char *); static int cvs_resp_removed (int, char *); static int cvs_resp_mode (int, char *); + static int cvs_resp_modxpand (int, char *); *************** *** 181,196 **** --- 173,205 ---- { CVS_RESP_CHECKEDIN, "Checked-in", cvs_resp_newentry }, { CVS_RESP_MODE, "Mode", cvs_resp_mode }, { CVS_RESP_MODTIME, "Mod-time", cvs_resp_modtime }, + { CVS_RESP_MODXPAND, "Module-expansion", cvs_resp_modxpand }, + { CVS_RESP_SETSTICKY, "Set-sticky", cvs_resp_sticky }, + { CVS_RESP_CLRSTICKY, "Clear-sticky", cvs_resp_sticky }, }; + static char *cvs_mt_stack[CVS_MTSTK_MAXDEPTH]; + static u_int cvs_mtstk_depth = 0; + + #define CVS_NBREQ (sizeof(cvs_requests)/sizeof(cvs_requests[0])) #define CVS_NBRESP (sizeof(cvs_responses)/sizeof(cvs_responses[0])) /* mask of requets supported by server */ static u_char cvs_server_validreq[CVS_REQ_MAX + 1]; + /* + * Local and remote directory used by the `Directory' request. + */ + char cvs_ldir[MAXPATHLEN]; + char cvs_rdir[MAXPATHLEN]; + char *cvs_fcksum = NULL; + + mode_t cvs_lastmode = 0; + + /* * cvs_req_getbyid() * *************** *** 485,490 **** --- 494,500 ---- static int cvs_resp_m(int type, char *line) { + char *cp; FILE *stream; stream = NULL; *************** *** 500,508 **** stream = stderr; break; case CVS_RESP_MT: break; case CVS_RESP_MBINARY: ! cvs_log(LP_WARN, "MT and Mbinary not supported in client yet"); break; } --- 510,555 ---- stream = stderr; break; case CVS_RESP_MT: + if (*line == '+') { + if (cvs_mtstk_depth == CVS_MTSTK_MAXDEPTH) { + cvs_log(LP_ERR, + "MT scope stack has reached max depth"); + return (-1); + } + cvs_mt_stack[cvs_mtstk_depth++] = strdup(line + 1); + if (cvs_mt_stack[cvs_mtstk_depth] == NULL) { + cvs_mtstk_depth--; + return (-1); + } + } + else if (*line == '-') { + if (cvs_mtstk_depth == 0) { + cvs_log(LP_ERR, "MT scope stack underflow"); + return (-1); + } + else if (strcmp(line, + cvs_mt_stack[cvs_mtstk_depth]) != 0) { + cvs_log(LP_ERR, "mismatch in MT scope stack"); + return (-1); + } + free(cvs_mt_stack[cvs_mtstk_depth--]); + } + else { + if (strcmp(line, "newline") == 0) + putc('\n', stdout); + else if (strncmp(line, "fname ", 6) == 0) + printf("%s", line + 6); + else { + /* assume text */ + cp = strchr(line, ' '); + if (cp != NULL) + printf("%s", cp + 1); + } + } + break; case CVS_RESP_MBINARY: ! cvs_log(LP_WARN, "Mbinary not supported in client yet"); break; } *************** *** 556,580 **** CVS_PATH_STATICENTRIES); if ((type == CVS_RESP_CLRSTATDIR) && ! (unlink(statpath) == -1)) { cvs_log(LP_ERRNO, "failed to unlink %s file", CVS_PATH_STATICENTRIES); return (-1); } else if (type == CVS_RESP_SETSTATDIR) { ! fd = open(statpath, O_CREAT|O_TRUNC|O_WRONLY, 0400); if (fd == -1) { cvs_log(LP_ERRNO, "failed to create %s file", CVS_PATH_STATICENTRIES); return (-1); } (void)close(fd); } return (0); } /* * cvs_resp_newentry() * --- 603,645 ---- CVS_PATH_STATICENTRIES); if ((type == CVS_RESP_CLRSTATDIR) && ! (unlink(statpath) == -1) && (errno != ENOENT)) { cvs_log(LP_ERRNO, "failed to unlink %s file", CVS_PATH_STATICENTRIES); return (-1); } else if (type == CVS_RESP_SETSTATDIR) { ! fd = open(statpath, O_CREAT|O_TRUNC|O_WRONLY, 0400); if (fd == -1) { cvs_log(LP_ERRNO, "failed to create %s file", CVS_PATH_STATICENTRIES); return (-1); } (void)close(fd); + } return (0); } + /* + * cvs_resp_sticky() + * + * Handler for the `Clear-sticky' and `Set-sticky' responses. + */ + static int + cvs_resp_sticky(int type, char *line) + { + if (type == CVS_RESP_CLRSTICKY) { + } + else if (type == CVS_RESP_SETSTICKY) { + } + + return (0); + } + + /* * cvs_resp_newentry() * *************** *** 713,718 **** --- 778,796 ---- if (cvs_strtomode(line, &cvs_lastmode) < 0) { return (-1); } + return (0); + } + + + /* + * cvs_resp_modxpand() + * + * Handler for the `Module-expansion' response. + */ + + static int + cvs_resp_modxpand(int type, char *line) + { return (0); }