Annotation of src/usr.bin/cvs/edit.c, Revision 1.12
1.12 ! xsa 1: /* $OpenBSD: edit.c,v 1.11 2006/01/02 08:11:56 xsa 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.12 ! xsa 99: int ch;
1.1 jfb 100:
101: while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
102: switch (ch) {
103: case 'a':
1.6 xsa 104: /*
105: * The `editors' and `unedit' commands do not have
106: * the -a option. Check which command has been issued.
107: */
1.1 jfb 108: if (cvs_cmdop != CVS_OP_EDIT)
109: return (CVS_EX_USAGE);
110: break;
111: case 'l':
112: cmd->file_flags &= ~CF_RECURSE;
113: break;
114: case 'R':
115: cmd->file_flags |= CF_RECURSE;
116: break;
117: default:
118: return (CVS_EX_USAGE);
119: }
120: }
121:
122: *arg = optind;
123: return (CVS_EX_OK);
124: }
125:
126:
127: /*
128: * cvs_edit_remote()
129: *
130: */
131: static int
1.9 xsa 132: cvs_edit_remote(CVSFILE *cf, void *arg)
1.1 jfb 133: {
134: return (CVS_EX_OK);
135: }
136:
137:
138: /*
139: * cvs_edit_local()
140: *
141: */
142: static int
1.9 xsa 143: cvs_edit_local(CVSFILE *cf, void *arg)
1.1 jfb 144: {
145: return (CVS_EX_OK);
1.9 xsa 146: }
147:
148:
149: /*
150: * cvs_editors_remote()
151: *
152: */
153: static int
154: cvs_editors_remote(CVSFILE *cf, void *arg)
155: {
156: struct cvsroot *root;
157:
158: root = CVS_DIR_ROOT(cf);
159:
160: if (cf->cf_type == DT_DIR) {
161: if (cf->cf_cvstat == CVS_FST_UNKNOWN)
1.10 joris 162: cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
1.9 xsa 163: else
1.10 joris 164: cvs_senddir(root, cf);
165: return (0);
1.9 xsa 166: }
167:
1.10 joris 168: cvs_sendentry(root, cf);
1.9 xsa 169:
170: switch (cf->cf_cvstat) {
171: case CVS_FST_UNKNOWN:
1.10 joris 172: cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
1.9 xsa 173: break;
174: case CVS_FST_UPTODATE:
1.10 joris 175: cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
1.9 xsa 176: break;
177: case CVS_FST_ADDED:
178: case CVS_FST_MODIFIED:
1.10 joris 179: cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
1.9 xsa 180: break;
181: default:
182: break;
183: }
184:
1.10 joris 185: return (0);
1.1 jfb 186: }