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
16 # include <config.h> /* this is stuff found via autoconf */
19 /* Add GNU attribute suppport. */
21 /* This feature is available in gcc versions 2.5 and later. */
22 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
23 # define __attribute__(Spec) /* empty */
25 # if __GNUC__ == 2 && __GNUC_MINOR__ < 96
26 # define __pure__ /* empty */
29 # define __malloc__ /* empty */
32 /* The __-protected variants of `format' and `printf' attributes
33 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
34 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
35 # define __const__ const
36 # define __format__ format
37 # define __noreturn__ noreturn
38 # define __printf__ printf
40 #endif /* __attribute__ */
42 /* begin GNULIB headers */
44 #include "vasnprintf.h"
47 /* end GNULIB headers */
51 #endif /* ! STDC_HEADERS */
53 /* Under OS/2, <stdio.h> doesn't define popen()/pclose(). */
59 /* If the system doesn't provide strerror, it won't be declared in
71 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
89 /* Note that the _ONLY_ reason for PATH_MAX is if various system calls (getwd,
90 * getcwd, readlink) require/want us to use it. All other parts of CVS
91 * allocate pathname buffers dynamically, and we want to keep it that way.
97 /* Definitions for the CVS Administrative directory and the files it contains.
98 Here as #define's to make changing the names a simple task. */
100 #ifdef USE_VMS_FILENAMES
102 #define CVSADM_ENT "CVS/Entries."
103 #define CVSADM_ENTBAK "CVS/Entries.Backup"
104 #define CVSADM_ENTLOG "CVS/Entries.Log"
105 #define CVSADM_ENTSTAT "CVS/Entries.Static"
106 #define CVSADM_REP "CVS/Repository."
107 #define CVSADM_ROOT "CVS/Root."
108 #define CVSADM_TAG "CVS/Tag."
109 #define CVSADM_NOTIFY "CVS/Notify."
110 #define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
111 #define CVSADM_BASE "CVS/Base"
112 #define CVSADM_BASEREV "CVS/Baserev."
113 #define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
114 #define CVSADM_TEMPLATE "CVS/Template."
115 #else /* USE_VMS_FILENAMES */
117 #define CVSADM_ENT "CVS/Entries"
118 #define CVSADM_ENTBAK "CVS/Entries.Backup"
119 #define CVSADM_ENTLOG "CVS/Entries.Log"
120 #define CVSADM_ENTSTAT "CVS/Entries.Static"
121 #define CVSADM_REP "CVS/Repository"
122 #define CVSADM_ROOT "CVS/Root"
123 #define CVSADM_TAG "CVS/Tag"
124 #define CVSADM_NOTIFY "CVS/Notify"
125 #define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
126 /* A directory in which we store base versions of files we currently are
127 editing with "cvs edit". */
128 #define CVSADM_BASE "CVS/Base"
129 #define CVSADM_BASEREV "CVS/Baserev"
130 #define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
131 /* File which contains the template for use in log messages. */
132 #define CVSADM_TEMPLATE "CVS/Template"
133 #endif /* USE_VMS_FILENAMES */
135 /* This is the special directory which we use to store various extra
136 per-directory information in the repository. It must be the same as
137 CVSADM to avoid creating a new reserved directory name which users cannot
138 use, but is a separate #define because if anyone changes it (which I don't
139 recommend), one needs to deal with old, unconverted, repositories.
141 See fileattr.h for details about file attributes, the only thing stored
142 in CVSREP currently. */
146 * Definitions for the CVSROOT Administrative directory and the files it
147 * contains. This directory is created as a sub-directory of the $CVSROOT
148 * environment variable, and holds global administration information for the
149 * entire source repository beginning at $CVSROOT.
151 #define CVSROOTADM "CVSROOT"
152 #define CVSROOTADM_MODULES "modules"
153 #define CVSROOTADM_LOGINFO "loginfo"
154 #define CVSROOTADM_RCSINFO "rcsinfo"
155 #define CVSROOTADM_COMMITINFO "commitinfo"
156 #define CVSROOTADM_TAGINFO "taginfo"
157 #define CVSROOTADM_VERIFYMSG "verifymsg"
158 #define CVSROOTADM_HISTORY "history"
159 #define CVSROOTADM_VALTAGS "val-tags"
160 #define CVSROOTADM_IGNORE "cvsignore"
161 #define CVSROOTADM_CHECKOUTLIST "checkoutlist"
162 #define CVSROOTADM_WRAPPER "cvswrappers"
163 #define CVSROOTADM_NOTIFY "notify"
164 #define CVSROOTADM_USERS "users"
165 #define CVSROOTADM_READERS "readers"
166 #define CVSROOTADM_WRITERS "writers"
167 #define CVSROOTADM_PASSWD "passwd"
168 #define CVSROOTADM_CONFIG "config"
170 #define CVSNULLREPOS "Emptydir" /* an empty directory */
172 /* Other CVS file names */
174 /* Files go in the attic if the head main branch revision is dead,
175 otherwise they go in the regular repository directories. The whole
176 concept of having an attic is sort of a relic from before death
177 support but on the other hand, it probably does help the speed of
178 some operations (such as main branch checkouts and updates). */
179 #define CVSATTIC "Attic"
181 #define CVSLCK "#cvs.lock"
182 #define CVSRFL "#cvs.rfl"
183 #define CVSPFL "#cvs.pfl"
184 #define CVSWFL "#cvs.wfl"
185 #define CVSPFLPAT "#cvs.pfl.*" /* wildcard expr to match plocks */
186 #define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */
187 #define CVSEXT_LOG ",t"
188 #define CVSPREFIX ",,"
189 #define CVSDOTIGNORE ".cvsignore"
190 #define CVSDOTWRAPPER ".cvswrappers"
192 /* Command attributes -- see function lookup_command_attribute(). */
193 #define CVS_CMD_IGNORE_ADMROOT 1
195 /* Set if CVS needs to create a CVS/Root file upon completion of this
196 command. The name may be slightly confusing, because the flag
197 isn't really as general purpose as it seems (it is not set for cvs
200 #define CVS_CMD_USES_WORK_DIR 2
202 #define CVS_CMD_MODIFIES_REPOSITORY 4
204 /* miscellaneous CVS defines */
206 /* This is the string which is at the start of the non-log-message lines
207 that we put up for the user when they edit the log message. */
208 #define CVSEDITPREFIX "CVS: "
209 /* Number of characters in CVSEDITPREFIX to compare when deciding to strip
210 off those lines. We don't check for the space, to accomodate users who
211 have editors which strip trailing spaces. */
212 #define CVSEDITPREFIXLEN 4
214 #define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
215 #define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
216 #define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
218 #ifdef USE_VMS_FILENAMES
219 #define BAKPREFIX "_$"
220 #define DEVNULL "NLA0:"
221 #else /* USE_VMS_FILENAMES */
222 #define BAKPREFIX ".#" /* when rcsmerge'ing */
224 #define DEVNULL "/dev/null"
226 #endif /* USE_VMS_FILENAMES */
229 * Special tags. -rHEAD refers to the head of an RCS file, regardless of any
230 * sticky tags. -rBASE refers to the current revision the user has checked
231 * out This mimics the behaviour of RCS.
233 #define TAG_HEAD "HEAD"
234 #define TAG_BASE "BASE"
236 /* Environment variable used by CVS */
237 #define CVSREAD_ENV "CVSREAD" /* make files read-only */
238 #define CVSREAD_DFLT 0 /* writable files by default */
240 #define CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */
242 #define TMPDIR_ENV "TMPDIR" /* Temporary directory */
243 #define CVS_PID_ENV "CVS_PID" /* pid of running cvs */
245 #define EDITOR1_ENV "CVSEDITOR" /* which editor to use */
246 #define EDITOR2_ENV "VISUAL" /* which editor to use */
247 #define EDITOR3_ENV "EDITOR" /* which editor to use */
249 #define CVSROOT_ENV "CVSROOT" /* source directory root */
250 #define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
252 #define IGNORE_ENV "CVSIGNORE" /* More files to ignore */
253 #define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */
255 #define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */
258 * If the beginning of the Repository matches the following string, strip it
259 * so that the output to the logfile does not contain a full pathname.
261 * If the CVSROOT environment variable is set, it overrides this define.
263 #define REPOS_STRIP "/master/"
265 /* Large enough to hold DATEFORM. Not an arbitrary limit as long as
266 it is used for that purpose, and not to hold a string from the
267 command line, the client, etc. */
268 #define MAXDATELEN 50
270 /* The type of an entnode. */
276 /* structure of a entry record */
283 /* Timestamp, or "" if none (never NULL). */
286 /* Keyword expansion options, or "" if none (never NULL). */
293 typedef struct entnode Entnode;
295 /* The type of request that is being done in do_module() */
298 CHECKOUT, TAG, PATCH, EXPORT, MISC
302 * structure used for list-private storage by Entries_Open() and
303 * Version_TS() and Find_Directories().
307 /* These fields pass sticky tag information from Entries_Open() to
314 /* This field is set by Entries_Open() if there was subdirectory
315 information; Find_Directories() uses it to see whether it needs
316 to scan the directory itself. */
320 /* Flags for find_{names,dirs} routines */
321 #define W_LOCAL 0x01 /* look for files locally */
322 #define W_REPOS 0x02 /* look for files in the repository */
323 #define W_ATTIC 0x04 /* look for files in the attic */
325 /* Flags for return values of direnter procs for the recursion processor */
328 R_PROCESS = 1, /* process files and maybe dirs */
329 R_SKIP_FILES, /* don't process files in this dir */
330 R_SKIP_DIRS, /* don't process sub-dirs */
331 R_SKIP_ALL /* don't process files or dirs */
333 #ifdef ENUMS_CAN_BE_TROUBLE
336 typedef enum direnter_type Dtype;
339 /* Recursion processor lock types */
340 #define CVS_LOCK_NONE 0
341 #define CVS_LOCK_READ 1
342 #define CVS_LOCK_WRITE 2
344 /* Option flags for Parse_Info() */
345 #define PIOPT_ALL 1 /* accept "all" keyword */
347 extern const char *program_name, *program_path, *cvs_cmd_name;
348 extern char *Tmpdir, *Editor;
349 extern int cvsadmin_root;
351 extern int really_quiet, quiet;
352 extern int use_editor;
354 extern mode_t cvsumask;
358 /* This global variable holds the global -d option. It is NULL if -d
359 was not used, which means that we must get the CVSroot information
360 from the CVSROOT environment variable or from a CVS/Root file. */
361 extern char *CVSroot_cmdline;
363 /* These variables keep track of all of the CVSROOT directories that
364 have been seen by the client and the current one of those selected. */
365 extern List *root_directories;
366 extern cvsroot_t *current_parsed_root;
368 char *emptydir_name (void);
369 int safe_location (char *);
371 extern int trace; /* Show all commands */
372 extern int noexec; /* Don't modify disk anywhere */
373 extern int readonlyfs; /* fail on all write locks; succeed all read locks */
374 extern int logoff; /* Don't write history entry */
376 extern int top_level_admin;
377 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
378 extern int UseNewInfoFmtStrings;
379 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
382 #define LOGMSG_REREAD_NEVER 0 /* do_verify - never reread message */
383 #define LOGMSG_REREAD_ALWAYS 1 /* do_verify - always reread message */
384 #define LOGMSG_REREAD_STAT 2 /* do_verify - reread message if changed */
385 extern int RereadLogAfterVerify;
387 #ifdef CLIENT_SUPPORT
388 extern List *dirs_sent_to_server; /* used to decide which "Argument
389 xxx" commands to send to each
390 server in multiroot mode. */
393 extern char hostname[];
395 /* Externs that are included directly in the CVS sources */
397 int RCS_merge (RCSNode *, const char *, const char *, const char *,
398 const char *, const char *);
399 /* Flags used by RCS_* functions. See the description of the individual
400 functions for which flags mean what for each function. */
401 #define RCS_FLAGS_FORCE 1
402 #define RCS_FLAGS_DEAD 2
403 #define RCS_FLAGS_QUIET 4
404 #define RCS_FLAGS_MODTIME 8
405 #define RCS_FLAGS_KEEPFILE 16
407 int RCS_exec_rcsdiff (RCSNode *rcsfile,
408 const char *opts, const char *options,
409 const char *rev1, const char *rev1_cache,
411 const char *label1, const char *label2,
412 const char *workfile);
413 int diff_exec (const char *file1, const char *file2,
414 const char *label1, const char *label2,
415 const char *options, const char *out);
420 DBM *open_module (void);
421 FILE *open_file (const char *, const char *);
422 List *Find_Directories (char *repository, int which, List *entries);
423 void Entries_Close (List *entries);
424 List *Entries_Open (int aflag, char *update_dir);
425 void Subdirs_Known (List *entries);
426 void Subdir_Register (List *, const char *, const char *);
427 void Subdir_Deregister (List *, const char *, const char *);
429 char *Make_Date (char *rawdate);
430 char *date_from_time_t (time_t);
431 void date_to_internet (char *, const char *);
432 void date_to_tm (struct tm *, const char *);
433 void tm_to_internet (char *, const struct tm *);
434 char *gmformat_time_t (time_t unixtime);
435 char *format_date_alloc (char *text);
437 char *Name_Repository (const char *dir, const char *update_dir);
438 const char *Short_Repository (const char *repository);
439 void Sanitize_Repository_Name (char *repository);
441 char *Name_Root (char *dir, char *update_dir);
442 void free_cvsroot_t (cvsroot_t *root_in);
443 cvsroot_t *parse_cvsroot (const char *root)
444 __attribute__ ((__malloc__));
445 cvsroot_t *local_cvsroot (const char *dir)
446 __attribute__ ((__malloc__));
447 void Create_Root (const char *dir, const char *rootdir);
448 void root_allow_add (char *);
449 void root_allow_free (void);
450 int root_allow_ok (char *);
452 char *previous_rev (RCSNode *rcs, const char *rev);
453 char *gca (const char *rev1, const char *rev2);
454 void check_numeric (const char *, int, char **);
455 char *getcaller (void);
456 char *entries_time (time_t unixtime);
457 time_t unix_time_stamp (const char *file);
458 char *time_stamp (const char *file);
460 void *xmalloc (size_t bytes)
461 __attribute__((__malloc__));
462 void *xrealloc (void *ptr, size_t bytes)
463 __attribute__ ((__malloc__));
464 void expand_string (char **, size_t *, size_t);
465 void xrealloc_and_strcat (char **, size_t *, const char *);
466 char *xstrdup (const char *str)
467 __attribute__ ((__malloc__));
468 int strip_trailing_newlines (char *str);
469 int pathname_levels (const char *path);
471 typedef int (*CALLPROC) (const char *repository, const char *value,
473 int Parse_Info (const char *infofile, const char *repository,
474 CALLPROC callproc, int opt, void *closure);
475 int parse_config (char *);
477 typedef RETSIGTYPE (*SIGCLEANUPPROC) ();
478 int SIG_register (int sig, SIGCLEANUPPROC sigcleanup);
479 int isdir (const char *file);
480 int isfile (const char *file);
481 int islink (const char *file);
482 int isdevice (const char *file);
483 int isreadable (const char *file);
484 int iswritable (const char *file);
485 int isaccessible (const char *file, const int mode);
486 int isabsolute (const char *filename);
488 char *xreadlink (const char *link);
489 #endif /* HAVE_READLINK */
490 char *xresolvepath (const char *path);
491 const char *last_component (const char *path);
492 char *get_homedir (void);
493 char *strcat_filename_onto_homedir (const char *, const char *);
494 char *cvs_temp_name (void);
495 FILE *cvs_temp_file (char **filename);
497 int numdots (const char *s);
498 char *increment_revnum (const char *);
499 int compare_revnums (const char *, const char *);
500 int ls (int argc, char *argv[]);
501 int unlink_file (const char *f);
502 int unlink_file_dir (const char *f);
504 /* This is the structure that the recursion processor passes to the
505 fileproc to tell it about a particular file. */
508 /* Name of the file, without any directory component. */
511 /* Name of the directory we are in, relative to the directory in
512 which this command was issued. We have cd'd to this directory
513 (either in the working directory or in the repository, depending
514 on which sort of recursion we are doing). If we are in the directory
515 in which the command was issued, this is "". */
516 const char *update_dir;
518 /* update_dir and file put together, with a slash between them as
519 necessary. This is the proper way to refer to the file in user
521 const char *fullname;
523 /* Name of the directory corresponding to the repository which contains
525 const char *repository;
527 /* The pre-parsed entries for this directory. */
533 int update (int argc, char *argv[]);
534 /* The only place this is currently used outside of update.c is add.c.
535 * Restricting its use to update.c seems to be in the best interest of
536 * modularity, but I can't think of a good way to get an update of a
537 * resurrected file done and print the fact otherwise.
539 void write_letter (struct file_info *finfo, int letter);
540 int xcmp (const char *file1, const char *file2);
542 void *valloc (size_t bytes);
544 /* Need this until we back out the get_date () proto again and use a current
545 * version of getdate.y from GNULIB.
548 time_t get_date (char *date, struct timeb *now);
550 int Create_Admin (const char *dir, const char *update_dir,
551 const char *repository, const char *tag, const char *date,
552 int nonbranch, int warn, int dotemplate);
553 int expand_at_signs (const char *, off_t, FILE *);
555 /* Locking subsystem (implemented in lock.c). */
557 int Reader_Lock (char *xrepository);
558 void Simple_Lock_Cleanup (void);
559 void Lock_Cleanup (void);
561 /* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL,
562 and AFLAG, anyway. */
563 void lock_tree_promotably (int argc, char **argv, int local, int which,
566 /* See lock.c for description. */
567 void lock_dir_for_write (const char *);
569 /* LockDir setting from CVSROOT/config. */
570 extern char *lock_dir;
572 /* AllowedAdminOptions setting from CVSROOT/config. */
573 extern char *UserAdminOptions;
575 void Scratch_Entry (List * list, const char *fname);
576 void ParseTag (char **tagp, char **datep, int *nonbranchp);
577 void WriteTag (const char *dir, const char *tag, const char *date,
578 int nonbranch, const char *update_dir, const char *repository);
579 void WriteTemplate (const char *update_dir, int dotemplate,
580 const char *repository);
581 void cat_module (int status);
582 void check_entries (char *dir);
583 void close_module (DBM * db);
584 void copy_file (const char *from, const char *to);
585 void fperrmsg (FILE * fp, int status, int errnum, char *message,...);
586 void free_names (int *pargc, char *argv[]);
588 int ign_name (char *name);
589 void ign_add (char *ign, int hold);
590 void ign_add_file (char *file, int hold);
591 void ign_setup (void);
592 void ign_dir_add (char *name);
593 int ignore_directory (const char *name);
594 typedef void (*Ignore_proc) (const char *, const char *);
595 void ignore_files (List *, List *, const char *, Ignore_proc);
596 extern int ign_inhibit_server;
600 void line2argv (int *pargc, char ***argv, char *line, char *sepchars);
601 void make_directories (const char *name);
602 void make_directory (const char *name);
603 int mkdir_if_needed (const char *name);
604 void rename_file (const char *from, const char *to);
605 /* Expand wildcards in each element of (ARGC,ARGV). This is according to the
606 files which exist in the current directory, and accordingly to OS-specific
607 conventions regarding wildcard syntax. It might be desirable to change the
608 former in the future (e.g. "cvs status *.h" including files which don't exist
609 in the working directory). The result is placed in *PARGC and *PARGV;
610 the *PARGV array itself and all the strings it contains are newly
611 malloc'd. It is OK to call it with PARGC == &ARGC or PARGV == &ARGV. */
612 void expand_wild (int argc, char **argv,
613 int *pargc, char ***pargv);
615 #ifdef SERVER_SUPPORT
616 int cvs_casecmp (const char *, const char *);
620 void signals_register (RETSIGTYPE (*handler)(int));
621 void cleanup_register (void (*handler) (void));
623 void strip_trailing_slashes (char *path);
624 void update_delproc (Node * p);
625 void usage (const char *const *cpp);
626 void xchmod (const char *fname, int writable);
628 List *Find_Names (char *repository, int which, int aflag,
630 void Register (List * list, const char *fname, const char *vn, const char *ts,
631 const char *options, const char *tag, const char *date,
632 const char *ts_conflict);
633 void Update_Logfile (const char *repository, const char *xmessage,
634 FILE * xlogfp, List * xchanges);
635 void do_editor (const char *dir, char **messagep,
636 const char *repository, List * changes);
638 void do_verify (char **messagep, const char *repository);
640 typedef int (*CALLBACKPROC) (int argc, char *argv[], char *where,
641 char *mwhere, char *mfile, int shorten, int local_specified,
642 char *omodule, char *msg);
645 typedef int (*FILEPROC) (void *callerdat, struct file_info *finfo);
646 typedef int (*FILESDONEPROC) (void *callerdat, int err,
647 const char *repository, const char *update_dir,
649 typedef Dtype (*DIRENTPROC) (void *callerdat, const char *dir,
650 const char *repos, const char *update_dir,
652 typedef int (*DIRLEAVEPROC) (void *callerdat, const char *dir, int err,
653 const char *update_dir, List *entries);
655 int mkmodules (char *dir);
656 int init (int argc, char **argv);
658 int do_module (DBM * db, char *mname, enum mtype m_type, char *msg,
659 CALLBACKPROC callback_proc, char *where, int shorten,
660 int local_specified, int run_module_prog, int build_dirs,
662 void history_write (int type, const char *update_dir, const char *revs,
663 const char *name, const char *repository);
664 int start_recursion (FILEPROC fileproc, FILESDONEPROC filesdoneproc,
665 DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
667 int argc, char *argv[], int local, int which,
668 int aflag, int locktype, char *update_preload,
669 int dosrcs, char *repository);
670 void SIG_beginCrSect (void);
671 void SIG_endCrSect (void);
672 int SIG_inCrSect (void);
673 void read_cvsrc (int *argc, char ***argv, const char *cmdname);
675 char *make_message_rcsvalid (const char *message);
676 int file_has_conflict (const struct file_info *,
677 const char *ts_conflict);
678 int file_has_markers (const struct file_info *);
679 void get_file (const char *, const char *, const char *,
680 char **, size_t *, size_t *);
681 char *shell_escape (char *buf, const char *str);
682 char *backup_file (const char *file, const char *suffix);
683 void resolve_symlink (char **filename);
684 void sleep_past (time_t desttime);
686 /* flags for run_exec(), the fast system() for CVS */
687 #define RUN_NORMAL 0x0000 /* no special behaviour */
688 #define RUN_COMBINED 0x0001 /* stdout is duped to stderr */
689 #define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */
690 #define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */
691 #define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */
692 #define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */
693 #define RUN_TTY (char *)0 /* for the benefit of lint */
695 void run_arg (const char *s);
696 void run_print (FILE * fp);
697 void run_setup (const char *prog);
698 int run_exec (const char *stin, const char *stout, const char *sterr,
700 /* for format_cmdline function - when a list variable is bound to a user string,
701 * we need to pass some data through walklist into the callback function.
702 * We use this struct.
704 struct format_cmdline_walklist_closure
706 const char *format; /* the format string the user passed us */
707 char **buf; /* *dest = our NUL terminated and possibly too short
710 size_t *length; /* *dlen = how many bytes have already been allocated to
713 char **d; /* our pointer into buf where the next char should go */
714 char quotes; /* quotes we are currently between, if any */
715 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
719 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
720 void *closure; /* our user defined closure */
722 char *cmdlinequote (char quotes, char *s);
723 char *cmdlineescape (char quotes, char *s);
724 #ifdef SUPPORT_OLD_INFO_FMT_STRINGS
725 char *format_cmdline (int oldway, const char *srepos, const char *format, ...);
726 #else /* SUPPORT_OLD_INFO_FMT_STRINGS */
727 char *format_cmdline (const char *format, ...);
728 #endif /* SUPPORT_OLD_INFO_FMT_STRINGS */
730 /* other similar-minded stuff from run.c. */
731 FILE *run_popen (const char *, const char *);
732 int piped_child (char *const *, int *, int *);
733 void close_on_exec (int);
735 pid_t waitpid (pid_t, int *, int);
738 * a struct vers_ts contains all the information about a file including the
739 * user and rcs file names, and the version checked out and the head.
741 * this is usually obtained from a call to Version_TS which takes a
742 * tag argument for the RCS file if desired
746 /* rcs version user file derives from, from CVS/Entries.
747 It can have the following special values:
749 NULL = file is not mentioned in Entries (this is also used for a
751 "" = INVALID! The comment used to say that it meant "no user file"
752 but as far as I know CVS didn't actually use it that way.
753 Note that according to cvs.texinfo, "" is not valid in the
756 -vers = user file to be removed. */
759 /* Numeric revision number corresponding to ->vn_tag (->vn_tag
760 will often be symbolic). */
762 /* If ->tag is a simple tag in the RCS file--a tag which really
763 exists which is not a magic revision--and if ->date is NULL,
764 then this is a copy of ->tag. Otherwise, it is a copy of
768 /* This is the timestamp from stating the file in the working directory.
769 It is NULL if there is no file in the working directory. It is
770 "Is-modified" if we know the file is modified but don't have its
773 /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
774 are computed in a slightly different way, but the fact remains that
775 if they are equal the file in the working directory is unmodified
776 and if they differ it is modified. */
779 /* Options from CVS/Entries (keyword expansion), malloc'd. If none,
780 then it is an empty string (never NULL). */
783 /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
784 and the time stamp in this field is the time stamp of the working
785 directory file which was created with the conflict markers in it.
786 This is from CVS/Entries. */
789 /* Tag specified on the command line, or if none, tag stored in
792 /* Date specified on the command line, or if none, date stored in
795 /* If this is 1, then tag is not a branch tag. If this is 0, then
796 tag may or may not be a branch tag. */
799 /* Pointer to entries file node */
802 /* Pointer to parsed src file info */
805 typedef struct vers_ts Vers_TS;
807 Vers_TS *Version_TS (struct file_info *finfo, char *options, char *tag,
808 char *date, int force_tag_match,
810 void freevers_ts (Vers_TS ** versp);
812 /* Miscellaneous CVS infrastructure which layers on top of the recursion
813 processor (for example, needs struct file_info). */
815 int Checkin (int type, struct file_info *finfo, char *rev,
816 char *tag, char *options, char *message);
817 int No_Difference (struct file_info *finfo, Vers_TS *vers);
818 /* TODO: can the finfo argument to special_file_mismatch be changed? -twp */
819 int special_file_mismatch (struct file_info *finfo,
820 char *rev1, char *rev2);
822 /* CVSADM_BASEREV stuff, from entries.c. */
823 char *base_get (struct file_info *);
824 void base_register (struct file_info *, char *);
825 void base_deregister (struct file_info *);
828 * defines for Classify_File() to determine the current state of a file.
829 * These are also used as types in the data field for the list we make for
830 * Update_Logfile in commit, import, and add.
834 T_UNKNOWN = 1, /* no old-style analog existed */
835 T_CONFLICT, /* C (conflict) list */
836 T_NEEDS_MERGE, /* G (needs merging) list */
837 T_MODIFIED, /* M (needs checked in) list */
838 T_CHECKOUT, /* O (needs checkout) list */
839 T_ADDED, /* A (added file) list */
840 T_REMOVED, /* R (removed file) list */
841 T_REMOVE_ENTRY, /* W (removed entry) list */
842 T_UPTODATE, /* File is up-to-date */
843 T_PATCH, /* P Like C, but can patch */
844 T_TITLE /* title for node type */
846 typedef enum classify_type Ctype;
848 Ctype Classify_File (struct file_info *finfo, char *tag, char *date, char *options,
849 int force_tag_match, int aflag, Vers_TS **versp, int pipeout);
852 * structure used for list nodes passed to Update_Logfile() and
857 enum classify_type type;
859 char *rev_old; /* rev number before a commit/modify,
860 NULL for add or import */
861 char *rev_new; /* rev number after a commit/modify,
862 add, or import, NULL for remove */
867 typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
869 /* -t and -f wrapper options. Treating directories as single files. */
872 /* -k wrapper option. Default keyword expansion options. */
876 void wrap_setup (void);
877 int wrap_name_has (const char *name,WrapMergeHas has);
878 char *wrap_rcsoption (const char *fileName, int asFlag);
879 char *wrap_tocvs_process_file (const char *fileName);
880 int wrap_merge_is_copy (const char *fileName);
881 void wrap_fromcvs_process_file (const char *fileName);
882 void wrap_add_file (const char *file,int temp);
883 void wrap_add (char *line,int temp);
884 void wrap_send (void);
885 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
886 void wrap_unparse_rcs_options (char **, int);
887 #endif /* SERVER_SUPPORT || CLIENT_SUPPORT */
889 /* Pathname expansion */
890 char *expand_path (const char *name, const char *file, int line,
893 /* User variables. */
894 extern List *variable_list;
896 void variable_set (char *nameval);
898 int watch (int argc, char **argv);
899 int edit (int argc, char **argv);
900 int unedit (int argc, char **argv);
901 int editors (int argc, char **argv);
902 int watchers (int argc, char **argv);
903 int annotate (int argc, char **argv);
904 int add (int argc, char **argv);
905 int admin (int argc, char **argv);
906 int checkout (int argc, char **argv);
907 int commit (int argc, char **argv);
908 int diff (int argc, char **argv);
909 int history (int argc, char **argv);
910 int import (int argc, char **argv);
911 int cvslog (int argc, char **argv);
912 #ifdef AUTH_CLIENT_SUPPORT
913 /* Some systems (namely Mac OS X) have conflicting definitions for these
914 * functions. Avoid them.
917 # define login cvs_login
918 #endif /* HAVE_LOGIN */
920 # define logout cvs_logout
921 #endif /* HAVE_LOGOUT */
922 int login (int argc, char **argv);
923 int logout (int argc, char **argv);
924 #endif /* AUTH_CLIENT_SUPPORT */
925 int patch (int argc, char **argv);
926 int release (int argc, char **argv);
927 int cvsremove (int argc, char **argv);
928 int rtag (int argc, char **argv);
929 int cvsstatus (int argc, char **argv);
930 int cvstag (int argc, char **argv);
931 int version (int argc, char **argv);
933 unsigned long int lookup_command_attribute (char *);
935 #if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
936 char *scramble (char *str);
937 char *descramble (char *str);
938 #endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */
940 #ifdef AUTH_CLIENT_SUPPORT
941 char *get_cvs_password (void);
942 /* get_cvs_port_number() is not pure since the /etc/services file could change
944 int get_cvs_port_number (const cvsroot_t *root);
945 /* normalize_cvsroot() is not pure since it calls get_cvs_port_number. */
946 char *normalize_cvsroot (const cvsroot_t *root)
947 __attribute__ ((__malloc__));
948 #endif /* AUTH_CLIENT_SUPPORT */
950 void tag_check_valid (char *, int, char **, int, int, char *);
951 void tag_check_valid_join (char *, int, char **, int, int,
956 /* From server.c and documented there. */
957 void cvs_output (const char *, size_t);
958 void cvs_output_binary (char *, size_t);
959 void cvs_outerr (const char *, size_t);
960 void cvs_flusherr (void);
961 void cvs_flushout (void);
962 void cvs_output_tagged (const char *, const char *);
964 /* The trace function from subr.c */
965 void cvs_trace (int level, const char *fmt, ...)
966 __attribute__ ((__format__ (__printf__, 2, 3)));
967 #define TRACE cvs_trace
970 * TRACE_FUNCTION Trace function calls, often including function
971 * arguments. This is the trace level that, historically,
972 * applied to all trace calls.
973 * TRACE_FLOW Include the flow control functions, such as
974 * start_recursion, do_recursion, and walklist in the
976 * TRACE_DATA Trace important internal function data.
978 #define TRACE_FUNCTION 1