]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/cvs/src/cvs.h
This commit was generated by cvs2svn to compensate for changes in r174206,
[FreeBSD/FreeBSD.git] / contrib / cvs / src / cvs.h
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$
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 /* Begin GNULIB headers.  */
45 #include "xsize.h"
46 /* End GNULIB headers.  */
47
48 #ifdef STDC_HEADERS
49 #include <stdlib.h>
50 #else
51 extern void exit ();
52 extern char *getenv();
53 #endif
54
55 #ifdef HAVE_UNISTD_H
56 #include <unistd.h>
57 #endif
58
59 #ifdef HAVE_STRING_H
60 #include <string.h>
61 #else
62 #include <strings.h>
63 #endif
64
65 #ifdef SERVER_SUPPORT
66 /* If the system doesn't provide strerror, it won't be declared in
67    string.h.  */
68 char *strerror ();
69 #endif
70
71 #ifdef HAVE_FNMATCH
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 */
76
77 #include <ctype.h>
78 #include <pwd.h>
79 #include <signal.h>
80
81 #ifdef HAVE_ERRNO_H
82 #include <errno.h>
83 #else
84 #ifndef errno
85 extern int errno;
86 #endif /* !errno */
87 #endif /* HAVE_ERRNO_H */
88
89 #include "system.h"
90
91 #include "hash.h"
92 #include "stack.h"
93
94 #include "root.h"
95
96 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
97 # include "client.h"
98 #endif
99
100 #ifdef MY_NDBM
101 #include "myndbm.h"
102 #else
103 #include <ndbm.h>
104 #endif /* MY_NDBM */
105
106 #include "regex.h"
107 #include "getopt.h"
108 #include "wait.h"
109
110 #include "rcs.h"
111
112
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.  */
117 #ifndef PATH_MAX
118 #ifdef MAXPATHLEN
119 #define PATH_MAX MAXPATHLEN+2
120 #else
121 #define PATH_MAX 1024+2
122 #endif
123 #endif /* PATH_MAX */
124
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.  */
127
128 #ifdef USE_VMS_FILENAMES
129 #define CVSADM          "CVS"
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 */
144 #define CVSADM          "CVS"
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 */
162
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.
168    
169    See fileattr.h for details about file attributes, the only thing stored
170    in CVSREP currently.  */
171 #define CVSREP "CVS"
172
173 /*
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.
178  */
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"
199
200 #define CVSNULLREPOS            "Emptydir"      /* an empty directory */
201
202 /* Other CVS file names */
203
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"
210
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"
219
220 /* Command attributes -- see function lookup_command_attribute(). */
221 #define CVS_CMD_IGNORE_ADMROOT        1
222
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
226    release).  */
227
228 #define CVS_CMD_USES_WORK_DIR         2
229
230 #define CVS_CMD_MODIFIES_REPOSITORY   4
231
232 /* miscellaneous CVS defines */
233
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
241
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 */
245
246 #ifdef USE_VMS_FILENAMES
247 #define BAKPREFIX       "_$"
248 #define DEVNULL         "NLA0:"
249 #else /* USE_VMS_FILENAMES */
250 #define BAKPREFIX       ".#"            /* when rcsmerge'ing */
251 #ifndef DEVNULL
252 #define DEVNULL         "/dev/null"
253 #endif
254 #endif /* USE_VMS_FILENAMES */
255
256 /*
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.
260  */
261 #define TAG_HEAD        "HEAD"
262 #define TAG_BASE        "BASE"
263
264 /* Environment variable used by CVS */
265 #define CVSREAD_ENV     "CVSREAD"       /* make files read-only */
266 #define CVSREAD_DFLT    0               /* writable files by default */
267
268 #define CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */
269
270 #define TMPDIR_ENV      "TMPDIR"        /* Temporary directory */
271
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 */
275
276 #define CVSROOT_ENV     "CVSROOT"       /* source directory root */
277 #define CVSROOT_DFLT    NULL            /* No dflt; must set for checkout */
278
279 #define IGNORE_ENV      "CVSIGNORE"     /* More files to ignore */
280 #define WRAPPER_ENV     "CVSWRAPPERS"   /* name of the wrapper file */
281
282 #define CVSUMASK_ENV    "CVSUMASK"      /* Effective umask for repository */
283
284 /*
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.
287  *
288  * If the CVSROOT environment variable is set, it overrides this define.
289  */
290 #define REPOS_STRIP     "/master/"
291
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
296
297 /* The type of an entnode.  */
298 enum ent_type
299 {
300     ENT_FILE, ENT_SUBDIR
301 };
302
303 /* structure of a entry record */
304 struct entnode
305 {
306     enum ent_type type;
307     char *user;
308     char *version;
309
310     /* Timestamp, or "" if none (never NULL).  */
311     char *timestamp;
312
313     /* Keyword expansion options, or "" if none (never NULL).  */
314     char *options;
315
316     char *tag;
317     char *date;
318     char *conflict;
319 };
320 typedef struct entnode Entnode;
321
322 /* The type of request that is being done in do_module() */
323 enum mtype
324 {
325     CHECKOUT, TAG, PATCH, EXPORT, MISC
326 };
327
328 /*
329  * structure used for list-private storage by Entries_Open() and
330  * Version_TS() and Find_Directories().
331  */
332 struct stickydirtag
333 {
334     /* These fields pass sticky tag information from Entries_Open() to
335        Version_TS().  */
336     int aflag;
337     char *tag;
338     char *date;
339     int nonbranch;
340
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.  */
344     int subdirs;
345 };
346
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 */
351
352 /* Flags for return values of direnter procs for the recursion processor */
353 enum direnter_type
354 {
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 */
359 };
360 #ifdef ENUMS_CAN_BE_TROUBLE
361 typedef int Dtype;
362 #else
363 typedef enum direnter_type Dtype;
364 #endif
365
366 /* Recursion processor lock types */
367 #define CVS_LOCK_NONE   0
368 #define CVS_LOCK_READ   1
369 #define CVS_LOCK_WRITE  2
370
371 extern const char *program_name, *program_path, *cvs_cmd_name;
372 extern char *Tmpdir, *Editor;
373 extern int cvsadmin_root;
374 extern char *CurDir;
375 extern int really_quiet, quiet;
376 extern int use_editor;
377 extern int cvswrite;
378 extern mode_t cvsumask;
379 extern char *RCS_citag;
380
381
382
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;
387
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;
392
393 extern char *emptydir_name PROTO ((void));
394 extern int safe_location PROTO ((char *));
395
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*/
401
402 extern int top_level_admin;
403
404
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;
409
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. */
414 #endif
415
416 extern char hostname[];
417
418 /* Externs that are included directly in the CVS sources */
419
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
429
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));
438
439
440 #include "error.h"
441
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 *));
450
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 *));
456
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));
460
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 *));
469
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));
475
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));
483
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 *));
488
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));
499 #ifdef HAVE_READLINK
500 char *xreadlink PROTO((const char *link));
501 #endif
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));
509
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));
515
516
517
518 /* This is the structure that the recursion processor passes to the
519    fileproc to tell it about a particular file.  */
520 struct file_info
521 {
522     /* Name of the file, without any directory component.  */
523     const char *file;
524
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;
531
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
534        messages.  */
535     const char *fullname;
536
537     /* Name of the directory corresponding to the repository which contains
538        this file.  */
539     const char *repository;
540
541     /* The pre-parsed entries for this directory.  */
542     List *entries;
543
544     RCSNode *rcs;
545 };
546
547
548
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.
554  */
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,
562                                 const char *date,
563                                 int nonbranch, int warn, int dotemplate));
564 extern int expand_at_signs PROTO ((const char *, off_t, FILE *));
565
566 /* Locking subsystem (implemented in lock.c).  */
567
568 int Reader_Lock PROTO((char *xrepository));
569 void Lock_Cleanup PROTO((void));
570
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,
574                                  int aflag));
575
576 /* See lock.c for description.  */
577 extern void lock_dir_for_write PROTO ((char *));
578
579 /* LockDir setting from CVSROOT/config.  */
580 extern char *lock_dir;
581
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[]));
594
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;
604
605 #include "update.h"
606
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));
621
622 #ifdef SERVER_SUPPORT
623 extern int cvs_casecmp PROTO ((const char *, const char *));
624 #endif
625
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,
632                         List **optentries));
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));
640
641 void do_verify PROTO((char **messagep, const char *repository));
642
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));
646
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,
651                                      List *entries));
652 typedef Dtype (*DIRENTPROC) PROTO ((void *callerdat, const char *dir,
653                                     const char *repos, const char *update_dir,
654                                     List *entries));
655 typedef int (*DIRLEAVEPROC) PROTO ((void *callerdat, const char *dir, int err,
656                                     const char *update_dir, List *entries));
657
658 extern int mkmodules PROTO ((char *dir));
659 extern int init PROTO ((int argc, char **argv));
660
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,
664                 char *extra_arg));
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,
669                      void *callerdat,
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));
677
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));
688
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 */
697
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,
702                     int flags));
703
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));
708
709 pid_t waitpid PROTO((pid_t, int *, int));
710 \f
711 /*
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.
714  *
715  * this is usually obtained from a call to Version_TS which takes a
716  * tag argument for the RCS file if desired
717  */
718 struct vers_ts
719 {
720     /* rcs version user file derives from, from CVS/Entries.
721        It can have the following special values:
722
723        NULL = file is not mentioned in Entries (this is also used for a
724               directory).
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
728             Entries file.
729        0 = user file is new
730        -vers = user file to be removed.  */
731     char *vn_user;
732
733     /* Numeric revision number corresponding to ->vn_tag (->vn_tag
734        will often be symbolic).  */
735     char *vn_rcs;
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
739        ->vn_rcs.  */
740     char *vn_tag;
741
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
745        contents.  */
746     char *ts_user;
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.  */
751     char *ts_rcs;
752
753     /* Options from CVS/Entries (keyword expansion), malloc'd.  If none,
754        then it is an empty string (never NULL).  */
755     char *options;
756
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.  */
761     char *ts_conflict;
762
763     /* Tag specified on the command line, or if none, tag stored in
764        CVS/Entries.  */
765     char *tag;
766     /* Date specified on the command line, or if none, date stored in
767        CVS/Entries.  */
768     char *date;
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.  */
771     int nonbranch;
772
773     /* Pointer to entries file node  */
774     Entnode *entdata;
775
776     /* Pointer to parsed src file info */
777     RCSNode *srcfile;
778 };
779 typedef struct vers_ts Vers_TS;
780
781 Vers_TS *Version_TS PROTO ((struct file_info *finfo, char *options, char *tag,
782                             char *date, int force_tag_match,
783                             int set_time));
784 void freevers_ts PROTO ((Vers_TS ** versp));
785 \f
786 /* Miscellaneous CVS infrastructure which layers on top of the recursion
787    processor (for example, needs struct file_info).  */
788
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));
795
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 *));
800
801 /*
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.
805  */
806 enum classify_type
807 {
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           */
819 };
820 typedef enum classify_type Ctype;
821
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));
825
826 /*
827  * structure used for list nodes passed to Update_Logfile() and
828  * do_editor().
829  */
830 struct logfile_info
831 {
832   enum classify_type type;
833   char *tag;
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 */
838 };
839 \f
840 /* Wrappers.  */
841
842 typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
843 typedef enum {
844     /* -t and -f wrapper options.  Treating directories as single files.  */
845     WRAP_TOCVS,
846     WRAP_FROMCVS,
847     /* -k wrapper option.  Default keyword expansion options.  */
848     WRAP_RCSOPTION
849 } WrapMergeHas;
850
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 */
863
864 /* Pathname expansion */
865 char *expand_path PROTO((const char *name, const char *file, int line));
866
867 /* User variables.  */
868 extern List *variable_list;
869
870 extern void variable_set PROTO ((char *nameval));
871
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.
889  */
890 #ifdef HAVE_LOGIN
891 # define login          cvs_login
892 #endif /* HAVE_LOGIN */
893 #ifdef HAVE_LOGOUT
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));
906 \f
907 extern unsigned long int lookup_command_attribute PROTO((char *));
908 \f
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 */
913
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 */
919
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,
922                                          char *));
923 \f
924 #include "server.h"
925
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 *));