Commit | Line | Data |
---|---|---|
fe37a9c9 WJ |
1 | /* @(#)cvs.h 1.72 92/03/31 */ |
2 | ||
3 | #include "system.h" | |
4 | #include <stdio.h> | |
5 | #include <ctype.h> | |
6 | #include <pwd.h> | |
7 | #include <signal.h> | |
8 | #include "hash.h" | |
9 | #include "rcs.h" | |
10 | #include "regex.h" | |
11 | #include "fnmatch.h" | |
12 | #include "getopt.h" | |
13 | #include "wait.h" | |
14 | #include "config.h" | |
15 | #ifdef MY_NDBM | |
16 | #include "myndbm.h" | |
17 | #else | |
18 | #include <ndbm.h> | |
19 | #endif /* !MY_NDBM */ | |
20 | ||
21 | /* XXX - for now this is static */ | |
22 | #undef PATH_MAX | |
23 | #ifdef MAXPATHLEN | |
24 | #define PATH_MAX MAXPATHLEN+2 | |
25 | #else | |
26 | #define PATH_MAX 1024+2 | |
27 | #endif | |
28 | ||
29 | /* just in case this implementation does not define this */ | |
30 | #ifndef L_tmpnam | |
31 | #define L_tmpnam 50 | |
32 | #endif | |
33 | ||
34 | #if __STDC__ | |
35 | #define CONST const | |
36 | #define PTR void * | |
37 | #else | |
38 | #define CONST | |
39 | #define PTR char * | |
40 | #endif | |
41 | ||
42 | /* | |
43 | * Copyright (c) 1992, Brian Berliner and Jeff Polk | |
44 | * Copyright (c) 1989-1992, Brian Berliner | |
45 | * | |
46 | * You may distribute under the terms of the GNU General Public License as | |
47 | * specified in the README file that comes with the CVS 1.3 kit. | |
48 | * | |
49 | * Definitions for the CVS Administrative directory and the files it contains. | |
50 | * Here as #define's to make changing the names a simple task. | |
51 | */ | |
52 | #define CVSADM "CVS" | |
53 | #define CVSADM_ENT "CVS/Entries" | |
54 | #define CVSADM_ENTBAK "CVS/Entries.Backup" | |
55 | #define CVSADM_ENTSTAT "CVS/Entries.Static" | |
56 | #define CVSADM_REP "CVS/Repository" | |
57 | #define CVSADM_CIPROG "CVS/Checkin.prog" | |
58 | #define CVSADM_UPROG "CVS/Update.prog" | |
59 | #define CVSADM_TAG "CVS/Tag" | |
60 | ||
61 | /* | |
62 | * The following are obsolete and are maintained here only so that they can be | |
63 | * cleaned up during the transition | |
64 | */ | |
65 | #define OCVSADM "CVS.adm" /* for CVS 1.2 and earlier */ | |
66 | #define CVSADM_FILE "CVS/Files" | |
67 | #define CVSADM_MOD "CVS/Mod" | |
68 | ||
69 | /* | |
70 | * Definitions for the CVSROOT Administrative directory and the files it | |
71 | * contains. This directory is created as a sub-directory of the $CVSROOT | |
72 | * environment variable, and holds global administration information for the | |
73 | * entire source repository beginning at $CVSROOT. | |
74 | */ | |
75 | #define CVSROOTADM "CVSROOT" | |
76 | #define CVSROOTADM_MODULES "modules" | |
77 | #define CVSROOTADM_LOGINFO "loginfo" | |
78 | #define CVSROOTADM_RCSINFO "rcsinfo" | |
79 | #define CVSROOTADM_COMMITINFO "commitinfo" | |
80 | #define CVSROOTADM_EDITINFO "editinfo" | |
81 | #define CVSROOTADM_HISTORY "history" | |
82 | #define CVSROOTADM_IGNORE "cvsignore" | |
83 | #define CVSNULLREPOS "Emptydir" /* an empty directory */ | |
84 | ||
85 | /* support for the modules file (CVSROOTADM_MODULES) */ | |
86 | #define CVSMODULE_OPTS "ad:i:lo:s:t:u:"/* options in modules file */ | |
87 | #define CVSMODULE_SPEC '&' /* special delimiter */ | |
88 | ||
89 | /* | |
90 | * The following are obsolete and are maintained here only so that they can be | |
91 | * cleaned up during the transition | |
92 | */ | |
93 | #define OCVSROOTADM "CVSROOT.adm" /* for CVS 1.2 and earlier */ | |
94 | ||
95 | /* Other CVS file names */ | |
96 | #define CVSATTIC "Attic" | |
97 | #define CVSLCK "#cvs.lock" | |
98 | #define CVSTFL "#cvs.tfl" | |
99 | #define CVSRFL "#cvs.rfl" | |
100 | #define CVSWFL "#cvs.wfl" | |
101 | #define CVSEXT_OPT ",p" | |
102 | #define CVSEXT_LOG ",t" | |
103 | #define CVSPREFIX ",," | |
104 | #define CVSDOTIGNORE ".cvsignore" | |
105 | ||
106 | /* miscellaneous CVS defines */ | |
107 | #define CVSEDITPREFIX "CVS: " | |
108 | #define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */ | |
109 | #define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */ | |
110 | #define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */ | |
111 | #define BAKPREFIX ".#" /* when rcsmerge'ing */ | |
112 | #define DEVNULL "/dev/null" | |
113 | ||
114 | #define FALSE 0 | |
115 | #define TRUE 1 | |
116 | ||
117 | /* | |
118 | * Special tags. -rHEAD refers to the head of an RCS file, regardless of any | |
119 | * sticky tags. -rBASE refers to the current revision the user has checked | |
120 | * out This mimics the behaviour of RCS. | |
121 | */ | |
122 | #define TAG_HEAD "HEAD" | |
123 | #define TAG_BASE "BASE" | |
124 | ||
125 | /* Environment variable used by CVS */ | |
126 | #define CVSREAD_ENV "CVSREAD" /* make files read-only */ | |
127 | #define CVSREAD_DFLT FALSE /* writable files by default */ | |
128 | ||
129 | #define RCSBIN_ENV "RCSBIN" /* RCS binary directory */ | |
130 | /* #define RCSBIN_DFLT Set by config.h */ | |
131 | ||
132 | #define EDITOR_ENV "EDITOR" /* which editor to use */ | |
133 | /* #define EDITOR_DFLT Set by config.h */ | |
134 | ||
135 | #define CVSROOT_ENV "CVSROOT" /* source directory root */ | |
136 | #define CVSROOT_DFLT NULL /* No dflt; must set for checkout */ | |
137 | ||
138 | #define IGNORE_ENV "CVSIGNORE" /* More files to ignore */ | |
139 | ||
140 | /* | |
141 | * If the beginning of the Repository matches the following string, strip it | |
142 | * so that the output to the logfile does not contain a full pathname. | |
143 | * | |
144 | * If the CVSROOT environment variable is set, it overrides this define. | |
145 | */ | |
146 | #define REPOS_STRIP "/master/" | |
147 | ||
148 | /* | |
149 | * The maximum number of files per each CVS directory. This is mainly for | |
150 | * sizing arrays statically rather than dynamically. 3000 seems plenty for | |
151 | * now. | |
152 | */ | |
153 | #define MAXFILEPERDIR 3000 | |
154 | #define MAXLINELEN 5000 /* max input line from a file */ | |
155 | #define MAXPROGLEN 30000 /* max program length to system() */ | |
156 | #define MAXLISTLEN 40000 /* For [A-Z]list holders */ | |
157 | #define MAXMESGLEN 10000 /* max RCS log message size */ | |
158 | #define MAXDATELEN 50 /* max length for a date */ | |
159 | ||
160 | /* The type of request that is being done in do_module() */ | |
161 | enum mtype | |
162 | { | |
163 | CHECKOUT, TAG, PATCH | |
164 | }; | |
165 | ||
166 | /* | |
167 | * defines for Classify_File() to determine the current state of a file. | |
168 | * These are also used as types in the data field for the list we make for | |
169 | * Update_Logfile in commit, import, and add. | |
170 | */ | |
171 | enum classify_type | |
172 | { | |
173 | T_UNKNOWN = 1, /* no old-style analog existed */ | |
174 | T_CONFLICT, /* C (conflict) list */ | |
175 | T_NEEDS_MERGE, /* G (needs merging) list */ | |
176 | T_MODIFIED, /* M (needs checked in) list */ | |
177 | T_CHECKOUT, /* O (needs checkout) list */ | |
178 | T_ADDED, /* A (added file) list */ | |
179 | T_REMOVED, /* R (removed file) list */ | |
180 | T_REMOVE_ENTRY, /* W (removed entry) list */ | |
181 | T_UPTODATE, /* File is up-to-date */ | |
182 | T_TITLE /* title for node type */ | |
183 | }; | |
184 | typedef enum classify_type Ctype; | |
185 | ||
186 | /* | |
187 | * a struct vers_ts contains all the information about a file including the | |
188 | * user and rcs file names, and the version checked out and the head. | |
189 | * | |
190 | * this is usually obtained from a call to Version_TS which takes a tag argument | |
191 | * for the RCS file if desired | |
192 | */ | |
193 | struct vers_ts | |
194 | { | |
195 | char *vn_user; /* rcs version user file derives from | |
196 | * it can have the following special | |
197 | * values: | |
198 | * empty = no user file | |
199 | * 0 = user file is new | |
200 | * -vers = user file to be removed */ | |
201 | char *vn_rcs; /* the verion for the rcs file | |
202 | * (tag version?) */ | |
203 | char *ts_user; /* the timestamp for the user file */ | |
204 | char *ts_rcs; /* the user timestamp from entries */ | |
205 | char *options; /* opts from Entries file | |
206 | * (keyword expansion) */ | |
207 | char *tag; /* tag stored in the Entries file */ | |
208 | char *date; /* date stored in the Entries file */ | |
209 | Entnode *entdata; /* pointer to entries file node */ | |
210 | RCSNode *srcfile; /* pointer to parsed src file info */ | |
211 | }; | |
212 | typedef struct vers_ts Vers_TS; | |
213 | ||
214 | /* | |
215 | * structure used for list-private storage by ParseEntries() and | |
216 | * Version_TS(). | |
217 | */ | |
218 | struct stickydirtag | |
219 | { | |
220 | int aflag; | |
221 | char *tag; | |
222 | char *date; | |
223 | char *options; | |
224 | }; | |
225 | ||
226 | /* flags for run_exec(), the fast system() for CVS */ | |
227 | #define RUN_NORMAL 0x0000 /* no special behaviour */ | |
228 | #define RUN_COMBINED 0x0001 /* stdout is duped to stderr */ | |
229 | #define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */ | |
230 | #define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */ | |
231 | #define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */ | |
232 | #define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */ | |
233 | #define RUN_TTY (char *)0 /* for the benefit of lint */ | |
234 | ||
235 | /* Flags for find_{names,dirs} routines */ | |
236 | #define W_LOCAL 0x01 /* look for files locally */ | |
237 | #define W_REPOS 0x02 /* look for files in the repository */ | |
238 | #define W_ATTIC 0x04 /* look for files in the attic */ | |
239 | ||
240 | /* Flags for return values of direnter procs for the recursion processor */ | |
241 | enum direnter_type | |
242 | { | |
243 | R_PROCESS = 1, /* process files and maybe dirs */ | |
244 | R_SKIP_FILES, /* don't process files in this dir */ | |
245 | R_SKIP_DIRS, /* don't process sub-dirs */ | |
246 | R_SKIP_ALL /* don't process files or dirs */ | |
247 | }; | |
248 | typedef enum direnter_type Dtype; | |
249 | ||
250 | extern char *program_name, *command_name; | |
251 | extern char *Rcsbin, *Editor, *CVSroot; | |
252 | extern char *CurDir; | |
253 | extern int really_quiet, quiet; | |
254 | extern int use_editor; | |
255 | extern int cvswrite; | |
256 | ||
257 | extern int trace; /* Show all commands */ | |
258 | extern int noexec; /* Don't modify disk anywhere */ | |
259 | extern int logoff; /* Don't write history entry */ | |
260 | ||
261 | /* Externs that are included directly in the CVS sources */ | |
262 | #if __STDC__ | |
263 | int Reader_Lock (char *xrepository); | |
264 | DBM *open_module (void); | |
265 | FILE *Fopen (char *name, char *mode); | |
266 | FILE *open_file (char *name, char *mode); | |
267 | List *Find_Dirs (char *repository, int which); | |
268 | List *ParseEntries (int aflag); | |
269 | char *Make_Date (char *rawdate); | |
270 | char *Name_Repository (char *dir, char *update_dir); | |
271 | char *Short_Repository (char *repository); | |
272 | char *getcaller (void); | |
273 | char *time_stamp (char *file); | |
274 | char *xmalloc (int bytes); | |
275 | char *xrealloc (char *ptr, int bytes); | |
276 | char *xstrdup (char *str); | |
277 | int No_Difference (char *file, Vers_TS * vers, List * entries); | |
278 | int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all); | |
279 | int Reader_Lock (char *xrepository); | |
280 | int SIG_register (int sig, SIGTYPE (*fn) ()); | |
281 | int Writer_Lock (List * list); | |
282 | int gethostname (char *name, int namelen); | |
283 | int ign_name (char *name); | |
284 | int isdir (char *file); | |
285 | int isfile (char *file); | |
286 | int islink (char *file); | |
287 | int isreadable (char *file); | |
288 | int iswritable (char *file); | |
289 | int link_file (char *from, char *to); | |
290 | int numdots (char *s); | |
291 | int run_exec (char *stin, char *stout, char *sterr, int flags); | |
292 | int unlink_file (char *f); | |
293 | int update (int argc, char *argv[]); | |
294 | int xcmp (char *file1, char *file2); | |
295 | int yesno (void); | |
296 | time_t get_date (char *date, struct timeb *now); | |
297 | void Create_Admin (char *dir, char *repository, char *tag, char *date); | |
298 | void Lock_Cleanup (void); | |
299 | void ParseTag (char **tagp, char **datep); | |
300 | void Scratch_Entry (List * list, char *fname); | |
301 | void WriteTag (char *dir, char *tag, char *date); | |
302 | void cat_module (int status); | |
303 | void check_entries (char *dir); | |
304 | void close_module (DBM * db); | |
305 | void copy_file (char *from, char *to); | |
306 | void error (int status, int errnum, char *message,...); | |
307 | void fperror (FILE * fp, int status, int errnum, char *message,...); | |
308 | void free_names (int *pargc, char *argv[]); | |
309 | void freevers_ts (Vers_TS ** versp); | |
310 | void ign_add (char *ign, int hold); | |
311 | void ign_add_file (char *file, int hold); | |
312 | void ign_setup (void); | |
313 | void line2argv (int *pargc, char *argv[], char *line); | |
314 | void make_directories (char *name); | |
315 | void make_directory (char *name); | |
316 | void rename_file (char *from, char *to); | |
317 | void run_arg (char *s); | |
318 | void run_args (char *fmt,...); | |
319 | void run_print (FILE * fp); | |
320 | void run_setup (char *fmt,...); | |
321 | void strip_path (char *path); | |
322 | void update_delproc (Node * p); | |
323 | void usage (char **cpp); | |
324 | void xchmod (char *fname, int writable); | |
325 | int Checkin (int type, char *file, char *repository, char *rcs, char *rev, | |
326 | char *tag, char *message, List * entries); | |
327 | Ctype Classify_File (char *file, char *tag, char *date, char *options, | |
328 | int force_tag_match, int aflag, char *repository, | |
329 | List *entries, List *srcfiles, Vers_TS **versp); | |
330 | List *Find_Names (char *repository, int which, int aflag, | |
331 | List ** optentries); | |
332 | void Register (List * list, char *fname, char *vn, char *ts, | |
333 | char *options, char *tag, char *date); | |
334 | void Update_Logfile (char *repository, char *xmessage, char *xrevision, | |
335 | FILE * xlogfp, List * xchanges); | |
336 | Vers_TS *Version_TS (char *repository, char *options, char *tag, | |
337 | char *date, char *user, int force_tag_match, | |
338 | int set_time, List * entries, List * xfiles); | |
339 | void do_editor (char *dir, char *message, char *repository, | |
340 | List * changes); | |
341 | int do_module (DBM * db, char *mname, enum mtype m_type, char *msg, | |
342 | int (*callback_proc) (), char *where, int shorten, | |
343 | int local_specified, int run_module_prog, char *extra_arg); | |
344 | int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (), | |
345 | Dtype (*xdirentproc) (), int (*xdirleaveproc) (), | |
346 | Dtype xflags, int xwhich, int xaflag, int xreadlock, | |
347 | int xdosrcs); | |
348 | int do_update (int argc, char *argv[], char *xoptions, char *xtag, | |
349 | char *xdate, int xforce, int local, int xbuild, | |
350 | int xaflag, int xprune, int xpipeout, int which, | |
351 | char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir); | |
352 | void history_write (int type, char *update_dir, char *revs, char *name, | |
353 | char *repository); | |
354 | int start_recursion (int (*fileproc) (), int (*filesdoneproc) (), | |
355 | Dtype (*direntproc) (), int (*dirleaveproc) (), | |
356 | int argc, char *argv[], int local, int which, | |
357 | int aflag, int readlock, char *update_preload, | |
358 | int dosrcs); | |
359 | void SIG_beginCrSect (); | |
360 | void SIG_endCrSect (); | |
361 | #else /* !__STDC__ */ | |
362 | DBM *open_module (); | |
363 | FILE *Fopen (); | |
364 | FILE *open_file (); | |
365 | List *Find_Dirs (); | |
366 | List *Find_Names (); | |
367 | List *ParseEntries (); | |
368 | Vers_TS *Version_TS (); | |
369 | char *Make_Date (); | |
370 | char *Name_Repository (); | |
371 | char *Short_Repository (); | |
372 | char *getcaller (); | |
373 | char *time_stamp (); | |
374 | char *xmalloc (); | |
375 | char *xrealloc (); | |
376 | char *xstrdup (); | |
377 | int Checkin (); | |
378 | Ctype Classify_File (); | |
379 | int No_Difference (); | |
380 | int Parse_Info (); | |
381 | int Reader_Lock (); | |
382 | int SIG_register (); | |
383 | int Writer_Lock (); | |
384 | int do_module (); | |
385 | int do_recursion (); | |
386 | int do_update (); | |
387 | int gethostname (); | |
388 | int ign_name (); | |
389 | int isdir (); | |
390 | int isfile (); | |
391 | int islink (); | |
392 | int isreadable (); | |
393 | int iswritable (); | |
394 | int link_file (); | |
395 | int numdots (); | |
396 | int run_exec (); | |
397 | int start_recursion (); | |
398 | int unlink_file (); | |
399 | int update (); | |
400 | int xcmp (); | |
401 | int yesno (); | |
402 | time_t get_date (); | |
403 | void Create_Admin (); | |
404 | void Lock_Cleanup (); | |
405 | void ParseTag (); | |
406 | void ParseTag (); | |
407 | void Register (); | |
408 | void Scratch_Entry (); | |
409 | void Update_Logfile (); | |
410 | void WriteTag (); | |
411 | void cat_module (); | |
412 | void check_entries (); | |
413 | void close_module (); | |
414 | void copy_file (); | |
415 | void do_editor (); | |
416 | void error (); | |
417 | void fperror (); | |
418 | void free_names (); | |
419 | void freevers_ts (); | |
420 | void history_write (); | |
421 | void ign_add (); | |
422 | void ign_add_file (); | |
423 | void ign_setup (); | |
424 | void line2argv (); | |
425 | void make_directories (); | |
426 | void make_directory (); | |
427 | void rename_file (); | |
428 | void run_arg (); | |
429 | void run_args (); | |
430 | void run_print (); | |
431 | void run_setup (); | |
432 | void strip_path (); | |
433 | void update_delproc (); | |
434 | void usage (); | |
435 | void xchmod (); | |
436 | void SIG_beginCrSect (); | |
437 | void SIG_endCrSect (); | |
438 | #endif /* __STDC__ */ |