Annotation of src/usr.bin/cvs/edit.c, Revision 1.8
1.8 ! xsa 1: /* $OpenBSD: edit.c,v 1.7 2005/07/10 21:51:23 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:
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:
1.8 ! xsa 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 *);
1.1 jfb 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: {
1.7 joris 105: int ch, dflag, mod_count;
1.1 jfb 106:
107: dflag = 0;
108: mod_count = 0;
109:
110: while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
111: switch (ch) {
112: case 'a':
1.6 xsa 113: /*
114: * The `editors' and `unedit' commands do not have
115: * the -a option. Check which command has been issued.
116: */
1.1 jfb 117: if (cvs_cmdop != CVS_OP_EDIT)
118: return (CVS_EX_USAGE);
119: break;
120: case 'l':
121: cmd->file_flags &= ~CF_RECURSE;
122: break;
123: case 'R':
124: cmd->file_flags |= CF_RECURSE;
125: break;
126: default:
127: return (CVS_EX_USAGE);
128: }
129: }
130:
131: *arg = optind;
132: return (CVS_EX_OK);
133: }
134:
135:
136: /*
137: * cvs_edit_remote()
138: *
139: */
140: static int
141: cvs_edit_remote(CVSFILE *file, void *arg)
142: {
143: int *mod_count;
144:
145: mod_count = (int *)arg;
146:
147: return (CVS_EX_OK);
148: }
149:
150:
151: /*
152: * cvs_edit_local()
153: *
154: */
155: static int
156: cvs_edit_local(CVSFILE *file, void *arg)
157: {
158: int *mod_count;
159:
160: mod_count = (int *)arg;
161:
162: return (CVS_EX_OK);
163: }