1 /* $CVSid: @(#)cvs.h 1.86 94/10/22 $ */
4 * basic information used in all source files
9 #include "config.h" /* this is stuff found via autoconf */
10 #include "options.h" /* these are some larger questions which
11 can't easily be automatically checked
14 /* Changed from if __STDC__ to ifdef __STDC__ because of Sun's acc compiler */
22 /* Add prototype support. */
24 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
25 #define PROTO(ARGS) ARGS
27 #define PROTO(ARGS) ()
33 /* Under OS/2, <stdio.h> doesn't define popen()/pclose(). */
42 extern char *getenv();
56 /* If the system doesn't provide strerror, it won't be declared in
61 #include <fnmatch.h> /* This is supposed to be available on Posix systems */
73 #endif /* HAVE_ERRNO_H */
78 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
96 /* XXX - for now this is static */
99 #define PATH_MAX MAXPATHLEN+2
101 #define PATH_MAX 1024+2
103 #endif /* PATH_MAX */
105 /* just in case this implementation does not define this */
112 * Copyright (c) 1992, Brian Berliner and Jeff Polk
113 * Copyright (c) 1989-1992, Brian Berliner
115 * You may distribute under the terms of the GNU General Public License as
116 * specified in the README file that comes with the CVS 1.4 kit.
118 * Definitions for the CVS Administrative directory and the files it contains.
119 * Here as #define's to make changing the names a simple task.
122 #ifdef USE_VMS_FILENAMES
124 #define CVSADM_ENT "CVS/Entries."
125 #define CVSADM_ENTBAK "CVS/Entries.Backup"
126 #define CVSADM_ENTLOG "CVS/Entries.Log"
127 #define CVSADM_ENTSTAT "CVS/Entries.Static"
128 #define CVSADM_REP "CVS/Repository."
129 #define CVSADM_ROOT "CVS/Root."
130 #define CVSADM_CIPROG "CVS/Checkin.prog"
131 #define CVSADM_UPROG "CVS/Update.prog"
132 #define CVSADM_TAG "CVS/Tag."
133 #define CVSADM_NOTIFY "CVS/Notify."
134 #define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
135 #define CVSADM_BASE "CVS/Base"
136 #define CVSADM_TEMPLATE "CVS/Template."
137 #else /* USE_VMS_FILENAMES */
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 /* File which contains the template for use in log messages. */
154 #define CVSADM_TEMPLATE "CVS/Template"
155 #endif /* USE_VMS_FILENAMES */
157 /* This is the special directory which we use to store various extra
158 per-directory information in the repository. It must be the same as
159 CVSADM to avoid creating a new reserved directory name which users cannot
160 use, but is a separate #define because if anyone changes it (which I don't
161 recommend), one needs to deal with old, unconverted, repositories.
163 See fileattr.h for details about file attributes, the only thing stored
164 in CVSREP currently. */
168 * Definitions for the CVSROOT Administrative directory and the files it
169 * contains. This directory is created as a sub-directory of the $CVSROOT
170 * environment variable, and holds global administration information for the
171 * entire source repository beginning at $CVSROOT.
173 #define CVSROOTADM "CVSROOT"
174 #define CVSROOTADM_MODULES "modules"
175 #define CVSROOTADM_LOGINFO "loginfo"
176 #define CVSROOTADM_RCSINFO "rcsinfo"
177 #define CVSROOTADM_COMMITINFO "commitinfo"
178 #define CVSROOTADM_TAGINFO "taginfo"
179 #define CVSROOTADM_EDITINFO "editinfo"
180 #define CVSROOTADM_HISTORY "history"
181 #define CVSROOTADM_VALTAGS "val-tags"
182 #define CVSROOTADM_IGNORE "cvsignore"
183 #define CVSROOTADM_CHECKOUTLIST "checkoutlist"
184 #define CVSROOTADM_WRAPPER "cvswrappers"
185 #define CVSROOTADM_NOTIFY "notify"
186 #define CVSROOTADM_USERS "users"
188 #define CVSNULLREPOS "Emptydir" /* an empty directory */
190 /* Other CVS file names */
192 /* Files go in the attic if the head main branch revision is dead,
193 otherwise they go in the regular repository directories. The whole
194 concept of having an attic is sort of a relic from before death
195 support but on the other hand, it probably does help the speed of
196 some operations (such as main branch checkouts and updates). */
197 #define CVSATTIC "Attic"
199 #define CVSLCK "#cvs.lock"
200 #define CVSRFL "#cvs.rfl"
201 #define CVSWFL "#cvs.wfl"
202 #define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */
203 #define CVSEXT_LOG ",t"
204 #define CVSPREFIX ",,"
205 #define CVSDOTIGNORE ".cvsignore"
206 #define CVSDOTWRAPPER ".cvswrappers"
208 /* miscellaneous CVS defines */
209 #define CVSEDITPREFIX "CVS: "
210 #define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
211 #define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
212 #define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
214 #ifdef USE_VMS_FILENAMES
215 #define BAKPREFIX "_$"
216 #define DEVNULL "NLA0:"
217 #else /* USE_VMS_FILENAMES */
218 #define BAKPREFIX ".#" /* when rcsmerge'ing */
220 #define DEVNULL "/dev/null"
222 #endif /* USE_VMS_FILENAMES */
228 * Special tags. -rHEAD refers to the head of an RCS file, regardless of any
229 * sticky tags. -rBASE refers to the current revision the user has checked
230 * out This mimics the behaviour of RCS.
232 #define TAG_HEAD "HEAD"
233 #define TAG_BASE "BASE"
235 /* Environment variable used by CVS */
236 #define CVSREAD_ENV "CVSREAD" /* make files read-only */
237 #define CVSREAD_DFLT FALSE /* writable files by default */
239 #define RCSBIN_ENV "RCSBIN" /* RCS binary directory */
240 /* #define RCSBIN_DFLT Set by config.h */
242 #define EDITOR1_ENV "CVSEDITOR" /* which editor to use */
243 #define EDITOR2_ENV "VISUAL" /* which editor to use */
244 #define EDITOR3_ENV "EDITOR" /* which editor to use */
245 /* #define EDITOR_DFLT Set by config.h */
247 #define CVSROOT_ENV "CVSROOT" /* source directory root */
248 #define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
250 #define IGNORE_ENV "CVSIGNORE" /* More files to ignore */
251 #define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */
253 #define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */
254 /* #define CVSUMASK_DFLT Set by config.h */
257 * If the beginning of the Repository matches the following string, strip it
258 * so that the output to the logfile does not contain a full pathname.
260 * If the CVSROOT environment variable is set, it overrides this define.
262 #define REPOS_STRIP "/master/"
265 * The maximum number of files per each CVS directory. This is mainly for
266 * sizing arrays statically rather than dynamically. 3000 seems plenty for
269 #define MAXFILEPERDIR 3000
270 #define MAXLINELEN 5000 /* max input line from a file */
271 #define MAXPROGLEN 30000 /* max program length to system() */
272 #define MAXLISTLEN 40000 /* For [A-Z]list holders */
273 #define MAXDATELEN 50 /* max length for a date */
275 /* structure of a entry record */
286 typedef struct entnode Entnode;
288 /* The type of request that is being done in do_module() */
291 CHECKOUT, TAG, PATCH, EXPORT
295 * defines for Classify_File() to determine the current state of a file.
296 * These are also used as types in the data field for the list we make for
297 * Update_Logfile in commit, import, and add.
301 T_UNKNOWN = 1, /* no old-style analog existed */
302 T_CONFLICT, /* C (conflict) list */
303 T_NEEDS_MERGE, /* G (needs merging) list */
304 T_MODIFIED, /* M (needs checked in) list */
305 T_CHECKOUT, /* O (needs checkout) list */
306 T_ADDED, /* A (added file) list */
307 T_REMOVED, /* R (removed file) list */
308 T_REMOVE_ENTRY, /* W (removed entry) list */
309 T_UPTODATE, /* File is up-to-date */
310 #ifdef SERVER_SUPPORT
311 T_PATCH, /* P Like C, but can patch */
313 T_TITLE /* title for node type */
315 typedef enum classify_type Ctype;
318 * a struct vers_ts contains all the information about a file including the
319 * user and rcs file names, and the version checked out and the head.
321 * this is usually obtained from a call to Version_TS which takes a tag argument
322 * for the RCS file if desired
326 /* rcs version user file derives from, from CVS/Entries.
327 * it can have the following special values:
328 * empty = no user file
329 * 0 = user file is new
330 * -vers = user file to be removed. */
333 /* Numeric revision number corresponding to ->vn_tag (->vn_tag
334 will often be symbolic). */
336 /* If ->tag corresponds to a tag which really exists in this file,
337 this is just a copy of ->tag. If not, this is either NULL or
338 the head revision. (Or something like that, see RCS_getversion
342 /* This is the timestamp from stating the file in the working directory.
343 It is NULL if there is no file in the working directory. */
345 /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
346 are computed in a slightly different way, but the fact remains that
347 if they are equal the file in the working directory is unmodified
348 and if they differ it is modified. */
351 /* Options from CVS/Entries (keyword expansion). */
354 /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
355 and the time stamp in this field is the time stamp of the working
356 directory file which was created with the conflict markers in it.
357 This is from CVS/Entries. */
360 /* Tag specified on the command line, or if none, tag stored in
363 /* Date specified on the command line, or if none, date stored in
367 /* Pointer to entries file node */
370 /* Pointer to parsed src file info */
373 typedef struct vers_ts Vers_TS;
376 * structure used for list-private storage by Entries_Open() and
387 /* Flags for find_{names,dirs} routines */
388 #define W_LOCAL 0x01 /* look for files locally */
389 #define W_REPOS 0x02 /* look for files in the repository */
390 #define W_ATTIC 0x04 /* look for files in the attic */
392 /* Flags for return values of direnter procs for the recursion processor */
395 R_PROCESS = 1, /* process files and maybe dirs */
396 R_SKIP_FILES, /* don't process files in this dir */
397 R_SKIP_DIRS, /* don't process sub-dirs */
398 R_SKIP_ALL /* don't process files or dirs */
400 typedef enum direnter_type Dtype;
402 extern char *program_name, *program_path, *command_name;
403 extern char *Rcsbin, *Editor, *CVSroot;
404 extern char *CVSADM_Root;
405 extern int cvsadmin_root;
407 extern int really_quiet, quiet;
408 extern int use_editor;
410 extern mode_t cvsumask;
412 extern int trace; /* Show all commands */
413 extern int noexec; /* Don't modify disk anywhere */
414 extern int logoff; /* Don't write history entry */
416 extern char hostname[];
418 /* Externs that are included directly in the CVS sources */
420 int RCS_settag PROTO((const char *, const char *, const char *));
421 int RCS_deltag PROTO((const char *, const char *, int));
422 int RCS_setbranch PROTO((const char *, const char *));
423 int RCS_lock PROTO((const char *, const char *, int));
424 int RCS_unlock PROTO((const char *, const char *, int));
425 int RCS_merge PROTO((const char *, const char *, const char *, const char *));
426 int RCS_checkout PROTO ((char *rcsfile, char *workfile, char *tag,
428 char *sout, int flags, int noerr));
429 /* Flags used by RCS_* functions. See the description of the individual
430 functions for which flags mean what for each function. */
431 #define RCS_FLAGS_LOCK 1
432 #define RCS_FLAGS_FORCE 2
433 #define RCS_FLAGS_DEAD 4
434 #define RCS_FLAGS_QUIET 8
435 #define RCS_FLAGS_MODTIME 16
436 int RCS_checkin PROTO ((char *rcsfile, char *workfile, char *message,
437 char *rev, int flags, int noerr));
443 DBM *open_module PROTO((void));
444 FILE *open_file PROTO((const char *, const char *));
445 List *Find_Directories PROTO((char *repository, int which));
446 void Entries_Close PROTO((List *entries));
447 List *Entries_Open PROTO((int aflag));
448 char *Make_Date PROTO((char *rawdate));
449 char *Name_Repository PROTO((char *dir, char *update_dir));
450 char *Name_Root PROTO((char *dir, char *update_dir));
451 void Create_Root PROTO((char *dir, char *rootdir));
452 int same_directories PROTO((char *dir1, char *dir2));
453 char *Short_Repository PROTO((char *repository));
454 char *gca PROTO((char *rev1, char *rev2));
455 char *getcaller PROTO((void));
456 char *time_stamp PROTO((char *file));
457 char *xmalloc PROTO((size_t bytes));
458 void *xrealloc PROTO((void *ptr, size_t bytes));
459 char *xstrdup PROTO((const char *str));
460 void strip_trailing_newlines PROTO((char *str));
461 int No_Difference PROTO((char *file, Vers_TS * vers, List * entries,
462 char *repository, char *update_dir));
463 typedef int (*CALLPROC) PROTO((char *repository, char *value));
464 int Parse_Info PROTO((char *infofile, char *repository, CALLPROC callproc, int all));
465 int Reader_Lock PROTO((char *xrepository));
466 typedef RETSIGTYPE (*SIGCLEANUPPROC) PROTO(());
467 int SIG_register PROTO((int sig, SIGCLEANUPPROC sigcleanup));
468 int Writer_Lock PROTO((List * list));
469 int isdir PROTO((const char *file));
470 int isfile PROTO((const char *file));
471 int islink PROTO((const char *file));
472 int isreadable PROTO((const char *file));
473 int iswritable PROTO((const char *file));
474 int isaccessible PROTO((const char *file, const int mode));
475 int isabsolute PROTO((const char *filename));
476 char *last_component PROTO((char *path));
477 char *get_homedir PROTO ((void));
479 int numdots PROTO((const char *s));
480 int unlink_file PROTO((const char *f));
481 int link_file PROTO ((const char *from, const char *to));
482 int unlink_file_dir PROTO((const char *f));
483 int update PROTO((int argc, char *argv[]));
484 int xcmp PROTO((const char *file1, const char *file2));
485 int yesno PROTO((void));
486 void *valloc PROTO((size_t bytes));
487 time_t get_date PROTO((char *date, struct timeb *now));
488 void Create_Admin PROTO((char *dir, char *update_dir,
489 char *repository, char *tag, char *date));
491 void Lock_Cleanup PROTO((void));
493 /* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL,
494 and AFLAG, anyway. */
495 void lock_tree_for_write PROTO ((int argc, char **argv, int local, int aflag));
497 /* Remove locks set by lock_tree_for_write. Currently removes readlocks
499 void lock_tree_cleanup PROTO ((void));
501 void ParseTag PROTO((char **tagp, char **datep));
502 void Scratch_Entry PROTO((List * list, char *fname));
503 void WriteTag PROTO((char *dir, char *tag, char *date));
504 void cat_module PROTO((int status));
505 void check_entries PROTO((char *dir));
506 void close_module PROTO((DBM * db));
507 void copy_file PROTO((const char *from, const char *to));
508 void (*error_set_cleanup PROTO((void (*) (void)))) PROTO ((void));
509 void fperror PROTO((FILE * fp, int status, int errnum, char *message,...));
510 void free_names PROTO((int *pargc, char *argv[]));
511 void freevers_ts PROTO((Vers_TS ** versp));
513 extern int ign_name PROTO ((char *name));
514 void ign_add PROTO((char *ign, int hold));
515 void ign_add_file PROTO((char *file, int hold));
516 void ign_setup PROTO((void));
517 void ign_dir_add PROTO((char *name));
518 int ignore_directory PROTO((char *name));
519 typedef void (*Ignore_proc) PROTO ((char *, char *));
520 extern void ignore_files PROTO ((List *, char *, Ignore_proc));
521 extern int ign_inhibit_server;
526 void line2argv PROTO((int *pargc, char *argv[], char *line));
527 void make_directories PROTO((const char *name));
528 void make_directory PROTO((const char *name));
529 void rename_file PROTO((const char *from, const char *to));
530 /* Expand wildcards in each element of (ARGC,ARGV). This is according to the
531 files which exist in the current directory, and accordingly to OS-specific
532 conventions regarding wildcard syntax. It might be desirable to change the
533 former in the future (e.g. "cvs status *.h" including files which don't exist
534 in the working directory). The result is placed in *PARGC and *PARGV;
535 the *PARGV array itself and all the strings it contains are newly
536 malloc'd. It is OK to call it with PARGC == &ARGC or PARGV == &ARGV. */
537 extern void expand_wild PROTO ((int argc, char **argv,
538 int *pargc, char ***pargv));
540 void strip_path PROTO((char *path));
541 void strip_trailing_slashes PROTO((char *path));
542 void update_delproc PROTO((Node * p));
543 void usage PROTO((const char *const *cpp));
544 void xchmod PROTO((char *fname, int writable));
545 char *xgetwd PROTO((void));
546 int Checkin PROTO((int type, char *file, char *update_dir,
547 char *repository, char *rcs, char *rev,
548 char *tag, char *options, char *message, List *entries));
549 Ctype Classify_File PROTO((char *file, char *tag, char *date, char *options,
550 int force_tag_match, int aflag, char *repository,
551 List *entries, RCSNode *rcsnode, Vers_TS **versp,
552 char *update_dir, int pipeout));
553 List *Find_Names PROTO((char *repository, int which, int aflag,
554 List ** optentries));
555 void Register PROTO((List * list, char *fname, char *vn, char *ts,
556 char *options, char *tag, char *date, char *ts_conflict));
557 void Update_Logfile PROTO((char *repository, char *xmessage, char *xrevision,
558 FILE * xlogfp, List * xchanges));
559 Vers_TS *Version_TS PROTO((char *repository, char *options, char *tag,
560 char *date, char *user, int force_tag_match,
561 int set_time, List * entries, RCSNode * rcs));
562 void do_editor PROTO((char *dir, char **messagep,
563 char *repository, List * changes));
565 typedef int (*CALLBACKPROC) PROTO((int *pargc, char *argv[], char *where,
566 char *mwhere, char *mfile, int horten, int local_specified,
567 char *omodule, char *msg));
569 /* This is the structure that the recursion processor passes to the
570 fileproc to tell it about a particular file. */
573 /* Name of the file, without any directory component. */
576 /* Name of the directory we are in, relative to the directory in
577 which this command was issued. We have cd'd to this directory
578 (either in the working directory or in the repository, depending
579 on which sort of recursion we are doing). If we are in the directory
580 in which the command was issued, this is "". */
583 /* update_dir and file put together, with a slash between them as
584 necessary. This is the proper way to refer to the file in user
588 /* Name of the directory corresponding to the repository which contains
592 /* The pre-parsed entries for this directory. */
598 typedef int (*FILEPROC) PROTO((struct file_info *finfo));
599 typedef int (*FILESDONEPROC) PROTO((int err, char *repository, char *update_dir));
600 typedef Dtype (*DIRENTPROC) PROTO((char *dir, char *repos, char *update_dir));
601 typedef int (*DIRLEAVEPROC) PROTO((char *dir, int err, char *update_dir));
603 extern int mkmodules PROTO ((char *dir));
604 extern int init PROTO ((int argc, char **argv));
606 int do_module PROTO((DBM * db, char *mname, enum mtype m_type, char *msg,
607 CALLBACKPROC callback_proc, char *where, int shorten,
608 int local_specified, int run_module_prog, char *extra_arg));
609 int do_recursion PROTO((FILEPROC xfileproc, FILESDONEPROC xfilesdoneproc,
610 DIRENTPROC xdirentproc, DIRLEAVEPROC xdirleaveproc,
611 Dtype xflags, int xwhich, int xaflag, int xreadlock,
613 void history_write PROTO((int type, char *update_dir, char *revs, char *name,
615 int start_recursion PROTO((FILEPROC fileproc, FILESDONEPROC filesdoneproc,
616 DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
617 int argc, char *argv[], int local, int which,
618 int aflag, int readlock, char *update_preload,
619 int dosrcs, int wd_is_repos));
620 void SIG_beginCrSect PROTO((void));
621 void SIG_endCrSect PROTO((void));
622 void read_cvsrc PROTO((int *argc, char ***argv, char *cmdname));
624 char *make_message_rcslegal PROTO((char *message));
626 /* flags for run_exec(), the fast system() for CVS */
627 #define RUN_NORMAL 0x0000 /* no special behaviour */
628 #define RUN_COMBINED 0x0001 /* stdout is duped to stderr */
629 #define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */
630 #define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
631 #define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
632 #define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
633 #define RUN_TTY (char *)0 /* for the benefit of lint */
635 void run_arg PROTO((const char *s));
636 void run_print PROTO((FILE * fp));
638 void run_setup PROTO((const char *fmt,...));
639 void run_args PROTO((const char *fmt,...));
644 int run_exec PROTO((char *stin, char *stout, char *sterr, int flags));
646 /* other similar-minded stuff from run.c. */
647 FILE *run_popen PROTO((const char *, const char *));
648 int piped_child PROTO((char **, int *, int *));
649 void close_on_exec PROTO((int));
650 int filter_stream_through_program PROTO((int, int, char **, pid_t *));
652 pid_t waitpid PROTO((pid_t, int *, int));
656 typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
657 typedef enum { WRAP_TOCVS, WRAP_FROMCVS, WRAP_CONFLICT } WrapMergeHas;
659 void wrap_setup PROTO((void));
660 int wrap_name_has PROTO((const char *name,WrapMergeHas has));
661 char *wrap_tocvs_process_file PROTO((const char *fileName));
662 int wrap_merge_is_copy PROTO((const char *fileName));
663 char *wrap_fromcvs_process_file PROTO((const char *fileName));
664 void wrap_add_file PROTO((const char *file,int temp));
665 void wrap_add PROTO((char *line,int temp));
667 /* Pathname expansion */
668 char *expand_path PROTO((char *name, char *file, int line));
670 /* User variables. */
671 extern List *variable_list;
673 extern void variable_set PROTO ((char *nameval));
675 int watch PROTO ((int argc, char **argv));
676 int edit PROTO ((int argc, char **argv));
677 int unedit PROTO ((int argc, char **argv));
678 int editors PROTO ((int argc, char **argv));
679 int watchers PROTO ((int argc, char **argv));
680 extern int annotate PROTO ((int argc, char **argv));
682 #if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
683 char *scramble PROTO ((char *str));
684 char *descramble PROTO ((char *str));
685 #endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */
687 extern void tag_check_valid PROTO ((char *, int, char **, int, int, char *));
689 extern void cvs_output PROTO ((char *, size_t));
690 extern void cvs_outerr PROTO ((char *, size_t));