Annotation of src/usr.bin/cvs/edit.c, Revision 1.5
1.5 ! xsa 1: /* $OpenBSD: edit.c,v 1.4 2005/05/28 20:39:08 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:
27: #include <sys/types.h>
28:
29: #include <errno.h>
30: #include <fcntl.h>
1.5 ! xsa 31: #include <libgen.h>
1.1 jfb 32: #include <stdio.h>
33: #include <stdlib.h>
34: #include <string.h>
35: #include <unistd.h>
36:
37: #include "cvs.h"
38: #include "log.h"
39: #include "proto.h"
40:
41:
42:
43: static int cvs_edit_init (struct cvs_cmd *, int, char **, int *);
44: static int cvs_edit_remote (CVSFILE *, void *);
45: static int cvs_edit_local (CVSFILE *, void *);
46:
47:
48: struct cvs_cmd cvs_cmd_edit = {
49: CVS_OP_EDIT, CVS_REQ_NOOP, "edit",
50: { },
51: "Mark a file as being edited",
1.2 xsa 52: "[-lR] [-a action] [file ...]",
1.1 jfb 53: "a:lR",
54: NULL,
55: CF_SORT | CF_RECURSE,
56: cvs_edit_init,
57: NULL,
58: cvs_edit_remote,
59: cvs_edit_local,
60: NULL,
61: NULL,
62: 0
63: };
64:
65: struct cvs_cmd cvs_cmd_editors = {
66: CVS_OP_EDITORS, CVS_REQ_EDITORS, "editors",
67: { },
68: "List editors on a file",
1.3 xsa 69: "[-lR] [file ...]",
70: "lR",
1.1 jfb 71: NULL,
72: 0,
73: cvs_edit_init,
74: NULL,
75: cvs_edit_remote,
76: cvs_edit_local,
77: NULL,
78: NULL,
79: 0
80: };
81:
82:
83: struct cvs_cmd cvs_cmd_unedit = {
84: CVS_OP_UNEDIT, CVS_REQ_NOOP, "unedit",
85: { },
86: "Undo an edit command",
1.3 xsa 87: "[-lR] [file ...]",
1.1 jfb 88: "lR",
89: NULL,
90: CF_SORT | CF_RECURSE,
91: cvs_edit_init,
92: NULL,
93: cvs_edit_remote,
94: cvs_edit_local,
95: NULL,
96: NULL,
97: 0
98: };
99:
100:
101:
102: static int
103: cvs_edit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
104: {
105: int i, ch, dflag, mod_count;
106: struct cvsroot *root;
107:
108: dflag = 0;
109: mod_count = 0;
110:
111: while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
112: switch (ch) {
113: case 'a':
114: if (cvs_cmdop != CVS_OP_EDIT)
115: return (CVS_EX_USAGE);
116: break;
117: case 'l':
118: cmd->file_flags &= ~CF_RECURSE;
119: break;
120: case 'R':
121: cmd->file_flags |= CF_RECURSE;
122: break;
123: default:
124: return (CVS_EX_USAGE);
125: }
126: }
127:
128: *arg = optind;
129: return (CVS_EX_OK);
130: }
131:
132:
133: /*
134: * cvs_edit_remote()
135: *
136: */
137: static int
138: cvs_edit_remote(CVSFILE *file, void *arg)
139: {
140: int *mod_count;
141:
142: mod_count = (int *)arg;
143:
144: return (CVS_EX_OK);
145: }
146:
147:
148: /*
149: * cvs_edit_local()
150: *
151: */
152: static int
153: cvs_edit_local(CVSFILE *file, void *arg)
154: {
155: int *mod_count;
156:
157: mod_count = (int *)arg;
158:
159: return (CVS_EX_OK);
160: }