Deleted Added
full compact
cvs.h (102843) cvs.h (107487)
1/*
2 * Copyright (c) 1992, Brian Berliner and Jeff Polk
3 * Copyright (c) 1989-1992, Brian Berliner
4 *
5 * You may distribute under the terms of the GNU General Public License as
6 * specified in the README file that comes with the CVS kit.
7 */
8
9/*
10 * basic information used in all source files
11 *
1/*
2 * Copyright (c) 1992, Brian Berliner and Jeff Polk
3 * Copyright (c) 1989-1992, Brian Berliner
4 *
5 * You may distribute under the terms of the GNU General Public License as
6 * specified in the README file that comes with the CVS kit.
7 */
8
9/*
10 * basic information used in all source files
11 *
12 * $FreeBSD: head/contrib/cvs/src/cvs.h 102843 2002-09-02 05:57:14Z peter $
12 * $FreeBSD: head/contrib/cvs/src/cvs.h 107487 2002-12-02 03:17:49Z peter $
13 */
14
15
13 */
14
15
16#include "config.h" /* this is stuff found via autoconf */
16#ifdef HAVE_CONFIG_H
17# include <config.h> /* this is stuff found via autoconf */
18#endif /* CONFIG_H */
17#include "options.h" /* these are some larger questions which
18 can't easily be automatically checked
19 for */
20
21/* Changed from if __STDC__ to ifdef __STDC__ because of Sun's acc compiler */
22
23#ifdef __STDC__
24#define PTR void *
25#else
26#define PTR char *
27#endif
28
29/* Add prototype support. */
30#ifndef PROTO
31#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
32#define PROTO(ARGS) ARGS
33#else
34#define PROTO(ARGS) ()
35#endif
36#endif
37
38#include <stdio.h>
39
40/* Under OS/2, <stdio.h> doesn't define popen()/pclose(). */
41#ifdef USE_OWN_POPEN
42#include "popen.h"
43#endif
44
45#ifdef STDC_HEADERS
46#include <stdlib.h>
47#else
48extern void exit ();
49extern char *getenv();
50#endif
51
52#ifdef HAVE_UNISTD_H
53#include <unistd.h>
54#endif
55
56#ifdef HAVE_STRING_H
57#include <string.h>
58#else
59#include <strings.h>
60#endif
61
62#ifdef SERVER_SUPPORT
63/* If the system doesn't provide strerror, it won't be declared in
64 string.h. */
65char *strerror ();
66#endif
67
19#include "options.h" /* these are some larger questions which
20 can't easily be automatically checked
21 for */
22
23/* Changed from if __STDC__ to ifdef __STDC__ because of Sun's acc compiler */
24
25#ifdef __STDC__
26#define PTR void *
27#else
28#define PTR char *
29#endif
30
31/* Add prototype support. */
32#ifndef PROTO
33#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
34#define PROTO(ARGS) ARGS
35#else
36#define PROTO(ARGS) ()
37#endif
38#endif
39
40#include <stdio.h>
41
42/* Under OS/2, <stdio.h> doesn't define popen()/pclose(). */
43#ifdef USE_OWN_POPEN
44#include "popen.h"
45#endif
46
47#ifdef STDC_HEADERS
48#include <stdlib.h>
49#else
50extern void exit ();
51extern char *getenv();
52#endif
53
54#ifdef HAVE_UNISTD_H
55#include <unistd.h>
56#endif
57
58#ifdef HAVE_STRING_H
59#include <string.h>
60#else
61#include <strings.h>
62#endif
63
64#ifdef SERVER_SUPPORT
65/* If the system doesn't provide strerror, it won't be declared in
66 string.h. */
67char *strerror ();
68#endif
69
68#include <fnmatch.h> /* This is supposed to be available on Posix systems */
70#ifdef HAVE_FNMATCH
71# include <fnmatch.h> /* This is supposed to be available on Posix systems */
72#else /* HAVE_FNMATCH */
73# include "fnmatch.h" /* Our substitute */
74#endif /* HAVE_FNMATCH */
69
70#include <ctype.h>
71#include <pwd.h>
72#include <signal.h>
73
74#ifdef HAVE_ERRNO_H
75#include <errno.h>
76#else
77#ifndef errno
78extern int errno;
79#endif /* !errno */
80#endif /* HAVE_ERRNO_H */
81
82#include "system.h"
83
84#include "hash.h"
85
86#include "root.h"
87
88#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
89# include "client.h"
90#endif
91
92#ifdef MY_NDBM
93#include "myndbm.h"
94#else
95#include <ndbm.h>
96#endif /* MY_NDBM */
97
98#include "regex.h"
99#include "getopt.h"
100#include "wait.h"
101
102#include "rcs.h"
103
104
105/* This actually gets set in system.h. Note that the _ONLY_ reason for
106 this is if various system calls (getwd, getcwd, readlink) require/want
107 us to use it. All other parts of CVS allocate pathname buffers
108 dynamically, and we want to keep it that way. */
109#ifndef PATH_MAX
110#ifdef MAXPATHLEN
111#define PATH_MAX MAXPATHLEN+2
112#else
113#define PATH_MAX 1024+2
114#endif
115#endif /* PATH_MAX */
116
117/* Definitions for the CVS Administrative directory and the files it contains.
118 Here as #define's to make changing the names a simple task. */
119
120#ifdef USE_VMS_FILENAMES
121#define CVSADM "CVS"
122#define CVSADM_ENT "CVS/Entries."
123#define CVSADM_ENTBAK "CVS/Entries.Backup"
124#define CVSADM_ENTLOG "CVS/Entries.Log"
125#define CVSADM_ENTSTAT "CVS/Entries.Static"
126#define CVSADM_REP "CVS/Repository."
127#define CVSADM_ROOT "CVS/Root."
128#define CVSADM_CIPROG "CVS/Checkin.prog"
129#define CVSADM_UPROG "CVS/Update.prog"
130#define CVSADM_TAG "CVS/Tag."
131#define CVSADM_NOTIFY "CVS/Notify."
132#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
133#define CVSADM_BASE "CVS/Base"
134#define CVSADM_BASEREV "CVS/Baserev."
135#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
136#define CVSADM_TEMPLATE "CVS/Template."
137#else /* USE_VMS_FILENAMES */
138#define CVSADM "CVS"
139#define CVSADM_ENT "CVS/Entries"
140#define CVSADM_ENTBAK "CVS/Entries.Backup"
141#define CVSADM_ENTLOG "CVS/Entries.Log"
142#define CVSADM_ENTSTAT "CVS/Entries.Static"
143#define CVSADM_REP "CVS/Repository"
144#define CVSADM_ROOT "CVS/Root"
145#define CVSADM_CIPROG "CVS/Checkin.prog"
146#define CVSADM_UPROG "CVS/Update.prog"
147#define CVSADM_TAG "CVS/Tag"
148#define CVSADM_NOTIFY "CVS/Notify"
149#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
150/* A directory in which we store base versions of files we currently are
151 editing with "cvs edit". */
152#define CVSADM_BASE "CVS/Base"
153#define CVSADM_BASEREV "CVS/Baserev"
154#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
155/* File which contains the template for use in log messages. */
156#define CVSADM_TEMPLATE "CVS/Template"
157#endif /* USE_VMS_FILENAMES */
158
159/* This is the special directory which we use to store various extra
160 per-directory information in the repository. It must be the same as
161 CVSADM to avoid creating a new reserved directory name which users cannot
162 use, but is a separate #define because if anyone changes it (which I don't
163 recommend), one needs to deal with old, unconverted, repositories.
164
165 See fileattr.h for details about file attributes, the only thing stored
166 in CVSREP currently. */
167#define CVSREP "CVS"
168
169/*
170 * Definitions for the CVSROOT Administrative directory and the files it
171 * contains. This directory is created as a sub-directory of the $CVSROOT
172 * environment variable, and holds global administration information for the
173 * entire source repository beginning at $CVSROOT.
174 */
175#define CVSROOTADM "CVSROOT"
176#define CVSROOTADM_MODULES "modules"
177#define CVSROOTADM_LOGINFO "loginfo"
178#define CVSROOTADM_RCSINFO "rcsinfo"
179#define CVSROOTADM_COMMITINFO "commitinfo"
180#define CVSROOTADM_TAGINFO "taginfo"
181#define CVSROOTADM_EDITINFO "editinfo"
182#define CVSROOTADM_VERIFYMSG "verifymsg"
183#define CVSROOTADM_HISTORY "history"
184#define CVSROOTADM_VALTAGS "val-tags"
185#define CVSROOTADM_IGNORE "cvsignore"
186#define CVSROOTADM_CHECKOUTLIST "checkoutlist"
187#define CVSROOTADM_WRAPPER "cvswrappers"
188#define CVSROOTADM_NOTIFY "notify"
189#define CVSROOTADM_USERS "users"
190#define CVSROOTADM_READERS "readers"
191#define CVSROOTADM_WRITERS "writers"
192#define CVSROOTADM_PASSWD "passwd"
193#define CVSROOTADM_CONFIG "config"
194#define CVSROOTADM_OPTIONS "options"
195
196#define CVSNULLREPOS "Emptydir" /* an empty directory */
197
198/* Other CVS file names */
199
200/* Files go in the attic if the head main branch revision is dead,
201 otherwise they go in the regular repository directories. The whole
202 concept of having an attic is sort of a relic from before death
203 support but on the other hand, it probably does help the speed of
204 some operations (such as main branch checkouts and updates). */
205#define CVSATTIC "Attic"
206
207#define CVSLCK "#cvs.lock"
208#define CVSRFL "#cvs.rfl"
209#define CVSWFL "#cvs.wfl"
210#define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */
211#define CVSEXT_LOG ",t"
212#define CVSPREFIX ",,"
213#define CVSDOTIGNORE ".cvsignore"
214#define CVSDOTWRAPPER ".cvswrappers"
215
216/* Command attributes -- see function lookup_command_attribute(). */
217#define CVS_CMD_IGNORE_ADMROOT 1
218
219/* Set if CVS needs to create a CVS/Root file upon completion of this
220 command. The name may be slightly confusing, because the flag
221 isn't really as general purpose as it seems (it is not set for cvs
222 release). */
223
224#define CVS_CMD_USES_WORK_DIR 2
225
226#define CVS_CMD_MODIFIES_REPOSITORY 4
227
228/* miscellaneous CVS defines */
229
230/* This is the string which is at the start of the non-log-message lines
231 that we put up for the user when they edit the log message. */
232#define CVSEDITPREFIX "CVS: "
233/* Number of characters in CVSEDITPREFIX to compare when deciding to strip
234 off those lines. We don't check for the space, to accomodate users who
235 have editors which strip trailing spaces. */
236#define CVSEDITPREFIXLEN 4
237
238#define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
239#define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
240#define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
241
242#ifdef USE_VMS_FILENAMES
243#define BAKPREFIX "_$"
244#define DEVNULL "NLA0:"
245#else /* USE_VMS_FILENAMES */
246#define BAKPREFIX ".#" /* when rcsmerge'ing */
247#ifndef DEVNULL
248#define DEVNULL "/dev/null"
249#endif
250#endif /* USE_VMS_FILENAMES */
251
252/*
253 * Special tags. -rHEAD refers to the head of an RCS file, regardless of any
254 * sticky tags. -rBASE refers to the current revision the user has checked
255 * out This mimics the behaviour of RCS.
256 */
257#define TAG_HEAD "HEAD"
258#define TAG_BASE "BASE"
259
260/* Environment variable used by CVS */
261#define CVSREAD_ENV "CVSREAD" /* make files read-only */
262#define CVSREAD_DFLT 0 /* writable files by default */
263
264#define CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */
265
266#define TMPDIR_ENV "TMPDIR" /* Temporary directory */
267/* #define TMPDIR_DFLT Set by options.h */
268
269#define EDITOR1_ENV "CVSEDITOR" /* which editor to use */
270#define EDITOR2_ENV "VISUAL" /* which editor to use */
271#define EDITOR3_ENV "EDITOR" /* which editor to use */
272/* #define EDITOR_DFLT Set by options.h */
273
274#define CVSROOT_ENV "CVSROOT" /* source directory root */
275#define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
276
277#define IGNORE_ENV "CVSIGNORE" /* More files to ignore */
278#define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */
279
280#define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */
281/* #define CVSUMASK_DFLT Set by options.h */
282
283/*
284 * If the beginning of the Repository matches the following string, strip it
285 * so that the output to the logfile does not contain a full pathname.
286 *
287 * If the CVSROOT environment variable is set, it overrides this define.
288 */
289#define REPOS_STRIP "/master/"
290
291/* Large enough to hold DATEFORM. Not an arbitrary limit as long as
292 it is used for that purpose, and not to hold a string from the
293 command line, the client, etc. */
294#define MAXDATELEN 50
295
296/* The type of an entnode. */
297enum ent_type
298{
299 ENT_FILE, ENT_SUBDIR
300};
301
302/* structure of a entry record */
303struct entnode
304{
305 enum ent_type type;
306 char *user;
307 char *version;
308
309 /* Timestamp, or "" if none (never NULL). */
310 char *timestamp;
311
312 /* Keyword expansion options, or "" if none (never NULL). */
313 char *options;
314
315 char *tag;
316 char *date;
317 char *conflict;
318};
319typedef struct entnode Entnode;
320
321/* The type of request that is being done in do_module() */
322enum mtype
323{
324 CHECKOUT, TAG, PATCH, EXPORT, MISC
325};
326
327/*
328 * structure used for list-private storage by Entries_Open() and
329 * Version_TS() and Find_Directories().
330 */
331struct stickydirtag
332{
333 /* These fields pass sticky tag information from Entries_Open() to
334 Version_TS(). */
335 int aflag;
336 char *tag;
337 char *date;
338 int nonbranch;
339
340 /* This field is set by Entries_Open() if there was subdirectory
341 information; Find_Directories() uses it to see whether it needs
342 to scan the directory itself. */
343 int subdirs;
344};
345
346/* Flags for find_{names,dirs} routines */
347#define W_LOCAL 0x01 /* look for files locally */
348#define W_REPOS 0x02 /* look for files in the repository */
349#define W_ATTIC 0x04 /* look for files in the attic */
350
351/* Flags for return values of direnter procs for the recursion processor */
352enum direnter_type
353{
354 R_PROCESS = 1, /* process files and maybe dirs */
355 R_SKIP_FILES, /* don't process files in this dir */
356 R_SKIP_DIRS, /* don't process sub-dirs */
357 R_SKIP_ALL /* don't process files or dirs */
358};
359#ifdef ENUMS_CAN_BE_TROUBLE
360typedef int Dtype;
361#else
362typedef enum direnter_type Dtype;
363#endif
364
75
76#include <ctype.h>
77#include <pwd.h>
78#include <signal.h>
79
80#ifdef HAVE_ERRNO_H
81#include <errno.h>
82#else
83#ifndef errno
84extern int errno;
85#endif /* !errno */
86#endif /* HAVE_ERRNO_H */
87
88#include "system.h"
89
90#include "hash.h"
91
92#include "root.h"
93
94#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
95# include "client.h"
96#endif
97
98#ifdef MY_NDBM
99#include "myndbm.h"
100#else
101#include <ndbm.h>
102#endif /* MY_NDBM */
103
104#include "regex.h"
105#include "getopt.h"
106#include "wait.h"
107
108#include "rcs.h"
109
110
111/* This actually gets set in system.h. Note that the _ONLY_ reason for
112 this is if various system calls (getwd, getcwd, readlink) require/want
113 us to use it. All other parts of CVS allocate pathname buffers
114 dynamically, and we want to keep it that way. */
115#ifndef PATH_MAX
116#ifdef MAXPATHLEN
117#define PATH_MAX MAXPATHLEN+2
118#else
119#define PATH_MAX 1024+2
120#endif
121#endif /* PATH_MAX */
122
123/* Definitions for the CVS Administrative directory and the files it contains.
124 Here as #define's to make changing the names a simple task. */
125
126#ifdef USE_VMS_FILENAMES
127#define CVSADM "CVS"
128#define CVSADM_ENT "CVS/Entries."
129#define CVSADM_ENTBAK "CVS/Entries.Backup"
130#define CVSADM_ENTLOG "CVS/Entries.Log"
131#define CVSADM_ENTSTAT "CVS/Entries.Static"
132#define CVSADM_REP "CVS/Repository."
133#define CVSADM_ROOT "CVS/Root."
134#define CVSADM_CIPROG "CVS/Checkin.prog"
135#define CVSADM_UPROG "CVS/Update.prog"
136#define CVSADM_TAG "CVS/Tag."
137#define CVSADM_NOTIFY "CVS/Notify."
138#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
139#define CVSADM_BASE "CVS/Base"
140#define CVSADM_BASEREV "CVS/Baserev."
141#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
142#define CVSADM_TEMPLATE "CVS/Template."
143#else /* USE_VMS_FILENAMES */
144#define CVSADM "CVS"
145#define CVSADM_ENT "CVS/Entries"
146#define CVSADM_ENTBAK "CVS/Entries.Backup"
147#define CVSADM_ENTLOG "CVS/Entries.Log"
148#define CVSADM_ENTSTAT "CVS/Entries.Static"
149#define CVSADM_REP "CVS/Repository"
150#define CVSADM_ROOT "CVS/Root"
151#define CVSADM_CIPROG "CVS/Checkin.prog"
152#define CVSADM_UPROG "CVS/Update.prog"
153#define CVSADM_TAG "CVS/Tag"
154#define CVSADM_NOTIFY "CVS/Notify"
155#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
156/* A directory in which we store base versions of files we currently are
157 editing with "cvs edit". */
158#define CVSADM_BASE "CVS/Base"
159#define CVSADM_BASEREV "CVS/Baserev"
160#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
161/* File which contains the template for use in log messages. */
162#define CVSADM_TEMPLATE "CVS/Template"
163#endif /* USE_VMS_FILENAMES */
164
165/* This is the special directory which we use to store various extra
166 per-directory information in the repository. It must be the same as
167 CVSADM to avoid creating a new reserved directory name which users cannot
168 use, but is a separate #define because if anyone changes it (which I don't
169 recommend), one needs to deal with old, unconverted, repositories.
170
171 See fileattr.h for details about file attributes, the only thing stored
172 in CVSREP currently. */
173#define CVSREP "CVS"
174
175/*
176 * Definitions for the CVSROOT Administrative directory and the files it
177 * contains. This directory is created as a sub-directory of the $CVSROOT
178 * environment variable, and holds global administration information for the
179 * entire source repository beginning at $CVSROOT.
180 */
181#define CVSROOTADM "CVSROOT"
182#define CVSROOTADM_MODULES "modules"
183#define CVSROOTADM_LOGINFO "loginfo"
184#define CVSROOTADM_RCSINFO "rcsinfo"
185#define CVSROOTADM_COMMITINFO "commitinfo"
186#define CVSROOTADM_TAGINFO "taginfo"
187#define CVSROOTADM_EDITINFO "editinfo"
188#define CVSROOTADM_VERIFYMSG "verifymsg"
189#define CVSROOTADM_HISTORY "history"
190#define CVSROOTADM_VALTAGS "val-tags"
191#define CVSROOTADM_IGNORE "cvsignore"
192#define CVSROOTADM_CHECKOUTLIST "checkoutlist"
193#define CVSROOTADM_WRAPPER "cvswrappers"
194#define CVSROOTADM_NOTIFY "notify"
195#define CVSROOTADM_USERS "users"
196#define CVSROOTADM_READERS "readers"
197#define CVSROOTADM_WRITERS "writers"
198#define CVSROOTADM_PASSWD "passwd"
199#define CVSROOTADM_CONFIG "config"
200#define CVSROOTADM_OPTIONS "options"
201
202#define CVSNULLREPOS "Emptydir" /* an empty directory */
203
204/* Other CVS file names */
205
206/* Files go in the attic if the head main branch revision is dead,
207 otherwise they go in the regular repository directories. The whole
208 concept of having an attic is sort of a relic from before death
209 support but on the other hand, it probably does help the speed of
210 some operations (such as main branch checkouts and updates). */
211#define CVSATTIC "Attic"
212
213#define CVSLCK "#cvs.lock"
214#define CVSRFL "#cvs.rfl"
215#define CVSWFL "#cvs.wfl"
216#define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */
217#define CVSEXT_LOG ",t"
218#define CVSPREFIX ",,"
219#define CVSDOTIGNORE ".cvsignore"
220#define CVSDOTWRAPPER ".cvswrappers"
221
222/* Command attributes -- see function lookup_command_attribute(). */
223#define CVS_CMD_IGNORE_ADMROOT 1
224
225/* Set if CVS needs to create a CVS/Root file upon completion of this
226 command. The name may be slightly confusing, because the flag
227 isn't really as general purpose as it seems (it is not set for cvs
228 release). */
229
230#define CVS_CMD_USES_WORK_DIR 2
231
232#define CVS_CMD_MODIFIES_REPOSITORY 4
233
234/* miscellaneous CVS defines */
235
236/* This is the string which is at the start of the non-log-message lines
237 that we put up for the user when they edit the log message. */
238#define CVSEDITPREFIX "CVS: "
239/* Number of characters in CVSEDITPREFIX to compare when deciding to strip
240 off those lines. We don't check for the space, to accomodate users who
241 have editors which strip trailing spaces. */
242#define CVSEDITPREFIXLEN 4
243
244#define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
245#define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
246#define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
247
248#ifdef USE_VMS_FILENAMES
249#define BAKPREFIX "_$"
250#define DEVNULL "NLA0:"
251#else /* USE_VMS_FILENAMES */
252#define BAKPREFIX ".#" /* when rcsmerge'ing */
253#ifndef DEVNULL
254#define DEVNULL "/dev/null"
255#endif
256#endif /* USE_VMS_FILENAMES */
257
258/*
259 * Special tags. -rHEAD refers to the head of an RCS file, regardless of any
260 * sticky tags. -rBASE refers to the current revision the user has checked
261 * out This mimics the behaviour of RCS.
262 */
263#define TAG_HEAD "HEAD"
264#define TAG_BASE "BASE"
265
266/* Environment variable used by CVS */
267#define CVSREAD_ENV "CVSREAD" /* make files read-only */
268#define CVSREAD_DFLT 0 /* writable files by default */
269
270#define CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */
271
272#define TMPDIR_ENV "TMPDIR" /* Temporary directory */
273/* #define TMPDIR_DFLT Set by options.h */
274
275#define EDITOR1_ENV "CVSEDITOR" /* which editor to use */
276#define EDITOR2_ENV "VISUAL" /* which editor to use */
277#define EDITOR3_ENV "EDITOR" /* which editor to use */
278/* #define EDITOR_DFLT Set by options.h */
279
280#define CVSROOT_ENV "CVSROOT" /* source directory root */
281#define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
282
283#define IGNORE_ENV "CVSIGNORE" /* More files to ignore */
284#define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */
285
286#define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */
287/* #define CVSUMASK_DFLT Set by options.h */
288
289/*
290 * If the beginning of the Repository matches the following string, strip it
291 * so that the output to the logfile does not contain a full pathname.
292 *
293 * If the CVSROOT environment variable is set, it overrides this define.
294 */
295#define REPOS_STRIP "/master/"
296
297/* Large enough to hold DATEFORM. Not an arbitrary limit as long as
298 it is used for that purpose, and not to hold a string from the
299 command line, the client, etc. */
300#define MAXDATELEN 50
301
302/* The type of an entnode. */
303enum ent_type
304{
305 ENT_FILE, ENT_SUBDIR
306};
307
308/* structure of a entry record */
309struct entnode
310{
311 enum ent_type type;
312 char *user;
313 char *version;
314
315 /* Timestamp, or "" if none (never NULL). */
316 char *timestamp;
317
318 /* Keyword expansion options, or "" if none (never NULL). */
319 char *options;
320
321 char *tag;
322 char *date;
323 char *conflict;
324};
325typedef struct entnode Entnode;
326
327/* The type of request that is being done in do_module() */
328enum mtype
329{
330 CHECKOUT, TAG, PATCH, EXPORT, MISC
331};
332
333/*
334 * structure used for list-private storage by Entries_Open() and
335 * Version_TS() and Find_Directories().
336 */
337struct stickydirtag
338{
339 /* These fields pass sticky tag information from Entries_Open() to
340 Version_TS(). */
341 int aflag;
342 char *tag;
343 char *date;
344 int nonbranch;
345
346 /* This field is set by Entries_Open() if there was subdirectory
347 information; Find_Directories() uses it to see whether it needs
348 to scan the directory itself. */
349 int subdirs;
350};
351
352/* Flags for find_{names,dirs} routines */
353#define W_LOCAL 0x01 /* look for files locally */
354#define W_REPOS 0x02 /* look for files in the repository */
355#define W_ATTIC 0x04 /* look for files in the attic */
356
357/* Flags for return values of direnter procs for the recursion processor */
358enum direnter_type
359{
360 R_PROCESS = 1, /* process files and maybe dirs */
361 R_SKIP_FILES, /* don't process files in this dir */
362 R_SKIP_DIRS, /* don't process sub-dirs */
363 R_SKIP_ALL /* don't process files or dirs */
364};
365#ifdef ENUMS_CAN_BE_TROUBLE
366typedef int Dtype;
367#else
368typedef enum direnter_type Dtype;
369#endif
370
371/* Recursion processor lock types */
372#define LOCK_NONE 0
373#define LOCK_READ 1
374#define LOCK_WRITE 2
375
365extern char *program_name, *program_path, *command_name;
366extern char *Tmpdir, *Editor;
367extern int cvsadmin_root;
368extern char *CurDir;
369extern int really_quiet, quiet;
370extern int use_editor;
371extern int cvswrite;
372extern mode_t cvsumask;
373extern char *RCS_citag;
374
375
376
377/* This global variable holds the global -d option. It is NULL if -d
378 was not used, which means that we must get the CVSroot information
379 from the CVSROOT environment variable or from a CVS/Root file. */
380extern char *CVSroot_cmdline;
381
382/* These variables keep track of all of the CVSROOT directories that
383 have been seen by the client and the current one of those selected. */
384extern List *root_directories;
385extern cvsroot_t *current_parsed_root;
386
387extern char *emptydir_name PROTO ((void));
388extern int safe_location PROTO ((char *));
389
390extern int trace; /* Show all commands */
391extern int noexec; /* Don't modify disk anywhere */
392extern int readonlyfs; /* fail on all write locks; succeed all read locks */
393extern int logoff; /* Don't write history entry */
394extern int require_real_user; /* skip CVSROOT/passwd, /etc/passwd users only*/
395
396extern int top_level_admin;
397
398
399#define LOGMSG_REREAD_NEVER 0 /* do_verify - never reread message */
400#define LOGMSG_REREAD_ALWAYS 1 /* do_verify - always reread message */
401#define LOGMSG_REREAD_STAT 2 /* do_verify - reread message if changed */
402extern int RereadLogAfterVerify;
403
404#ifdef CLIENT_SUPPORT
405extern List *dirs_sent_to_server; /* used to decide which "Argument
406 xxx" commands to send to each
407 server in multiroot mode. */
408#endif
409
410extern char hostname[];
411
412/* Externs that are included directly in the CVS sources */
413
414int RCS_merge PROTO((RCSNode *, char *, char *, char *, char *, char *));
415/* Flags used by RCS_* functions. See the description of the individual
416 functions for which flags mean what for each function. */
417#define RCS_FLAGS_FORCE 1
418#define RCS_FLAGS_DEAD 2
419#define RCS_FLAGS_QUIET 4
420#define RCS_FLAGS_MODTIME 8
421#define RCS_FLAGS_KEEPFILE 16
422
423extern int RCS_exec_rcsdiff PROTO ((RCSNode *rcsfile,
424 char *opts, char *options,
425 char *rev1, char *rev2,
426 char *label1, char *label2,
427 char *workfile));
428extern int diff_exec PROTO ((char *file1, char *file2,
429 char *label1, char *label2,
430 char *options, char *out));
376extern char *program_name, *program_path, *command_name;
377extern char *Tmpdir, *Editor;
378extern int cvsadmin_root;
379extern char *CurDir;
380extern int really_quiet, quiet;
381extern int use_editor;
382extern int cvswrite;
383extern mode_t cvsumask;
384extern char *RCS_citag;
385
386
387
388/* This global variable holds the global -d option. It is NULL if -d
389 was not used, which means that we must get the CVSroot information
390 from the CVSROOT environment variable or from a CVS/Root file. */
391extern char *CVSroot_cmdline;
392
393/* These variables keep track of all of the CVSROOT directories that
394 have been seen by the client and the current one of those selected. */
395extern List *root_directories;
396extern cvsroot_t *current_parsed_root;
397
398extern char *emptydir_name PROTO ((void));
399extern int safe_location PROTO ((char *));
400
401extern int trace; /* Show all commands */
402extern int noexec; /* Don't modify disk anywhere */
403extern int readonlyfs; /* fail on all write locks; succeed all read locks */
404extern int logoff; /* Don't write history entry */
405extern int require_real_user; /* skip CVSROOT/passwd, /etc/passwd users only*/
406
407extern int top_level_admin;
408
409
410#define LOGMSG_REREAD_NEVER 0 /* do_verify - never reread message */
411#define LOGMSG_REREAD_ALWAYS 1 /* do_verify - always reread message */
412#define LOGMSG_REREAD_STAT 2 /* do_verify - reread message if changed */
413extern int RereadLogAfterVerify;
414
415#ifdef CLIENT_SUPPORT
416extern List *dirs_sent_to_server; /* used to decide which "Argument
417 xxx" commands to send to each
418 server in multiroot mode. */
419#endif
420
421extern char hostname[];
422
423/* Externs that are included directly in the CVS sources */
424
425int RCS_merge PROTO((RCSNode *, char *, char *, char *, char *, char *));
426/* Flags used by RCS_* functions. See the description of the individual
427 functions for which flags mean what for each function. */
428#define RCS_FLAGS_FORCE 1
429#define RCS_FLAGS_DEAD 2
430#define RCS_FLAGS_QUIET 4
431#define RCS_FLAGS_MODTIME 8
432#define RCS_FLAGS_KEEPFILE 16
433
434extern int RCS_exec_rcsdiff PROTO ((RCSNode *rcsfile,
435 char *opts, char *options,
436 char *rev1, char *rev2,
437 char *label1, char *label2,
438 char *workfile));
439extern int diff_exec PROTO ((char *file1, char *file2,
440 char *label1, char *label2,
441 char *options, char *out));
431extern int diff_execv PROTO ((char *file1, char *file2,
432 char *label1, char *label2,
433 char *options, char *out));
434
435
436
437#include "error.h"
438
439DBM *open_module PROTO((void));
440FILE *open_file PROTO((const char *, const char *));
441List *Find_Directories PROTO((char *repository, int which, List *entries));
442void Entries_Close PROTO((List *entries));
443List *Entries_Open PROTO ((int aflag, char *update_dir));
444void Subdirs_Known PROTO((List *entries));
445void Subdir_Register PROTO((List *, const char *, const char *));
446void Subdir_Deregister PROTO((List *, const char *, const char *));
447
448char *Make_Date PROTO((char *rawdate));
449char *date_from_time_t PROTO ((time_t));
450void date_to_internet PROTO ((char *, const char *));
451void date_to_tm PROTO ((struct tm *, const char *));
452void tm_to_internet PROTO ((char *, const struct tm *));
453
454char *Name_Repository PROTO((char *dir, char *update_dir));
455char *Short_Repository PROTO((char *repository));
456void Sanitize_Repository_Name PROTO((char *repository));
457
458char *Name_Root PROTO((char *dir, char *update_dir));
459void free_cvsroot_t PROTO((cvsroot_t *root_in));
460cvsroot_t *parse_cvsroot PROTO((char *root));
461cvsroot_t *local_cvsroot PROTO((char *dir));
462void Create_Root PROTO((char *dir, char *rootdir));
463void root_allow_add PROTO ((char *));
464void root_allow_free PROTO ((void));
465int root_allow_ok PROTO ((char *));
466
467char *gca PROTO((const char *rev1, const char *rev2));
468extern void check_numeric PROTO ((const char *, int, char **));
469char *getcaller PROTO((void));
470char *time_stamp PROTO((char *file));
471
472void *xmalloc PROTO((size_t bytes));
473void *xrealloc PROTO((void *ptr, size_t bytes));
474void expand_string PROTO ((char **, size_t *, size_t));
475void xrealloc_and_strcat PROTO ((char **, size_t *, const char *));
476char *xstrdup PROTO((const char *str));
477void strip_trailing_newlines PROTO((char *str));
478int pathname_levels PROTO ((char *path));
479
480typedef int (*CALLPROC) PROTO((char *repository, char *value));
481int Parse_Info PROTO((char *infofile, char *repository, CALLPROC callproc, int all));
482extern int parse_config PROTO ((char *));
483
484typedef RETSIGTYPE (*SIGCLEANUPPROC) PROTO(());
485int SIG_register PROTO((int sig, SIGCLEANUPPROC sigcleanup));
486int isdir PROTO((const char *file));
487int isfile PROTO((const char *file));
488int islink PROTO((const char *file));
489int isdevice PROTO ((const char *));
490int isreadable PROTO((const char *file));
491int iswritable PROTO((const char *file));
492int isaccessible PROTO((const char *file, const int mode));
493int isabsolute PROTO((const char *filename));
494char *xreadlink PROTO((const char *link));
495char *last_component PROTO((char *path));
496char *get_homedir PROTO ((void));
442
443
444#include "error.h"
445
446DBM *open_module PROTO((void));
447FILE *open_file PROTO((const char *, const char *));
448List *Find_Directories PROTO((char *repository, int which, List *entries));
449void Entries_Close PROTO((List *entries));
450List *Entries_Open PROTO ((int aflag, char *update_dir));
451void Subdirs_Known PROTO((List *entries));
452void Subdir_Register PROTO((List *, const char *, const char *));
453void Subdir_Deregister PROTO((List *, const char *, const char *));
454
455char *Make_Date PROTO((char *rawdate));
456char *date_from_time_t PROTO ((time_t));
457void date_to_internet PROTO ((char *, const char *));
458void date_to_tm PROTO ((struct tm *, const char *));
459void tm_to_internet PROTO ((char *, const struct tm *));
460
461char *Name_Repository PROTO((char *dir, char *update_dir));
462char *Short_Repository PROTO((char *repository));
463void Sanitize_Repository_Name PROTO((char *repository));
464
465char *Name_Root PROTO((char *dir, char *update_dir));
466void free_cvsroot_t PROTO((cvsroot_t *root_in));
467cvsroot_t *parse_cvsroot PROTO((char *root));
468cvsroot_t *local_cvsroot PROTO((char *dir));
469void Create_Root PROTO((char *dir, char *rootdir));
470void root_allow_add PROTO ((char *));
471void root_allow_free PROTO ((void));
472int root_allow_ok PROTO ((char *));
473
474char *gca PROTO((const char *rev1, const char *rev2));
475extern void check_numeric PROTO ((const char *, int, char **));
476char *getcaller PROTO((void));
477char *time_stamp PROTO((char *file));
478
479void *xmalloc PROTO((size_t bytes));
480void *xrealloc PROTO((void *ptr, size_t bytes));
481void expand_string PROTO ((char **, size_t *, size_t));
482void xrealloc_and_strcat PROTO ((char **, size_t *, const char *));
483char *xstrdup PROTO((const char *str));
484void strip_trailing_newlines PROTO((char *str));
485int pathname_levels PROTO ((char *path));
486
487typedef int (*CALLPROC) PROTO((char *repository, char *value));
488int Parse_Info PROTO((char *infofile, char *repository, CALLPROC callproc, int all));
489extern int parse_config PROTO ((char *));
490
491typedef RETSIGTYPE (*SIGCLEANUPPROC) PROTO(());
492int SIG_register PROTO((int sig, SIGCLEANUPPROC sigcleanup));
493int isdir PROTO((const char *file));
494int isfile PROTO((const char *file));
495int islink PROTO((const char *file));
496int isdevice PROTO ((const char *));
497int isreadable PROTO((const char *file));
498int iswritable PROTO((const char *file));
499int isaccessible PROTO((const char *file, const int mode));
500int isabsolute PROTO((const char *filename));
501char *xreadlink PROTO((const char *link));
502char *last_component PROTO((char *path));
503char *get_homedir PROTO ((void));
504char *strcat_filename_onto_homedir PROTO ((const char *, const char *));
497char *cvs_temp_name PROTO ((void));
498FILE *cvs_temp_file PROTO ((char **filename));
499void parseopts PROTO ((const char *root));
500
501int numdots PROTO((const char *s));
502char *increment_revnum PROTO ((const char *));
503int compare_revnums PROTO ((const char *, const char *));
504int unlink_file PROTO((const char *f));
505int unlink_file_dir PROTO((const char *f));
506int update PROTO((int argc, char *argv[]));
507int xcmp PROTO((const char *file1, const char *file2));
508int yesno PROTO((void));
509void *valloc PROTO((size_t bytes));
510time_t get_date PROTO((char *date, struct timeb *now));
511extern int Create_Admin PROTO ((char *dir, char *update_dir,
512 char *repository, char *tag, char *date,
513 int nonbranch, int warn, int dotemplate));
514extern int expand_at_signs PROTO ((char *, off_t, FILE *));
515
516/* Locking subsystem (implemented in lock.c). */
517
518int Reader_Lock PROTO((char *xrepository));
519void Lock_Cleanup PROTO((void));
520
521/* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL,
522 and AFLAG, anyway. */
523void lock_tree_for_write PROTO ((int argc, char **argv, int local, int which,
524 int aflag));
525
526/* See lock.c for description. */
527extern void lock_dir_for_write PROTO ((char *));
528
529/* LockDir setting from CVSROOT/config. */
530extern char *lock_dir;
531
532void Scratch_Entry PROTO((List * list, char *fname));
533void ParseTag PROTO((char **tagp, char **datep, int *nonbranchp));
534void WriteTag PROTO ((char *dir, char *tag, char *date, int nonbranch,
535 char *update_dir, char *repository));
536void WriteTemplate PROTO ((char *dir, char *update_dir));
537void cat_module PROTO((int status));
538void check_entries PROTO((char *dir));
539void close_module PROTO((DBM * db));
540void copy_file PROTO((const char *from, const char *to));
541void fperrmsg PROTO((FILE * fp, int status, int errnum, char *message,...));
542void free_names PROTO((int *pargc, char *argv[]));
543
544extern int ign_name PROTO ((char *name));
545void ign_add PROTO((char *ign, int hold));
546void ign_add_file PROTO((char *file, int hold));
547void ign_setup PROTO((void));
548void ign_dir_add PROTO((char *name));
549int ignore_directory PROTO((char *name));
550typedef void (*Ignore_proc) PROTO ((char *, char *));
551extern void ignore_files PROTO ((List *, List *, char *, Ignore_proc));
552extern int ign_inhibit_server;
553extern int ign_case;
554
555#include "update.h"
556
557void line2argv PROTO ((int *pargc, char ***argv, char *line, char *sepchars));
558void make_directories PROTO((const char *name));
559void make_directory PROTO((const char *name));
560extern int mkdir_if_needed PROTO ((char *name));
561void rename_file PROTO((const char *from, const char *to));
562/* Expand wildcards in each element of (ARGC,ARGV). This is according to the
563 files which exist in the current directory, and accordingly to OS-specific
564 conventions regarding wildcard syntax. It might be desirable to change the
565 former in the future (e.g. "cvs status *.h" including files which don't exist
566 in the working directory). The result is placed in *PARGC and *PARGV;
567 the *PARGV array itself and all the strings it contains are newly
568 malloc'd. It is OK to call it with PARGC == &ARGC or PARGV == &ARGV. */
569extern void expand_wild PROTO ((int argc, char **argv,
570 int *pargc, char ***pargv));
571
572#ifdef SERVER_SUPPORT
573extern int cvs_casecmp PROTO ((char *, char *));
574extern int fopen_case PROTO ((char *, char *, FILE **, char **));
575#endif
576
577void strip_trailing_slashes PROTO((char *path));
578void update_delproc PROTO((Node * p));
579void usage PROTO((const char *const *cpp));
580void xchmod PROTO((char *fname, int writable));
581char *xgetwd PROTO((void));
582List *Find_Names PROTO((char *repository, int which, int aflag,
583 List ** optentries));
584void Register PROTO((List * list, char *fname, char *vn, char *ts,
585 char *options, char *tag, char *date, char *ts_conflict));
586void Update_Logfile PROTO((char *repository, char *xmessage, FILE * xlogfp,
587 List * xchanges));
588void do_editor PROTO((char *dir, char **messagep,
589 char *repository, List * changes));
590
591void do_verify PROTO((char **messagep, char *repository));
592
593typedef int (*CALLBACKPROC) PROTO((int argc, char *argv[], char *where,
594 char *mwhere, char *mfile, int shorten, int local_specified,
595 char *omodule, char *msg));
596
597/* This is the structure that the recursion processor passes to the
598 fileproc to tell it about a particular file. */
599struct file_info
600{
601 /* Name of the file, without any directory component. */
602 char *file;
603
604 /* Name of the directory we are in, relative to the directory in
605 which this command was issued. We have cd'd to this directory
606 (either in the working directory or in the repository, depending
607 on which sort of recursion we are doing). If we are in the directory
608 in which the command was issued, this is "". */
609 char *update_dir;
610
611 /* update_dir and file put together, with a slash between them as
612 necessary. This is the proper way to refer to the file in user
613 messages. */
614 char *fullname;
615
616 /* Name of the directory corresponding to the repository which contains
617 this file. */
618 char *repository;
619
620 /* The pre-parsed entries for this directory. */
621 List *entries;
622
623 RCSNode *rcs;
624};
625
626typedef int (*FILEPROC) PROTO ((void *callerdat, struct file_info *finfo));
627typedef int (*FILESDONEPROC) PROTO ((void *callerdat, int err,
628 char *repository, char *update_dir,
629 List *entries));
630typedef Dtype (*DIRENTPROC) PROTO ((void *callerdat, char *dir,
631 char *repos, char *update_dir,
632 List *entries));
633typedef int (*DIRLEAVEPROC) PROTO ((void *callerdat, char *dir, int err,
634 char *update_dir, List *entries));
635
636extern int mkmodules PROTO ((char *dir));
637extern int init PROTO ((int argc, char **argv));
638
639int do_module PROTO((DBM * db, char *mname, enum mtype m_type, char *msg,
640 CALLBACKPROC callback_proc, char *where, int shorten,
641 int local_specified, int run_module_prog, int build_dirs,
642 char *extra_arg));
643void history_write PROTO((int type, char *update_dir, char *revs, char *name,
644 char *repository));
645int start_recursion PROTO((FILEPROC fileproc, FILESDONEPROC filesdoneproc,
646 DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
647 void *callerdat,
648 int argc, char *argv[], int local, int which,
505char *cvs_temp_name PROTO ((void));
506FILE *cvs_temp_file PROTO ((char **filename));
507void parseopts PROTO ((const char *root));
508
509int numdots PROTO((const char *s));
510char *increment_revnum PROTO ((const char *));
511int compare_revnums PROTO ((const char *, const char *));
512int unlink_file PROTO((const char *f));
513int unlink_file_dir PROTO((const char *f));
514int update PROTO((int argc, char *argv[]));
515int xcmp PROTO((const char *file1, const char *file2));
516int yesno PROTO((void));
517void *valloc PROTO((size_t bytes));
518time_t get_date PROTO((char *date, struct timeb *now));
519extern int Create_Admin PROTO ((char *dir, char *update_dir,
520 char *repository, char *tag, char *date,
521 int nonbranch, int warn, int dotemplate));
522extern int expand_at_signs PROTO ((char *, off_t, FILE *));
523
524/* Locking subsystem (implemented in lock.c). */
525
526int Reader_Lock PROTO((char *xrepository));
527void Lock_Cleanup PROTO((void));
528
529/* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL,
530 and AFLAG, anyway. */
531void lock_tree_for_write PROTO ((int argc, char **argv, int local, int which,
532 int aflag));
533
534/* See lock.c for description. */
535extern void lock_dir_for_write PROTO ((char *));
536
537/* LockDir setting from CVSROOT/config. */
538extern char *lock_dir;
539
540void Scratch_Entry PROTO((List * list, char *fname));
541void ParseTag PROTO((char **tagp, char **datep, int *nonbranchp));
542void WriteTag PROTO ((char *dir, char *tag, char *date, int nonbranch,
543 char *update_dir, char *repository));
544void WriteTemplate PROTO ((char *dir, char *update_dir));
545void cat_module PROTO((int status));
546void check_entries PROTO((char *dir));
547void close_module PROTO((DBM * db));
548void copy_file PROTO((const char *from, const char *to));
549void fperrmsg PROTO((FILE * fp, int status, int errnum, char *message,...));
550void free_names PROTO((int *pargc, char *argv[]));
551
552extern int ign_name PROTO ((char *name));
553void ign_add PROTO((char *ign, int hold));
554void ign_add_file PROTO((char *file, int hold));
555void ign_setup PROTO((void));
556void ign_dir_add PROTO((char *name));
557int ignore_directory PROTO((char *name));
558typedef void (*Ignore_proc) PROTO ((char *, char *));
559extern void ignore_files PROTO ((List *, List *, char *, Ignore_proc));
560extern int ign_inhibit_server;
561extern int ign_case;
562
563#include "update.h"
564
565void line2argv PROTO ((int *pargc, char ***argv, char *line, char *sepchars));
566void make_directories PROTO((const char *name));
567void make_directory PROTO((const char *name));
568extern int mkdir_if_needed PROTO ((char *name));
569void rename_file PROTO((const char *from, const char *to));
570/* Expand wildcards in each element of (ARGC,ARGV). This is according to the
571 files which exist in the current directory, and accordingly to OS-specific
572 conventions regarding wildcard syntax. It might be desirable to change the
573 former in the future (e.g. "cvs status *.h" including files which don't exist
574 in the working directory). The result is placed in *PARGC and *PARGV;
575 the *PARGV array itself and all the strings it contains are newly
576 malloc'd. It is OK to call it with PARGC == &ARGC or PARGV == &ARGV. */
577extern void expand_wild PROTO ((int argc, char **argv,
578 int *pargc, char ***pargv));
579
580#ifdef SERVER_SUPPORT
581extern int cvs_casecmp PROTO ((char *, char *));
582extern int fopen_case PROTO ((char *, char *, FILE **, char **));
583#endif
584
585void strip_trailing_slashes PROTO((char *path));
586void update_delproc PROTO((Node * p));
587void usage PROTO((const char *const *cpp));
588void xchmod PROTO((char *fname, int writable));
589char *xgetwd PROTO((void));
590List *Find_Names PROTO((char *repository, int which, int aflag,
591 List ** optentries));
592void Register PROTO((List * list, char *fname, char *vn, char *ts,
593 char *options, char *tag, char *date, char *ts_conflict));
594void Update_Logfile PROTO((char *repository, char *xmessage, FILE * xlogfp,
595 List * xchanges));
596void do_editor PROTO((char *dir, char **messagep,
597 char *repository, List * changes));
598
599void do_verify PROTO((char **messagep, char *repository));
600
601typedef int (*CALLBACKPROC) PROTO((int argc, char *argv[], char *where,
602 char *mwhere, char *mfile, int shorten, int local_specified,
603 char *omodule, char *msg));
604
605/* This is the structure that the recursion processor passes to the
606 fileproc to tell it about a particular file. */
607struct file_info
608{
609 /* Name of the file, without any directory component. */
610 char *file;
611
612 /* Name of the directory we are in, relative to the directory in
613 which this command was issued. We have cd'd to this directory
614 (either in the working directory or in the repository, depending
615 on which sort of recursion we are doing). If we are in the directory
616 in which the command was issued, this is "". */
617 char *update_dir;
618
619 /* update_dir and file put together, with a slash between them as
620 necessary. This is the proper way to refer to the file in user
621 messages. */
622 char *fullname;
623
624 /* Name of the directory corresponding to the repository which contains
625 this file. */
626 char *repository;
627
628 /* The pre-parsed entries for this directory. */
629 List *entries;
630
631 RCSNode *rcs;
632};
633
634typedef int (*FILEPROC) PROTO ((void *callerdat, struct file_info *finfo));
635typedef int (*FILESDONEPROC) PROTO ((void *callerdat, int err,
636 char *repository, char *update_dir,
637 List *entries));
638typedef Dtype (*DIRENTPROC) PROTO ((void *callerdat, char *dir,
639 char *repos, char *update_dir,
640 List *entries));
641typedef int (*DIRLEAVEPROC) PROTO ((void *callerdat, char *dir, int err,
642 char *update_dir, List *entries));
643
644extern int mkmodules PROTO ((char *dir));
645extern int init PROTO ((int argc, char **argv));
646
647int do_module PROTO((DBM * db, char *mname, enum mtype m_type, char *msg,
648 CALLBACKPROC callback_proc, char *where, int shorten,
649 int local_specified, int run_module_prog, int build_dirs,
650 char *extra_arg));
651void history_write PROTO((int type, char *update_dir, char *revs, char *name,
652 char *repository));
653int start_recursion PROTO((FILEPROC fileproc, FILESDONEPROC filesdoneproc,
654 DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
655 void *callerdat,
656 int argc, char *argv[], int local, int which,
649 int aflag, int readlock, char *update_preload,
657 int aflag, int locktype, char *update_preload,
650 int dosrcs));
651void SIG_beginCrSect PROTO((void));
652void SIG_endCrSect PROTO((void));
653int SIG_inCrSect PROTO((void));
654void read_cvsrc PROTO((int *argc, char ***argv, char *cmdname));
655
656char *make_message_rcslegal PROTO((char *message));
657extern int file_has_markers PROTO ((const struct file_info *));
658extern void get_file PROTO ((const char *, const char *, const char *,
659 char **, size_t *, size_t *));
660extern char *shell_escape PROTO((char *buf, const char *str));
661char *backup_file PROTO((const char *file, const char *suffix));
662extern void resolve_symlink PROTO ((char **filename));
663void sleep_past PROTO ((time_t desttime));
664
665/* flags for run_exec(), the fast system() for CVS */
666#define RUN_NORMAL 0x0000 /* no special behaviour */
667#define RUN_COMBINED 0x0001 /* stdout is duped to stderr */
668#define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */
669#define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
670#define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
671#define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
672#define RUN_TTY (char *)0 /* for the benefit of lint */
673
674void run_arg PROTO((const char *s));
675void run_print PROTO((FILE * fp));
676void run_setup PROTO ((const char *prog));
677int run_exec PROTO((const char *stin, const char *stout, const char *sterr,
678 int flags));
679
680/* other similar-minded stuff from run.c. */
681FILE *run_popen PROTO((const char *, const char *));
682int piped_child PROTO((char **, int *, int *));
683void close_on_exec PROTO((int));
684
685pid_t waitpid PROTO((pid_t, int *, int));
686
687/*
688 * a struct vers_ts contains all the information about a file including the
689 * user and rcs file names, and the version checked out and the head.
690 *
691 * this is usually obtained from a call to Version_TS which takes a
692 * tag argument for the RCS file if desired
693 */
694struct vers_ts
695{
696 /* rcs version user file derives from, from CVS/Entries.
697 It can have the following special values:
698
699 NULL = file is not mentioned in Entries (this is also used for a
700 directory).
701 "" = ILLEGAL! The comment used to say that it meant "no user file"
702 but as far as I know CVS didn't actually use it that way.
703 Note that according to cvs.texinfo, "" is not legal in the
704 Entries file.
705 0 = user file is new
706 -vers = user file to be removed. */
707 char *vn_user;
708
709 /* Numeric revision number corresponding to ->vn_tag (->vn_tag
710 will often be symbolic). */
711 char *vn_rcs;
712 /* If ->tag is a simple tag in the RCS file--a tag which really
713 exists which is not a magic revision--and if ->date is NULL,
714 then this is a copy of ->tag. Otherwise, it is a copy of
715 ->vn_rcs. */
716 char *vn_tag;
717
718 /* This is the timestamp from stating the file in the working directory.
719 It is NULL if there is no file in the working directory. It is
720 "Is-modified" if we know the file is modified but don't have its
721 contents. */
722 char *ts_user;
723 /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
724 are computed in a slightly different way, but the fact remains that
725 if they are equal the file in the working directory is unmodified
726 and if they differ it is modified. */
727 char *ts_rcs;
728
729 /* Options from CVS/Entries (keyword expansion), malloc'd. If none,
730 then it is an empty string (never NULL). */
731 char *options;
732
733 /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
734 and the time stamp in this field is the time stamp of the working
735 directory file which was created with the conflict markers in it.
736 This is from CVS/Entries. */
737 char *ts_conflict;
738
739 /* Tag specified on the command line, or if none, tag stored in
740 CVS/Entries. */
741 char *tag;
742 /* Date specified on the command line, or if none, date stored in
743 CVS/Entries. */
744 char *date;
745 /* If this is 1, then tag is not a branch tag. If this is 0, then
746 tag may or may not be a branch tag. */
747 int nonbranch;
748
749 /* Pointer to entries file node */
750 Entnode *entdata;
751
752 /* Pointer to parsed src file info */
753 RCSNode *srcfile;
754};
755typedef struct vers_ts Vers_TS;
756
757Vers_TS *Version_TS PROTO ((struct file_info *finfo, char *options, char *tag,
758 char *date, int force_tag_match,
759 int set_time));
760void freevers_ts PROTO ((Vers_TS ** versp));
761
762/* Miscellaneous CVS infrastructure which layers on top of the recursion
763 processor (for example, needs struct file_info). */
764
765int Checkin PROTO ((int type, struct file_info *finfo, char *rcs, char *rev,
766 char *tag, char *options, char *message));
767int No_Difference PROTO ((struct file_info *finfo, Vers_TS *vers));
768/* TODO: can the finfo argument to special_file_mismatch be changed? -twp */
769int special_file_mismatch PROTO ((struct file_info *finfo,
770 char *rev1, char *rev2));
771
772/* CVSADM_BASEREV stuff, from entries.c. */
773extern char *base_get PROTO ((struct file_info *));
774extern void base_register PROTO ((struct file_info *, char *));
775extern void base_deregister PROTO ((struct file_info *));
776
777/*
778 * defines for Classify_File() to determine the current state of a file.
779 * These are also used as types in the data field for the list we make for
780 * Update_Logfile in commit, import, and add.
781 */
782enum classify_type
783{
784 T_UNKNOWN = 1, /* no old-style analog existed */
785 T_CONFLICT, /* C (conflict) list */
786 T_NEEDS_MERGE, /* G (needs merging) list */
787 T_MODIFIED, /* M (needs checked in) list */
788 T_CHECKOUT, /* O (needs checkout) list */
789 T_ADDED, /* A (added file) list */
790 T_REMOVED, /* R (removed file) list */
791 T_REMOVE_ENTRY, /* W (removed entry) list */
792 T_UPTODATE, /* File is up-to-date */
793 T_PATCH, /* P Like C, but can patch */
794 T_TITLE /* title for node type */
795};
796typedef enum classify_type Ctype;
797
798Ctype Classify_File PROTO
799 ((struct file_info *finfo, char *tag, char *date, char *options,
800 int force_tag_match, int aflag, Vers_TS **versp, int pipeout));
801
802/*
803 * structure used for list nodes passed to Update_Logfile() and
804 * do_editor().
805 */
806struct logfile_info
807{
808 enum classify_type type;
809 char *tag;
810 char *rev_old; /* rev number before a commit/modify,
811 NULL for add or import */
812 char *rev_new; /* rev number after a commit/modify,
813 add, or import, NULL for remove */
814};
815
816/* Wrappers. */
817
818typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
819typedef enum {
820 /* -t and -f wrapper options. Treating directories as single files. */
821 WRAP_TOCVS,
822 WRAP_FROMCVS,
823 /* -k wrapper option. Default keyword expansion options. */
824 WRAP_RCSOPTION
825} WrapMergeHas;
826
827void wrap_setup PROTO((void));
828int wrap_name_has PROTO((const char *name,WrapMergeHas has));
829char *wrap_rcsoption PROTO ((const char *fileName, int asFlag));
830char *wrap_tocvs_process_file PROTO((const char *fileName));
831int wrap_merge_is_copy PROTO((const char *fileName));
832void wrap_fromcvs_process_file PROTO ((const char *fileName));
833void wrap_add_file PROTO((const char *file,int temp));
834void wrap_add PROTO((char *line,int temp));
835void wrap_send PROTO ((void));
836#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
837void wrap_unparse_rcs_options PROTO ((char **, int));
838#endif /* SERVER_SUPPORT || CLIENT_SUPPORT */
839
840/* Pathname expansion */
841char *expand_path PROTO((char *name, char *file, int line));
842
843/* User variables. */
844extern List *variable_list;
845
846extern void variable_set PROTO ((char *nameval));
847
848int watch PROTO ((int argc, char **argv));
849int edit PROTO ((int argc, char **argv));
850int unedit PROTO ((int argc, char **argv));
851int editors PROTO ((int argc, char **argv));
852int watchers PROTO ((int argc, char **argv));
853extern int annotate PROTO ((int argc, char **argv));
854extern int add PROTO ((int argc, char **argv));
855extern int admin PROTO ((int argc, char **argv));
856extern int checkout PROTO ((int argc, char **argv));
857extern int commit PROTO ((int argc, char **argv));
858extern int diff PROTO ((int argc, char **argv));
859extern int history PROTO ((int argc, char **argv));
860extern int import PROTO ((int argc, char **argv));
861extern int cvslog PROTO ((int argc, char **argv));
862#ifdef AUTH_CLIENT_SUPPORT
658 int dosrcs));
659void SIG_beginCrSect PROTO((void));
660void SIG_endCrSect PROTO((void));
661int SIG_inCrSect PROTO((void));
662void read_cvsrc PROTO((int *argc, char ***argv, char *cmdname));
663
664char *make_message_rcslegal PROTO((char *message));
665extern int file_has_markers PROTO ((const struct file_info *));
666extern void get_file PROTO ((const char *, const char *, const char *,
667 char **, size_t *, size_t *));
668extern char *shell_escape PROTO((char *buf, const char *str));
669char *backup_file PROTO((const char *file, const char *suffix));
670extern void resolve_symlink PROTO ((char **filename));
671void sleep_past PROTO ((time_t desttime));
672
673/* flags for run_exec(), the fast system() for CVS */
674#define RUN_NORMAL 0x0000 /* no special behaviour */
675#define RUN_COMBINED 0x0001 /* stdout is duped to stderr */
676#define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */
677#define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
678#define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
679#define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
680#define RUN_TTY (char *)0 /* for the benefit of lint */
681
682void run_arg PROTO((const char *s));
683void run_print PROTO((FILE * fp));
684void run_setup PROTO ((const char *prog));
685int run_exec PROTO((const char *stin, const char *stout, const char *sterr,
686 int flags));
687
688/* other similar-minded stuff from run.c. */
689FILE *run_popen PROTO((const char *, const char *));
690int piped_child PROTO((char **, int *, int *));
691void close_on_exec PROTO((int));
692
693pid_t waitpid PROTO((pid_t, int *, int));
694
695/*
696 * a struct vers_ts contains all the information about a file including the
697 * user and rcs file names, and the version checked out and the head.
698 *
699 * this is usually obtained from a call to Version_TS which takes a
700 * tag argument for the RCS file if desired
701 */
702struct vers_ts
703{
704 /* rcs version user file derives from, from CVS/Entries.
705 It can have the following special values:
706
707 NULL = file is not mentioned in Entries (this is also used for a
708 directory).
709 "" = ILLEGAL! The comment used to say that it meant "no user file"
710 but as far as I know CVS didn't actually use it that way.
711 Note that according to cvs.texinfo, "" is not legal in the
712 Entries file.
713 0 = user file is new
714 -vers = user file to be removed. */
715 char *vn_user;
716
717 /* Numeric revision number corresponding to ->vn_tag (->vn_tag
718 will often be symbolic). */
719 char *vn_rcs;
720 /* If ->tag is a simple tag in the RCS file--a tag which really
721 exists which is not a magic revision--and if ->date is NULL,
722 then this is a copy of ->tag. Otherwise, it is a copy of
723 ->vn_rcs. */
724 char *vn_tag;
725
726 /* This is the timestamp from stating the file in the working directory.
727 It is NULL if there is no file in the working directory. It is
728 "Is-modified" if we know the file is modified but don't have its
729 contents. */
730 char *ts_user;
731 /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
732 are computed in a slightly different way, but the fact remains that
733 if they are equal the file in the working directory is unmodified
734 and if they differ it is modified. */
735 char *ts_rcs;
736
737 /* Options from CVS/Entries (keyword expansion), malloc'd. If none,
738 then it is an empty string (never NULL). */
739 char *options;
740
741 /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
742 and the time stamp in this field is the time stamp of the working
743 directory file which was created with the conflict markers in it.
744 This is from CVS/Entries. */
745 char *ts_conflict;
746
747 /* Tag specified on the command line, or if none, tag stored in
748 CVS/Entries. */
749 char *tag;
750 /* Date specified on the command line, or if none, date stored in
751 CVS/Entries. */
752 char *date;
753 /* If this is 1, then tag is not a branch tag. If this is 0, then
754 tag may or may not be a branch tag. */
755 int nonbranch;
756
757 /* Pointer to entries file node */
758 Entnode *entdata;
759
760 /* Pointer to parsed src file info */
761 RCSNode *srcfile;
762};
763typedef struct vers_ts Vers_TS;
764
765Vers_TS *Version_TS PROTO ((struct file_info *finfo, char *options, char *tag,
766 char *date, int force_tag_match,
767 int set_time));
768void freevers_ts PROTO ((Vers_TS ** versp));
769
770/* Miscellaneous CVS infrastructure which layers on top of the recursion
771 processor (for example, needs struct file_info). */
772
773int Checkin PROTO ((int type, struct file_info *finfo, char *rcs, char *rev,
774 char *tag, char *options, char *message));
775int No_Difference PROTO ((struct file_info *finfo, Vers_TS *vers));
776/* TODO: can the finfo argument to special_file_mismatch be changed? -twp */
777int special_file_mismatch PROTO ((struct file_info *finfo,
778 char *rev1, char *rev2));
779
780/* CVSADM_BASEREV stuff, from entries.c. */
781extern char *base_get PROTO ((struct file_info *));
782extern void base_register PROTO ((struct file_info *, char *));
783extern void base_deregister PROTO ((struct file_info *));
784
785/*
786 * defines for Classify_File() to determine the current state of a file.
787 * These are also used as types in the data field for the list we make for
788 * Update_Logfile in commit, import, and add.
789 */
790enum classify_type
791{
792 T_UNKNOWN = 1, /* no old-style analog existed */
793 T_CONFLICT, /* C (conflict) list */
794 T_NEEDS_MERGE, /* G (needs merging) list */
795 T_MODIFIED, /* M (needs checked in) list */
796 T_CHECKOUT, /* O (needs checkout) list */
797 T_ADDED, /* A (added file) list */
798 T_REMOVED, /* R (removed file) list */
799 T_REMOVE_ENTRY, /* W (removed entry) list */
800 T_UPTODATE, /* File is up-to-date */
801 T_PATCH, /* P Like C, but can patch */
802 T_TITLE /* title for node type */
803};
804typedef enum classify_type Ctype;
805
806Ctype Classify_File PROTO
807 ((struct file_info *finfo, char *tag, char *date, char *options,
808 int force_tag_match, int aflag, Vers_TS **versp, int pipeout));
809
810/*
811 * structure used for list nodes passed to Update_Logfile() and
812 * do_editor().
813 */
814struct logfile_info
815{
816 enum classify_type type;
817 char *tag;
818 char *rev_old; /* rev number before a commit/modify,
819 NULL for add or import */
820 char *rev_new; /* rev number after a commit/modify,
821 add, or import, NULL for remove */
822};
823
824/* Wrappers. */
825
826typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
827typedef enum {
828 /* -t and -f wrapper options. Treating directories as single files. */
829 WRAP_TOCVS,
830 WRAP_FROMCVS,
831 /* -k wrapper option. Default keyword expansion options. */
832 WRAP_RCSOPTION
833} WrapMergeHas;
834
835void wrap_setup PROTO((void));
836int wrap_name_has PROTO((const char *name,WrapMergeHas has));
837char *wrap_rcsoption PROTO ((const char *fileName, int asFlag));
838char *wrap_tocvs_process_file PROTO((const char *fileName));
839int wrap_merge_is_copy PROTO((const char *fileName));
840void wrap_fromcvs_process_file PROTO ((const char *fileName));
841void wrap_add_file PROTO((const char *file,int temp));
842void wrap_add PROTO((char *line,int temp));
843void wrap_send PROTO ((void));
844#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
845void wrap_unparse_rcs_options PROTO ((char **, int));
846#endif /* SERVER_SUPPORT || CLIENT_SUPPORT */
847
848/* Pathname expansion */
849char *expand_path PROTO((char *name, char *file, int line));
850
851/* User variables. */
852extern List *variable_list;
853
854extern void variable_set PROTO ((char *nameval));
855
856int watch PROTO ((int argc, char **argv));
857int edit PROTO ((int argc, char **argv));
858int unedit PROTO ((int argc, char **argv));
859int editors PROTO ((int argc, char **argv));
860int watchers PROTO ((int argc, char **argv));
861extern int annotate PROTO ((int argc, char **argv));
862extern int add PROTO ((int argc, char **argv));
863extern int admin PROTO ((int argc, char **argv));
864extern int checkout PROTO ((int argc, char **argv));
865extern int commit PROTO ((int argc, char **argv));
866extern int diff PROTO ((int argc, char **argv));
867extern int history PROTO ((int argc, char **argv));
868extern int import PROTO ((int argc, char **argv));
869extern int cvslog PROTO ((int argc, char **argv));
870#ifdef AUTH_CLIENT_SUPPORT
871/* Some systems (namely Mac OS X) have conflicting definitions for these
872 * functions. Avoid them.
873 */
874#ifdef HAVE_LOGIN
875# define login cvs_login
876#endif /* HAVE_LOGIN */
877#ifdef HAVE_LOGOUT
878# define logout cvs_logout
879#endif /* HAVE_LOGOUT */
863extern int login PROTO((int argc, char **argv));
880extern int login PROTO((int argc, char **argv));
864int logout PROTO((int argc, char **argv));
881extern int logout PROTO((int argc, char **argv));
865#endif /* AUTH_CLIENT_SUPPORT */
866extern int patch PROTO((int argc, char **argv));
867extern int release PROTO((int argc, char **argv));
868extern int cvsremove PROTO((int argc, char **argv));
869extern int rtag PROTO((int argc, char **argv));
870extern int cvsstatus PROTO((int argc, char **argv));
871extern int cvstag PROTO((int argc, char **argv));
872extern int version PROTO((int argc, char **argv));
873
874extern unsigned long int lookup_command_attribute PROTO((char *));
875
876#if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
877char *scramble PROTO ((char *str));
878char *descramble PROTO ((char *str));
879#endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */
880
881#ifdef AUTH_CLIENT_SUPPORT
882char *get_cvs_password PROTO((void));
883int get_cvs_port_number PROTO((const cvsroot_t *root));
884char *normalize_cvsroot PROTO((const cvsroot_t *root));
885#endif /* AUTH_CLIENT_SUPPORT */
886
887extern void tag_check_valid PROTO ((char *, int, char **, int, int, char *));
888extern void tag_check_valid_join PROTO ((char *, int, char **, int, int,
889 char *));
890
891#include "server.h"
892
893/* From server.c and documented there. */
894extern void cvs_output PROTO ((const char *, size_t));
895extern void cvs_output_binary PROTO ((char *, size_t));
896extern void cvs_outerr PROTO ((const char *, size_t));
897extern void cvs_flusherr PROTO ((void));
898extern void cvs_flushout PROTO ((void));
899extern void cvs_output_tagged PROTO ((char *, char *));
882#endif /* AUTH_CLIENT_SUPPORT */
883extern int patch PROTO((int argc, char **argv));
884extern int release PROTO((int argc, char **argv));
885extern int cvsremove PROTO((int argc, char **argv));
886extern int rtag PROTO((int argc, char **argv));
887extern int cvsstatus PROTO((int argc, char **argv));
888extern int cvstag PROTO((int argc, char **argv));
889extern int version PROTO((int argc, char **argv));
890
891extern unsigned long int lookup_command_attribute PROTO((char *));
892
893#if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
894char *scramble PROTO ((char *str));
895char *descramble PROTO ((char *str));
896#endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */
897
898#ifdef AUTH_CLIENT_SUPPORT
899char *get_cvs_password PROTO((void));
900int get_cvs_port_number PROTO((const cvsroot_t *root));
901char *normalize_cvsroot PROTO((const cvsroot_t *root));
902#endif /* AUTH_CLIENT_SUPPORT */
903
904extern void tag_check_valid PROTO ((char *, int, char **, int, int, char *));
905extern void tag_check_valid_join PROTO ((char *, int, char **, int, int,
906 char *));
907
908#include "server.h"
909
910/* From server.c and documented there. */
911extern void cvs_output PROTO ((const char *, size_t));
912extern void cvs_output_binary PROTO ((char *, size_t));
913extern void cvs_outerr PROTO ((const char *, size_t));
914extern void cvs_flusherr PROTO ((void));
915extern void cvs_flushout PROTO ((void));
916extern void cvs_output_tagged PROTO ((char *, char *));