Annotation of src/usr.bin/cvs/edit.c, Revision 1.11
1.11 ! xsa 1: /* $OpenBSD: edit.c,v 1.10 2005/12/30 02:03:28 joris Exp $ */
1.1 jfb 2: /*
3: * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
4: * All rights reserved.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: *
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. The name of the author may not be used to endorse or promote products
13: * derived from this software without specific prior written permission.
14: *
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18: * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25: */
26:
1.11 ! xsa 27: #include "includes.h"
1.1 jfb 28:
29: #include "cvs.h"
30: #include "log.h"
31: #include "proto.h"
32:
33:
34:
1.8 xsa 35: static int cvs_edit_init(struct cvs_cmd *, int, char **, int *);
36: static int cvs_edit_remote(CVSFILE *, void *);
37: static int cvs_edit_local(CVSFILE *, void *);
1.1 jfb 38:
1.9 xsa 39: static int cvs_editors_remote(CVSFILE *, void *);
40:
1.1 jfb 41:
42: struct cvs_cmd cvs_cmd_edit = {
43: CVS_OP_EDIT, CVS_REQ_NOOP, "edit",
44: { },
45: "Mark a file as being edited",
1.2 xsa 46: "[-lR] [-a action] [file ...]",
1.1 jfb 47: "a:lR",
48: NULL,
49: CF_SORT | CF_RECURSE,
50: cvs_edit_init,
51: NULL,
52: cvs_edit_remote,
53: cvs_edit_local,
54: NULL,
55: NULL,
56: 0
57: };
58:
59: struct cvs_cmd cvs_cmd_editors = {
60: CVS_OP_EDITORS, CVS_REQ_EDITORS, "editors",
61: { },
62: "List editors on a file",
1.3 xsa 63: "[-lR] [file ...]",
64: "lR",
1.1 jfb 65: NULL,
1.9 xsa 66: CF_SORT | CF_RECURSE,
1.1 jfb 67: cvs_edit_init,
68: NULL,
1.9 xsa 69: cvs_editors_remote,
70: NULL,
1.1 jfb 71: NULL,
72: NULL,
1.9 xsa 73: CVS_CMD_SENDDIR | CVS_CMD_ALLOWSPEC | CVS_CMD_SENDARGS2
1.1 jfb 74: };
75:
76:
77: struct cvs_cmd cvs_cmd_unedit = {
78: CVS_OP_UNEDIT, CVS_REQ_NOOP, "unedit",
79: { },
80: "Undo an edit command",
1.3 xsa 81: "[-lR] [file ...]",
1.1 jfb 82: "lR",
83: NULL,
84: CF_SORT | CF_RECURSE,
85: cvs_edit_init,
86: NULL,
87: cvs_edit_remote,
88: cvs_edit_local,
89: NULL,
90: NULL,
91: 0
92: };
93:
94:
95:
96: static int
97: cvs_edit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
98: {
1.7 joris 99: int ch, dflag, mod_count;
1.1 jfb 100:
101: dflag = 0;
102: mod_count = 0;
103:
104: while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
105: switch (ch) {
106: case 'a':
1.6 xsa 107: /*
108: * The `editors' and `unedit' commands do not have
109: * the -a option. Check which command has been issued.
110: */
1.1 jfb 111: if (cvs_cmdop != CVS_OP_EDIT)
112: return (CVS_EX_USAGE);
113: break;
114: case 'l':
115: cmd->file_flags &= ~CF_RECURSE;
116: break;
117: case 'R':
118: cmd->file_flags |= CF_RECURSE;
119: break;
120: default:
121: return (CVS_EX_USAGE);
122: }
123: }
124:
125: *arg = optind;
126: return (CVS_EX_OK);
127: }
128:
129:
130: /*
131: * cvs_edit_remote()
132: *
133: */
134: static int
1.9 xsa 135: cvs_edit_remote(CVSFILE *cf, void *arg)
1.1 jfb 136: {
137: int *mod_count;
138:
139: mod_count = (int *)arg;
140:
141: return (CVS_EX_OK);
142: }
143:
144:
145: /*
146: * cvs_edit_local()
147: *
148: */
149: static int
1.9 xsa 150: cvs_edit_local(CVSFILE *cf, void *arg)
1.1 jfb 151: {
152: int *mod_count;
153:
154: mod_count = (int *)arg;
155:
156: return (CVS_EX_OK);
1.9 xsa 157: }
158:
159:
160: /*
161: * cvs_editors_remote()
162: *
163: */
164: static int
165: cvs_editors_remote(CVSFILE *cf, void *arg)
166: {
167: struct cvsroot *root;
168:
169: root = CVS_DIR_ROOT(cf);
170:
171: if (cf->cf_type == DT_DIR) {
172: if (cf->cf_cvstat == CVS_FST_UNKNOWN)
1.10 joris 173: cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
1.9 xsa 174: else
1.10 joris 175: cvs_senddir(root, cf);
176: return (0);
1.9 xsa 177: }
178:
1.10 joris 179: cvs_sendentry(root, cf);
1.9 xsa 180:
181: switch (cf->cf_cvstat) {
182: case CVS_FST_UNKNOWN:
1.10 joris 183: cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
1.9 xsa 184: break;
185: case CVS_FST_UPTODATE:
1.10 joris 186: cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
1.9 xsa 187: break;
188: case CVS_FST_ADDED:
189: case CVS_FST_MODIFIED:
1.10 joris 190: cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
1.9 xsa 191: break;
192: default:
193: break;
194: }
195:
1.10 joris 196: return (0);
1.1 jfb 197: }