386BSD 0.1 development
[unix-history] / usr / othersrc / public / cvs-1.3 / src / cvs.h
CommitLineData
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() */
161enum 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 */
171enum 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};
184typedef 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 */
193struct 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};
212typedef struct vers_ts Vers_TS;
213
214/*
215 * structure used for list-private storage by ParseEntries() and
216 * Version_TS().
217 */
218struct 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 */
241enum 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};
248typedef enum direnter_type Dtype;
249
250extern char *program_name, *command_name;
251extern char *Rcsbin, *Editor, *CVSroot;
252extern char *CurDir;
253extern int really_quiet, quiet;
254extern int use_editor;
255extern int cvswrite;
256
257extern int trace; /* Show all commands */
258extern int noexec; /* Don't modify disk anywhere */
259extern int logoff; /* Don't write history entry */
260
261/* Externs that are included directly in the CVS sources */
262#if __STDC__
263int Reader_Lock (char *xrepository);
264DBM *open_module (void);
265FILE *Fopen (char *name, char *mode);
266FILE *open_file (char *name, char *mode);
267List *Find_Dirs (char *repository, int which);
268List *ParseEntries (int aflag);
269char *Make_Date (char *rawdate);
270char *Name_Repository (char *dir, char *update_dir);
271char *Short_Repository (char *repository);
272char *getcaller (void);
273char *time_stamp (char *file);
274char *xmalloc (int bytes);
275char *xrealloc (char *ptr, int bytes);
276char *xstrdup (char *str);
277int No_Difference (char *file, Vers_TS * vers, List * entries);
278int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all);
279int Reader_Lock (char *xrepository);
280int SIG_register (int sig, SIGTYPE (*fn) ());
281int Writer_Lock (List * list);
282int gethostname (char *name, int namelen);
283int ign_name (char *name);
284int isdir (char *file);
285int isfile (char *file);
286int islink (char *file);
287int isreadable (char *file);
288int iswritable (char *file);
289int link_file (char *from, char *to);
290int numdots (char *s);
291int run_exec (char *stin, char *stout, char *sterr, int flags);
292int unlink_file (char *f);
293int update (int argc, char *argv[]);
294int xcmp (char *file1, char *file2);
295int yesno (void);
296time_t get_date (char *date, struct timeb *now);
297void Create_Admin (char *dir, char *repository, char *tag, char *date);
298void Lock_Cleanup (void);
299void ParseTag (char **tagp, char **datep);
300void Scratch_Entry (List * list, char *fname);
301void WriteTag (char *dir, char *tag, char *date);
302void cat_module (int status);
303void check_entries (char *dir);
304void close_module (DBM * db);
305void copy_file (char *from, char *to);
306void error (int status, int errnum, char *message,...);
307void fperror (FILE * fp, int status, int errnum, char *message,...);
308void free_names (int *pargc, char *argv[]);
309void freevers_ts (Vers_TS ** versp);
310void ign_add (char *ign, int hold);
311void ign_add_file (char *file, int hold);
312void ign_setup (void);
313void line2argv (int *pargc, char *argv[], char *line);
314void make_directories (char *name);
315void make_directory (char *name);
316void rename_file (char *from, char *to);
317void run_arg (char *s);
318void run_args (char *fmt,...);
319void run_print (FILE * fp);
320void run_setup (char *fmt,...);
321void strip_path (char *path);
322void update_delproc (Node * p);
323void usage (char **cpp);
324void xchmod (char *fname, int writable);
325int Checkin (int type, char *file, char *repository, char *rcs, char *rev,
326 char *tag, char *message, List * entries);
327Ctype 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);
330List *Find_Names (char *repository, int which, int aflag,
331 List ** optentries);
332void Register (List * list, char *fname, char *vn, char *ts,
333 char *options, char *tag, char *date);
334void Update_Logfile (char *repository, char *xmessage, char *xrevision,
335 FILE * xlogfp, List * xchanges);
336Vers_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);
339void do_editor (char *dir, char *message, char *repository,
340 List * changes);
341int 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);
344int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (),
345 Dtype (*xdirentproc) (), int (*xdirleaveproc) (),
346 Dtype xflags, int xwhich, int xaflag, int xreadlock,
347 int xdosrcs);
348int 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);
352void history_write (int type, char *update_dir, char *revs, char *name,
353 char *repository);
354int 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);
359void SIG_beginCrSect ();
360void SIG_endCrSect ();
361#else /* !__STDC__ */
362DBM *open_module ();
363FILE *Fopen ();
364FILE *open_file ();
365List *Find_Dirs ();
366List *Find_Names ();
367List *ParseEntries ();
368Vers_TS *Version_TS ();
369char *Make_Date ();
370char *Name_Repository ();
371char *Short_Repository ();
372char *getcaller ();
373char *time_stamp ();
374char *xmalloc ();
375char *xrealloc ();
376char *xstrdup ();
377int Checkin ();
378Ctype Classify_File ();
379int No_Difference ();
380int Parse_Info ();
381int Reader_Lock ();
382int SIG_register ();
383int Writer_Lock ();
384int do_module ();
385int do_recursion ();
386int do_update ();
387int gethostname ();
388int ign_name ();
389int isdir ();
390int isfile ();
391int islink ();
392int isreadable ();
393int iswritable ();
394int link_file ();
395int numdots ();
396int run_exec ();
397int start_recursion ();
398int unlink_file ();
399int update ();
400int xcmp ();
401int yesno ();
402time_t get_date ();
403void Create_Admin ();
404void Lock_Cleanup ();
405void ParseTag ();
406void ParseTag ();
407void Register ();
408void Scratch_Entry ();
409void Update_Logfile ();
410void WriteTag ();
411void cat_module ();
412void check_entries ();
413void close_module ();
414void copy_file ();
415void do_editor ();
416void error ();
417void fperror ();
418void free_names ();
419void freevers_ts ();
420void history_write ();
421void ign_add ();
422void ign_add_file ();
423void ign_setup ();
424void line2argv ();
425void make_directories ();
426void make_directory ();
427void rename_file ();
428void run_arg ();
429void run_args ();
430void run_print ();
431void run_setup ();
432void strip_path ();
433void update_delproc ();
434void usage ();
435void xchmod ();
436void SIG_beginCrSect ();
437void SIG_endCrSect ();
438#endif /* __STDC__ */