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