2 * Copyright (c) 1992, Brian Berliner and Jeff Polk
3 * Copyright (c) 1989-1992, Brian Berliner
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.
10 * basic information used in all source files
17 # include <config.h> /* this is stuff found via autoconf */
20 /* Changed from if __STDC__ to ifdef __STDC__ because of Sun's acc compiler */
28 /* Add prototype support. */
30 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
31 #define PROTO(ARGS) ARGS
33 #define PROTO(ARGS) ()
39 /* Under OS/2, <stdio.h> doesn't define popen()/pclose(). */
44 /* Begin GNULIB headers. */
46 /* End GNULIB headers. */
52 extern char *getenv();
66 /* If the system doesn't provide strerror, it won't be declared in
72 # include <fnmatch.h> /* This is supposed to be available on Posix systems */
73 #else /* HAVE_FNMATCH */
74 # include "fnmatch.h" /* Our substitute */
75 #endif /* HAVE_FNMATCH */
87 #endif /* HAVE_ERRNO_H */
96 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
113 /* This actually gets set in system.h. Note that the _ONLY_ reason for
114 this is if various system calls (getwd, getcwd, readlink) require/want
115 us to use it. All other parts of CVS allocate pathname buffers
116 dynamically, and we want to keep it that way. */
119 #define PATH_MAX MAXPATHLEN+2
121 #define PATH_MAX 1024+2
123 #endif /* PATH_MAX */
125 /* Definitions for the CVS Administrative directory and the files it contains.
126 Here as #define's to make changing the names a simple task. */
128 #ifdef USE_VMS_FILENAMES
130 #define CVSADM_ENT "CVS/Entries."
131 #define CVSADM_ENTBAK "CVS/Entries.Backup"
132 #define CVSADM_ENTLOG "CVS/Entries.Log"
133 #define CVSADM_ENTSTAT "CVS/Entries.Static"
134 #define CVSADM_REP "CVS/Repository."
135 #define CVSADM_ROOT "CVS/Root."
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 */
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_TAG "CVS/Tag"
152 #define CVSADM_NOTIFY "CVS/Notify"
153 #define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
154 /* A directory in which we store base versions of files we currently are
155 editing with "cvs edit". */
156 #define CVSADM_BASE "CVS/Base"
157 #define CVSADM_BASEREV "CVS/Baserev"
158 #define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
159 /* File which contains the template for use in log messages. */
160 #define CVSADM_TEMPLATE "CVS/Template"
161 #endif /* USE_VMS_FILENAMES */
163 /* This is the special directory which we use to store various extra
164 per-directory information in the repository. It must be the same as
165 CVSADM to avoid creating a new reserved directory name which users cannot
166 use, but is a separate #define because if anyone changes it (which I don't
167 recommend), one needs to deal with old, unconverted, repositories.
169 See fileattr.h for details about file attributes, the only thing stored
170 in CVSREP currently. */
174 * Definitions for the CVSROOT Administrative directory and the files it
175 * contains. This directory is created as a sub-directory of the $CVSROOT
176 * environment variable, and holds global administration information for the
177 * entire source repository beginning at $CVSROOT.
179 #define CVSROOTADM "CVSROOT"
180 #define CVSROOTADM_MODULES "modules"
181 #define CVSROOTADM_LOGINFO "loginfo"
182 #define CVSROOTADM_RCSINFO "rcsinfo"
183 #define CVSROOTADM_COMMITINFO "commitinfo"
184 #define CVSROOTADM_TAGINFO "taginfo"
185 #define CVSROOTADM_EDITINFO "editinfo"
186 #define CVSROOTADM_VERIFYMSG "verifymsg"
187 #define CVSROOTADM_HISTORY "history"
188 #define CVSROOTADM_VALTAGS "val-tags"
189 #define CVSROOTADM_IGNORE "cvsignore"
190 #define CVSROOTADM_CHECKOUTLIST "checkoutlist"
191 #define CVSROOTADM_WRAPPER "cvswrappers"
192 #define CVSROOTADM_NOTIFY "notify"
193 #define CVSROOTADM_USERS "users"
194 #define CVSROOTADM_READERS "readers"
195 #define CVSROOTADM_WRITERS "writers"
196 #define CVSROOTADM_PASSWD "passwd"
197 #define CVSROOTADM_CONFIG "config"
198 #define CVSROOTADM_OPTIONS "options"
200 #define CVSNULLREPOS "Emptydir" /* an empty directory */
202 /* Other CVS file names */
204 /* Files go in the attic if the head main branch revision is dead,
205 otherwise they go in the regular repository directories. The whole
206 concept of having an attic is sort of a relic from before death
207 support but on the other hand, it probably does help the speed of
208 some operations (such as main branch checkouts and updates). */
209 #define CVSATTIC "Attic"
211 #define CVSLCK "#cvs.lock"
212 #define CVSRFL "#cvs.rfl"
213 #define CVSWFL "#cvs.wfl"
214 #define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */
215 #define CVSEXT_LOG ",t"
216 #define CVSPREFIX ",,"
217 #define CVSDOTIGNORE ".cvsignore"
218 #define CVSDOTWRAPPER ".cvswrappers"
220 /* Command attributes -- see function lookup_command_attribute(). */
221 #define CVS_CMD_IGNORE_ADMROOT 1
223 /* Set if CVS needs to create a CVS/Root file upon completion of this
224 command. The name may be slightly confusing, because the flag
225 isn't really as general purpose as it seems (it is not set for cvs
228 #define CVS_CMD_USES_WORK_DIR 2
230 #define CVS_CMD_MODIFIES_REPOSITORY 4
232 /* miscellaneous CVS defines */
234 /* This is the string which is at the start of the non-log-message lines
235 that we put up for the user when they edit the log message. */
236 #define CVSEDITPREFIX "CVS: "
237 /* Number of characters in CVSEDITPREFIX to compare when deciding to strip
238 off those lines. We don't check for the space, to accomodate users who
239 have editors which strip trailing spaces. */
240 #define CVSEDITPREFIXLEN 4
242 #define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
243 #define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
244 #define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
246 #ifdef USE_VMS_FILENAMES
247 #define BAKPREFIX "_$"
248 #define DEVNULL "NLA0:"
249 #else /* USE_VMS_FILENAMES */
250 #define BAKPREFIX ".#" /* when rcsmerge'ing */
252 #define DEVNULL "/dev/null"
254 #endif /* USE_VMS_FILENAMES */
257 * Special tags. -rHEAD refers to the head of an RCS file, regardless of any
258 * sticky tags. -rBASE refers to the current revision the user has checked
259 * out This mimics the behaviour of RCS.
261 #define TAG_HEAD "HEAD"
262 #define TAG_BASE "BASE"
264 /* Environment variable used by CVS */
265 #define CVSREAD_ENV "CVSREAD" /* make files read-only */
266 #define CVSREAD_DFLT 0 /* writable files by default */
268 #define CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */
270 #define TMPDIR_ENV "TMPDIR" /* Temporary directory */
272 #define EDITOR1_ENV "CVSEDITOR" /* which editor to use */
273 #define EDITOR2_ENV "VISUAL" /* which editor to use */
274 #define EDITOR3_ENV "EDITOR" /* which editor to use */
276 #define CVSROOT_ENV "CVSROOT" /* source directory root */
277 #define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
279 #define IGNORE_ENV "CVSIGNORE" /* More files to ignore */
280 #define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */
282 #define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */
285 * If the beginning of the Repository matches the following string, strip it
286 * so that the output to the logfile does not contain a full pathname.
288 * If the CVSROOT environment variable is set, it overrides this define.
290 #define REPOS_STRIP "/master/"
292 /* Large enough to hold DATEFORM. Not an arbitrary limit as long as
293 it is used for that purpose, and not to hold a string from the
294 command line, the client, etc. */
295 #define MAXDATELEN 50
297 /* The type of an entnode. */
303 /* structure of a entry record */
310 /* Timestamp, or "" if none (never NULL). */
313 /* Keyword expansion options, or "" if none (never NULL). */
320 typedef struct entnode Entnode;
322 /* The type of request that is being done in do_module() */
325 CHECKOUT, TAG, PATCH, EXPORT, MISC
329 * structure used for list-private storage by Entries_Open() and
330 * Version_TS() and Find_Directories().
334 /* These fields pass sticky tag information from Entries_Open() to
341 /* This field is set by Entries_Open() if there was subdirectory
342 information; Find_Directories() uses it to see whether it needs
343 to scan the directory itself. */
347 /* Flags for find_{names,dirs} routines */
348 #define W_LOCAL 0x01 /* look for files locally */
349 #define W_REPOS 0x02 /* look for files in the repository */
350 #define W_ATTIC 0x04 /* look for files in the attic */
352 /* Flags for return values of direnter procs for the recursion processor */
355 R_PROCESS = 1, /* process files and maybe dirs */
356 R_SKIP_FILES, /* don't process files in this dir */
357 R_SKIP_DIRS, /* don't process sub-dirs */
358 R_SKIP_ALL /* don't process files or dirs */
360 #ifdef ENUMS_CAN_BE_TROUBLE
363 typedef enum direnter_type Dtype;
366 /* Recursion processor lock types */
367 #define CVS_LOCK_NONE 0
368 #define CVS_LOCK_READ 1
369 #define CVS_LOCK_WRITE 2
371 extern const char *program_name, *program_path, *cvs_cmd_name;
372 extern char *Tmpdir, *Editor;
373 extern int cvsadmin_root;
375 extern int really_quiet, quiet;
376 extern int use_editor;
378 extern mode_t cvsumask;
379 extern char *RCS_citag;
383 /* This global variable holds the global -d option. It is NULL if -d
384 was not used, which means that we must get the CVSroot information
385 from the CVSROOT environment variable or from a CVS/Root file. */
386 extern char *CVSroot_cmdline;
388 /* These variables keep track of all of the CVSROOT directories that
389 have been seen by the client and the current one of those selected. */
390 extern List *root_directories;
391 extern cvsroot_t *current_parsed_root;
393 extern char *emptydir_name PROTO ((void));
394 extern int safe_location PROTO ((char *));
396 extern int trace; /* Show all commands */
397 extern int noexec; /* Don't modify disk anywhere */
398 extern int readonlyfs; /* fail on all write locks; succeed all read locks */
399 extern int logoff; /* Don't write history entry */
400 extern int require_real_user; /* skip CVSROOT/passwd, /etc/passwd users only*/
402 extern int top_level_admin;
405 #define LOGMSG_REREAD_NEVER 0 /* do_verify - never reread message */
406 #define LOGMSG_REREAD_ALWAYS 1 /* do_verify - always reread message */
407 #define LOGMSG_REREAD_STAT 2 /* do_verify - reread message if changed */
408 extern int RereadLogAfterVerify;
410 #ifdef CLIENT_SUPPORT
411 extern List *dirs_sent_to_server; /* used to decide which "Argument
412 xxx" commands to send to each
413 server in multiroot mode. */
416 extern char hostname[];
418 /* Externs that are included directly in the CVS sources */
420 int RCS_merge PROTO((RCSNode *, const char *, const char *, const char *,
421 const char *, const char *));
422 /* Flags used by RCS_* functions. See the description of the individual
423 functions for which flags mean what for each function. */
424 #define RCS_FLAGS_FORCE 1
425 #define RCS_FLAGS_DEAD 2
426 #define RCS_FLAGS_QUIET 4
427 #define RCS_FLAGS_MODTIME 8
428 #define RCS_FLAGS_KEEPFILE 16
430 extern int RCS_exec_rcsdiff PROTO ((RCSNode *rcsfile,
431 const char *opts, const char *options,
432 const char *rev1, const char *rev1_cache,
433 const char *rev2, const char *label1,
434 const char *label2, const char *workfile));
435 extern int diff_exec PROTO ((const char *file1, const char *file2,
436 const char *label1, const char *label2,
437 const char *options, const char *out));
442 DBM *open_module PROTO((void));
443 FILE *open_file PROTO((const char *, const char *));
444 List *Find_Directories PROTO((char *repository, int which, List *entries));
445 void Entries_Close PROTO((List *entries));
446 List *Entries_Open PROTO ((int aflag, char *update_dir));
447 void Subdirs_Known PROTO((List *entries));
448 void Subdir_Register PROTO((List *, const char *, const char *));
449 void Subdir_Deregister PROTO((List *, const char *, const char *));
451 char *Make_Date PROTO((char *rawdate));
452 char *date_from_time_t PROTO ((time_t));
453 void date_to_internet PROTO ((char *, const char *));
454 void date_to_tm PROTO ((struct tm *, const char *));
455 void tm_to_internet PROTO ((char *, const struct tm *));
457 char *Name_Repository PROTO((const char *dir, const char *update_dir));
458 const char *Short_Repository PROTO((const char *repository));
459 void Sanitize_Repository_Name PROTO((char *repository));
461 char *Name_Root PROTO((char *dir, char *update_dir));
462 void free_cvsroot_t PROTO((cvsroot_t *root_in));
463 cvsroot_t *parse_cvsroot PROTO((const char *root));
464 cvsroot_t *local_cvsroot PROTO((const char *dir));
465 void Create_Root PROTO((const char *dir, const char *rootdir));
466 void root_allow_add PROTO ((char *));
467 void root_allow_free PROTO ((void));
468 int root_allow_ok PROTO ((char *));
470 char *previous_rev PROTO ((RCSNode *rcs, const char *rev));
471 char *gca PROTO ((const char *rev1, const char *rev2));
472 extern void check_numeric PROTO ((const char *, int, char **));
473 char *getcaller PROTO ((void));
474 char *time_stamp PROTO ((const char *file));
476 void *xmalloc PROTO((size_t bytes));
477 void *xrealloc PROTO((void *ptr, size_t bytes));
478 void expand_string PROTO ((char **, size_t *, size_t));
479 void xrealloc_and_strcat PROTO ((char **, size_t *, const char *));
480 char *xstrdup PROTO((const char *str));
481 int strip_trailing_newlines PROTO((char *str));
482 int pathname_levels PROTO ((const char *path));
484 typedef int (*CALLPROC) PROTO((const char *repository, const char *value));
485 int Parse_Info PROTO((const char *infofile, const char *repository,
486 CALLPROC callproc, int all));
487 extern int parse_config PROTO ((char *));
489 typedef RETSIGTYPE (*SIGCLEANUPPROC) PROTO(());
490 int SIG_register PROTO((int sig, SIGCLEANUPPROC sigcleanup));
491 int isdir PROTO((const char *file));
492 int isfile PROTO((const char *file));
493 int islink PROTO((const char *file));
494 int isdevice PROTO ((const char *));
495 int isreadable PROTO((const char *file));
496 int iswritable PROTO((const char *file));
497 int isaccessible PROTO((const char *file, const int mode));
498 int isabsolute PROTO((const char *filename));
500 char *xreadlink PROTO((const char *link));
502 char *xresolvepath PROTO((const char *path));
503 const char *last_component PROTO((const char *path));
504 char *get_homedir PROTO ((void));
505 char *strcat_filename_onto_homedir PROTO ((const char *, const char *));
506 char *cvs_temp_name PROTO ((void));
507 FILE *cvs_temp_file PROTO ((char **filename));
508 void parseopts PROTO ((const char *root));
510 int numdots PROTO((const char *s));
511 char *increment_revnum PROTO ((const char *));
512 int compare_revnums PROTO ((const char *, const char *));
513 int unlink_file PROTO((const char *f));
514 int unlink_file_dir PROTO((const char *f));
518 /* This is the structure that the recursion processor passes to the
519 fileproc to tell it about a particular file. */
522 /* Name of the file, without any directory component. */
525 /* Name of the directory we are in, relative to the directory in
526 which this command was issued. We have cd'd to this directory
527 (either in the working directory or in the repository, depending
528 on which sort of recursion we are doing). If we are in the directory
529 in which the command was issued, this is "". */
530 const char *update_dir;
532 /* update_dir and file put together, with a slash between them as
533 necessary. This is the proper way to refer to the file in user
535 const char *fullname;
537 /* Name of the directory corresponding to the repository which contains
539 const char *repository;
541 /* The pre-parsed entries for this directory. */
549 int update PROTO((int argc, char *argv[]));
550 /* The only place this is currently used outside of update.c is add.c.
551 * Restricting its use to update.c seems to be in the best interest of
552 * modularity, but I can't think of a good way to get an update of a
553 * resurrected file done and print the fact otherwise.
555 void write_letter PROTO ((struct file_info *finfo, int letter));
556 int xcmp PROTO((const char *file1, const char *file2));
557 int yesno PROTO((void));
558 void *valloc PROTO((size_t bytes));
559 time_t get_date PROTO((char *date, struct timeb *now));
560 extern int Create_Admin PROTO ((const char *dir, const char *update_dir,
561 const char *repository, const char *tag,
563 int nonbranch, int warn, int dotemplate));
564 extern int expand_at_signs PROTO ((const char *, off_t, FILE *));
566 /* Locking subsystem (implemented in lock.c). */
568 int Reader_Lock PROTO((char *xrepository));
569 void Lock_Cleanup PROTO((void));
571 /* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL,
572 and AFLAG, anyway. */
573 void lock_tree_for_write PROTO ((int argc, char **argv, int local, int which,
576 /* See lock.c for description. */
577 extern void lock_dir_for_write PROTO ((char *));
579 /* LockDir setting from CVSROOT/config. */
580 extern char *lock_dir;
582 void Scratch_Entry PROTO((List * list, const char *fname));
583 void ParseTag PROTO((char **tagp, char **datep, int *nonbranchp));
584 void WriteTag PROTO ((const char *dir, const char *tag, const char *date,
585 int nonbranch, const char *update_dir,
586 const char *repository));
587 void WriteTemplate PROTO ((const char *dir, const char *update_dir));
588 void cat_module PROTO((int status));
589 void check_entries PROTO((char *dir));
590 void close_module PROTO((DBM * db));
591 void copy_file PROTO((const char *from, const char *to));
592 void fperrmsg PROTO((FILE * fp, int status, int errnum, char *message,...));
593 void free_names PROTO((int *pargc, char *argv[]));
595 extern int ign_name PROTO ((char *name));
596 void ign_add PROTO((char *ign, int hold));
597 void ign_add_file PROTO((char *file, int hold));
598 void ign_setup PROTO((void));
599 void ign_dir_add PROTO((char *name));
600 int ignore_directory PROTO((const char *name));
601 typedef void (*Ignore_proc) PROTO ((const char *, const char *));
602 extern void ignore_files PROTO ((List *, List *, const char *, Ignore_proc));
603 extern int ign_inhibit_server;
607 void line2argv PROTO ((int *pargc, char ***argv, char *line, char *sepchars));
608 void make_directories PROTO((const char *name));
609 void make_directory PROTO((const char *name));
610 extern int mkdir_if_needed PROTO ((const char *name));
611 void rename_file PROTO((const char *from, const char *to));
612 /* Expand wildcards in each element of (ARGC,ARGV). This is according to the
613 files which exist in the current directory, and accordingly to OS-specific
614 conventions regarding wildcard syntax. It might be desirable to change the
615 former in the future (e.g. "cvs status *.h" including files which don't exist
616 in the working directory). The result is placed in *PARGC and *PARGV;
617 the *PARGV array itself and all the strings it contains are newly
618 malloc'd. It is OK to call it with PARGC == &ARGC or PARGV == &ARGV. */
619 extern void expand_wild PROTO ((int argc, char **argv,
620 int *pargc, char ***pargv));
622 #ifdef SERVER_SUPPORT
623 extern int cvs_casecmp PROTO ((const char *, const char *));
626 void strip_trailing_slashes PROTO((char *path));
627 void update_delproc PROTO((Node * p));
628 void usage PROTO((const char *const *cpp));
629 void xchmod PROTO((const char *fname, int writable));
630 char *xgetwd PROTO((void));
631 List *Find_Names PROTO((char *repository, int which, int aflag,
633 void Register PROTO((List * list, const char *fname, const char *vn,
634 const char *ts, const char *options, const char *tag,
635 const char *date, const char *ts_conflict));
636 void Update_Logfile PROTO((const char *repository, const char *xmessage,
637 FILE * xlogfp, List * xchanges));
638 void do_editor PROTO((const char *dir, char **messagep,
639 const char *repository, List * changes));
641 void do_verify PROTO((char **messagep, const char *repository));
643 typedef int (*CALLBACKPROC) PROTO((int argc, char *argv[], char *where,
644 char *mwhere, char *mfile, int shorten, int local_specified,
645 char *omodule, char *msg));
647 typedef int (*FILEPROC) PROTO ((void *callerdat, struct file_info *finfo));
648 typedef int (*FILESDONEPROC) PROTO ((void *callerdat, int err,
649 const char *repository,
650 const char *update_dir,
652 typedef Dtype (*DIRENTPROC) PROTO ((void *callerdat, const char *dir,
653 const char *repos, const char *update_dir,
655 typedef int (*DIRLEAVEPROC) PROTO ((void *callerdat, const char *dir, int err,
656 const char *update_dir, List *entries));
658 extern int mkmodules PROTO ((char *dir));
659 extern int init PROTO ((int argc, char **argv));
661 int do_module PROTO((DBM * db, char *mname, enum mtype m_type, char *msg,
662 CALLBACKPROC callback_proc, char *where, int shorten,
663 int local_specified, int run_module_prog, int build_dirs,
665 void history_write PROTO((int type, const char *update_dir, const char *revs,
666 const char *name, const char *repository));
667 int start_recursion PROTO((FILEPROC fileproc, FILESDONEPROC filesdoneproc,
668 DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
670 int argc, char *argv[], int local, int which,
671 int aflag, int locktype, char *update_preload,
672 int dosrcs, char *repository));
673 void SIG_beginCrSect PROTO((void));
674 void SIG_endCrSect PROTO((void));
675 int SIG_inCrSect PROTO((void));
676 void read_cvsrc PROTO((int *argc, char ***argv, const char *cmdname));
678 char *make_message_rcslegal PROTO((const char *message));
679 extern int file_has_conflict PROTO ((const struct file_info *,
680 const char *ts_conflict));
681 extern int file_has_markers PROTO ((const struct file_info *));
682 extern void get_file PROTO ((const char *, const char *, const char *,
683 char **, size_t *, size_t *));
684 extern char *shell_escape PROTO((char *buf, const char *str));
685 char *backup_file PROTO((const char *file, const char *suffix));
686 extern void resolve_symlink PROTO ((char **filename));
687 void sleep_past PROTO ((time_t desttime));
689 /* flags for run_exec(), the fast system() for CVS */
690 #define RUN_NORMAL 0x0000 /* no special behaviour */
691 #define RUN_COMBINED 0x0001 /* stdout is duped to stderr */
692 #define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */
693 #define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
694 #define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
695 #define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
696 #define RUN_TTY (char *)0 /* for the benefit of lint */
698 void run_arg PROTO((const char *s));
699 void run_print PROTO((FILE * fp));
700 void run_setup PROTO ((const char *prog));
701 int run_exec PROTO((const char *stin, const char *stout, const char *sterr,
704 /* other similar-minded stuff from run.c. */
705 FILE *run_popen PROTO((const char *, const char *));
706 int piped_child PROTO((const char **, int *, int *));
707 void close_on_exec PROTO((int));
709 pid_t waitpid PROTO((pid_t, int *, int));
712 * a struct vers_ts contains all the information about a file including the
713 * user and rcs file names, and the version checked out and the head.
715 * this is usually obtained from a call to Version_TS which takes a
716 * tag argument for the RCS file if desired
720 /* rcs version user file derives from, from CVS/Entries.
721 It can have the following special values:
723 NULL = file is not mentioned in Entries (this is also used for a
725 "" = ILLEGAL! The comment used to say that it meant "no user file"
726 but as far as I know CVS didn't actually use it that way.
727 Note that according to cvs.texinfo, "" is not legal in the
730 -vers = user file to be removed. */
733 /* Numeric revision number corresponding to ->vn_tag (->vn_tag
734 will often be symbolic). */
736 /* If ->tag is a simple tag in the RCS file--a tag which really
737 exists which is not a magic revision--and if ->date is NULL,
738 then this is a copy of ->tag. Otherwise, it is a copy of
742 /* This is the timestamp from stating the file in the working directory.
743 It is NULL if there is no file in the working directory. It is
744 "Is-modified" if we know the file is modified but don't have its
747 /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
748 are computed in a slightly different way, but the fact remains that
749 if they are equal the file in the working directory is unmodified
750 and if they differ it is modified. */
753 /* Options from CVS/Entries (keyword expansion), malloc'd. If none,
754 then it is an empty string (never NULL). */
757 /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
758 and the time stamp in this field is the time stamp of the working
759 directory file which was created with the conflict markers in it.
760 This is from CVS/Entries. */
763 /* Tag specified on the command line, or if none, tag stored in
766 /* Date specified on the command line, or if none, date stored in
769 /* If this is 1, then tag is not a branch tag. If this is 0, then
770 tag may or may not be a branch tag. */
773 /* Pointer to entries file node */
776 /* Pointer to parsed src file info */
779 typedef struct vers_ts Vers_TS;
781 Vers_TS *Version_TS PROTO ((struct file_info *finfo, char *options, char *tag,
782 char *date, int force_tag_match,
784 void freevers_ts PROTO ((Vers_TS ** versp));
786 /* Miscellaneous CVS infrastructure which layers on top of the recursion
787 processor (for example, needs struct file_info). */
789 int Checkin PROTO ((int type, struct file_info *finfo, char *rev,
790 char *tag, char *options, char *message));
791 int No_Difference PROTO ((struct file_info *finfo, Vers_TS *vers));
792 /* TODO: can the finfo argument to special_file_mismatch be changed? -twp */
793 int special_file_mismatch PROTO ((struct file_info *finfo,
794 char *rev1, char *rev2));
796 /* CVSADM_BASEREV stuff, from entries.c. */
797 extern char *base_get PROTO ((struct file_info *));
798 extern void base_register PROTO ((struct file_info *, char *));
799 extern void base_deregister PROTO ((struct file_info *));
802 * defines for Classify_File() to determine the current state of a file.
803 * These are also used as types in the data field for the list we make for
804 * Update_Logfile in commit, import, and add.
808 T_UNKNOWN = 1, /* no old-style analog existed */
809 T_CONFLICT, /* C (conflict) list */
810 T_NEEDS_MERGE, /* G (needs merging) list */
811 T_MODIFIED, /* M (needs checked in) list */
812 T_CHECKOUT, /* O (needs checkout) list */
813 T_ADDED, /* A (added file) list */
814 T_REMOVED, /* R (removed file) list */
815 T_REMOVE_ENTRY, /* W (removed entry) list */
816 T_UPTODATE, /* File is up-to-date */
817 T_PATCH, /* P Like C, but can patch */
818 T_TITLE /* title for node type */
820 typedef enum classify_type Ctype;
822 Ctype Classify_File PROTO
823 ((struct file_info *finfo, char *tag, char *date, char *options,
824 int force_tag_match, int aflag, Vers_TS **versp, int pipeout));
827 * structure used for list nodes passed to Update_Logfile() and
832 enum classify_type type;
834 char *rev_old; /* rev number before a commit/modify,
835 NULL for add or import */
836 char *rev_new; /* rev number after a commit/modify,
837 add, or import, NULL for remove */
842 typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
844 /* -t and -f wrapper options. Treating directories as single files. */
847 /* -k wrapper option. Default keyword expansion options. */
851 void wrap_setup PROTO((void));
852 int wrap_name_has PROTO((const char *name,WrapMergeHas has));
853 char *wrap_rcsoption PROTO ((const char *fileName, int asFlag));
854 char *wrap_tocvs_process_file PROTO((const char *fileName));
855 int wrap_merge_is_copy PROTO((const char *fileName));
856 void wrap_fromcvs_process_file PROTO ((const char *fileName));
857 void wrap_add_file PROTO((const char *file,int temp));
858 void wrap_add PROTO((char *line,int temp));
859 void wrap_send PROTO ((void));
860 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
861 void wrap_unparse_rcs_options PROTO ((char **, int));
862 #endif /* SERVER_SUPPORT || CLIENT_SUPPORT */
864 /* Pathname expansion */
865 char *expand_path PROTO((const char *name, const char *file, int line));
867 /* User variables. */
868 extern List *variable_list;
870 extern void variable_set PROTO ((char *nameval));
872 int watch PROTO ((int argc, char **argv));
873 int edit PROTO ((int argc, char **argv));
874 int unedit PROTO ((int argc, char **argv));
875 int editors PROTO ((int argc, char **argv));
876 int watchers PROTO ((int argc, char **argv));
877 extern int annotate PROTO ((int argc, char **argv));
878 extern int add PROTO ((int argc, char **argv));
879 extern int admin PROTO ((int argc, char **argv));
880 extern int checkout PROTO ((int argc, char **argv));
881 extern int commit PROTO ((int argc, char **argv));
882 extern int diff PROTO ((int argc, char **argv));
883 extern int history PROTO ((int argc, char **argv));
884 extern int import PROTO ((int argc, char **argv));
885 extern int cvslog PROTO ((int argc, char **argv));
886 #ifdef AUTH_CLIENT_SUPPORT
887 /* Some systems (namely Mac OS X) have conflicting definitions for these
888 * functions. Avoid them.
891 # define login cvs_login
892 #endif /* HAVE_LOGIN */
894 # define logout cvs_logout
895 #endif /* HAVE_LOGOUT */
896 extern int login PROTO((int argc, char **argv));
897 extern int logout PROTO((int argc, char **argv));
898 #endif /* AUTH_CLIENT_SUPPORT */
899 extern int patch PROTO((int argc, char **argv));
900 extern int release PROTO((int argc, char **argv));
901 extern int cvsremove PROTO((int argc, char **argv));
902 extern int rtag PROTO((int argc, char **argv));
903 extern int cvsstatus PROTO((int argc, char **argv));
904 extern int cvstag PROTO((int argc, char **argv));
905 extern int version PROTO((int argc, char **argv));
907 extern unsigned long int lookup_command_attribute PROTO((char *));
909 #if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
910 char *scramble PROTO ((char *str));
911 char *descramble PROTO ((char *str));
912 #endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */
914 #ifdef AUTH_CLIENT_SUPPORT
915 char *get_cvs_password PROTO((void));
916 int get_cvs_port_number PROTO((const cvsroot_t *root));
917 char *normalize_cvsroot PROTO((const cvsroot_t *root));
918 #endif /* AUTH_CLIENT_SUPPORT */
920 extern void tag_check_valid PROTO ((char *, int, char **, int, int, char *));
921 extern void tag_check_valid_join PROTO ((char *, int, char **, int, int,
926 /* From server.c and documented there. */
927 extern void cvs_output PROTO ((const char *, size_t));
928 extern void cvs_output_binary PROTO ((char *, size_t));
929 extern void cvs_outerr PROTO ((const char *, size_t));
930 extern void cvs_flusherr PROTO ((void));
931 extern void cvs_flushout PROTO ((void));
932 extern void cvs_output_tagged PROTO ((const char *, const char *));