1 /* 2 * Copyright (C) 1986-2005 The Free Software Foundation, Inc. 3 * 4 * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, 5 * and others. 6 * 7 * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk 8 * Portions Copyright (C) 1989-1992, Brian Berliner 9 * 10 * You may distribute under the terms of the GNU General Public License as 11 * specified in the README file that comes with the CVS kit. 12 */ 13 14 /* 15 * basic information used in all source files 16 * 17 */ 18 19 20 #ifdef HAVE_CONFIG_H 21 # include <config.h> /* this is stuff found via autoconf */ 22 #endif /* CONFIG_H */ 23 24 /* Add GNU attribute suppport. */ 25 #ifndef __attribute__ 26 /* This feature is available in gcc versions 2.5 and later. */ 27 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ 28 # define __attribute__(Spec) /* empty */ 29 # else 30 # if __GNUC__ == 2 && __GNUC_MINOR__ < 96 31 # define __pure__ /* empty */ 32 # endif 33 # if __GNUC__ < 3 34 # define __malloc__ /* empty */ 35 # endif 36 # endif 37 /* The __-protected variants of `format' and `printf' attributes 38 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ 39 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 40 # define __const__ const 41 # define __format__ format 42 # define __noreturn__ noreturn 43 # define __printf__ printf 44 # endif 45 #endif /* __attribute__ */ 46 47 /* Some GNULIB headers require that we include system headers first. */ 48 #include "system.h" 49 50 /* begin GNULIB headers */ 51 #include "dirname.h" 52 #include "exit.h" 53 #include "getdate.h" 54 #include "minmax.h" 55 #include "regex.h" 56 #include "strcase.h" 57 #include "stat-macros.h" 58 #include "timespec.h" 59 #include "unlocked-io.h" 60 #include "xalloc.h" 61 #include "xgetcwd.h" 62 #include "xreadlink.h" 63 #include "xsize.h" 64 /* end GNULIB headers */ 65 66 #if ! STDC_HEADERS 67 char *getenv(); 68 #endif /* ! STDC_HEADERS */ 69 70 /* Under OS/2, <stdio.h> doesn't define popen()/pclose(). */ 71 #ifdef USE_OWN_POPEN 72 #include "popen.h" 73 #endif 74 75 #ifdef SERVER_SUPPORT 76 /* If the system doesn't provide strerror, it won't be declared in 77 string.h. */ 78 char *strerror (int); 79 #endif 80 81 #include "hash.h" 82 #include "stack.h" 83 84 #include "root.h" 85 86 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT) 87 # include "client.h" 88 #endif 89 90 #ifdef MY_NDBM 91 #include "myndbm.h" 92 #else 93 #include <ndbm.h> 94 #endif /* MY_NDBM */ 95 96 #include "wait.h" 97 98 #include "rcs.h" 99 100 101 102 /* Note that the _ONLY_ reason for PATH_MAX is if various system calls (getwd, 103 * getcwd, readlink) require/want us to use it. All other parts of CVS 104 * allocate pathname buffers dynamically, and we want to keep it that way. 105 */ 106 #include "pathmax.h" 107 108 109 110 /* Definitions for the CVS Administrative directory and the files it contains. 111 Here as #define's to make changing the names a simple task. */ 112 113 #ifdef USE_VMS_FILENAMES 114 #define CVSADM getCVSDir("") 115 #define CVSADM_ENT getCVSDir("/Entries.") 116 #define CVSADM_ENTBAK getCVSDir("/Entries.Backup") 117 #define CVSADM_ENTLOG getCVSDir("/Entries.Log") 118 #define CVSADM_ENTSTAT getCVSDir("/Entries.Static") 119 #define CVSADM_REP getCVSDir("/Repository.") 120 #define CVSADM_ROOT getCVSDir("/Root.") 121 #define CVSADM_CIPROG getCVSDir("/Checkin.prog") 122 #define CVSADM_UPROG getCVSDir("/Update.prog") 123 #define CVSADM_TAG getCVSDir("/Tag.") 124 #define CVSADM_NOTIFY getCVSDir("/Notify.") 125 #define CVSADM_NOTIFYTMP getCVSDir("/Notify.tmp") 126 #define CVSADM_BASE getCVSDir("/Base") 127 #define CVSADM_BASEREV getCVSDir("/Baserev.") 128 #define CVSADM_BASEREVTMP getCVSDir("/Baserev.tmp") 129 #define CVSADM_TEMPLATE getCVSDir("/Template.") 130 #else /* USE_VMS_FILENAMES */ 131 #define CVSADM getCVSDir("") 132 #define CVSADM_ENT getCVSDir("/Entries") 133 #define CVSADM_ENTBAK getCVSDir("/Entries.Backup") 134 #define CVSADM_ENTLOG getCVSDir("/Entries.Log") 135 #define CVSADM_ENTSTAT getCVSDir("/Entries.Static") 136 #define CVSADM_REP getCVSDir("/Repository") 137 #define CVSADM_ROOT getCVSDir("/Root") 138 #define CVSADM_CIPROG getCVSDir("/Checkin.prog") 139 #define CVSADM_UPROG getCVSDir("/Update.prog") 140 #define CVSADM_TAG getCVSDir("/Tag") 141 #define CVSADM_NOTIFY getCVSDir("/Notify") 142 #define CVSADM_NOTIFYTMP getCVSDir("/Notify.tmp") 143 /* A directory in which we store base versions of files we currently are 144 editing with "cvs edit". */ 145 #define CVSADM_BASE getCVSDir("/Base") 146 #define CVSADM_BASEREV getCVSDir("/Baserev") 147 #define CVSADM_BASEREVTMP getCVSDir("/Baserev.tmp") 148 /* File which contains the template for use in log messages. */ 149 #define CVSADM_TEMPLATE getCVSDir("/Template") 150 #endif /* USE_VMS_FILENAMES */ 151 152 /* This is the special directory which we use to store various extra 153 per-directory information in the repository. It must be the same as 154 CVSADM to avoid creating a new reserved directory name which users cannot 155 use, but is a separate #define because if anyone changes it (which I don't 156 recommend), one needs to deal with old, unconverted, repositories. 157 158 See fileattr.h for details about file attributes, the only thing stored 159 in CVSREP currently. */ 160 #define CVSREP getCVSDir("") 161 162 /* 163 * Definitions for the CVSROOT Administrative directory and the files it 164 * contains. This directory is created as a sub-directory of the $CVSROOT 165 * environment variable, and holds global administration information for the 166 * entire source repository beginning at $CVSROOT. 167 */ 168 #define CVSROOTADM "CVSROOT" 169 #define CVSROOTADM_CHECKOUTLIST "checkoutlist" 170 #define CVSROOTADM_COMMITINFO "commitinfo" 171 #define CVSROOTADM_CONFIG "config" 172 #define CVSROOTADM_HISTORY "history" 173 #define CVSROOTADM_IGNORE "cvsignore" 174 #define CVSROOTADM_LOGINFO "loginfo" 175 #define CVSROOTADM_MODULES "modules" 176 #define CVSROOTADM_NOTIFY "notify" 177 #define CVSROOTADM_PASSWD "passwd" 178 #define CVSROOTADM_POSTADMIN "postadmin" 179 #define CVSROOTADM_POSTPROXY "postproxy" 180 #define CVSROOTADM_POSTTAG "posttag" 181 #define CVSROOTADM_POSTWATCH "postwatch" 182 #define CVSROOTADM_PREPROXY "preproxy" 183 #define CVSROOTADM_RCSINFO "rcsinfo" 184 #define CVSROOTADM_READERS "readers" 185 #define CVSROOTADM_TAGINFO "taginfo" 186 #define CVSROOTADM_USERS "users" 187 #define CVSROOTADM_VALTAGS "val-tags" 188 #define CVSROOTADM_VERIFYMSG "verifymsg" 189 #define CVSROOTADM_WRAPPER "cvswrappers" 190 #define CVSROOTADM_WRITERS "writers" 191 192 #define CVSNULLREPOS "Emptydir" /* an empty directory */ 193 194 /* Other CVS file names */ 195 196 /* Files go in the attic if the head main branch revision is dead, 197 otherwise they go in the regular repository directories. The whole 198 concept of having an attic is sort of a relic from before death 199 support but on the other hand, it probably does help the speed of 200 some operations (such as main branch checkouts and updates). */ 201 #define CVSATTIC "Attic" 202 203 #define CVSLCK "#cvs.lock" 204 #define CVSHISTORYLCK "#cvs.history.lock" 205 #define CVSVALTAGSLCK "#cvs.val-tags.lock" 206 #define CVSRFL "#cvs.rfl" 207 #define CVSPFL "#cvs.pfl" 208 #define CVSWFL "#cvs.wfl" 209 #define CVSPFLPAT "#cvs.pfl.*" /* wildcard expr to match plocks */ 210 #define CVSRFLPAT "#cvs.rfl.*" /* wildcard expr to match read locks */ 211 #define CVSEXT_LOG ",t" 212 #define CVSPREFIX ",," 213 #define CVSDOTIGNORE ".cvsignore" 214 #define CVSDOTWRAPPER ".cvswrappers" 215 216 /* Command attributes -- see function lookup_command_attribute(). */ 217 #define CVS_CMD_IGNORE_ADMROOT 1 218 219 /* Set if CVS needs to create a CVS/Root file upon completion of this 220 command. The name may be slightly confusing, because the flag 221 isn't really as general purpose as it seems (it is not set for cvs 222 release). */ 223 224 #define CVS_CMD_USES_WORK_DIR 2 225 226 #define CVS_CMD_MODIFIES_REPOSITORY 4 227 228 /* miscellaneous CVS defines */ 229 230 /* This is the string which is at the start of the non-log-message lines 231 that we put up for the user when they edit the log message. */ 232 #define CVSEDITPREFIX "CVS: " 233 /* Number of characters in CVSEDITPREFIX to compare when deciding to strip 234 off those lines. We don't check for the space, to accomodate users who 235 have editors which strip trailing spaces. */ 236 #define CVSEDITPREFIXLEN 4 237 238 #define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */ 239 #define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */ 240 #define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */ 241 242 #ifdef USE_VMS_FILENAMES 243 # define BAKPREFIX "_$" 244 #else /* USE_VMS_FILENAMES */ 245 # define BAKPREFIX ".#" /* when rcsmerge'ing */ 246 #endif /* USE_VMS_FILENAMES */ 247 248 /* 249 * Special tags. -rHEAD refers to the head of an RCS file, regardless of any 250 * sticky tags. -rBASE refers to the current revision the user has checked 251 * out This mimics the behaviour of RCS. 252 */ 253 #define TAG_HEAD "HEAD" 254 #define TAG_BASE "BASE" 255 256 /* Environment variable used by CVS */ 257 #define CVSREAD_ENV "CVSREAD" /* make files read-only */ 258 #define CVSREAD_DFLT 0 /* writable files by default */ 259 260 #define CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */ 261 262 #define TMPDIR_ENV "TMPDIR" /* Temporary directory */ 263 #define CVS_PID_ENV "CVS_PID" /* pid of running cvs */ 264 265 #define EDITOR1_ENV "CVSEDITOR" /* which editor to use */ 266 #define EDITOR2_ENV "VISUAL" /* which editor to use */ 267 #define EDITOR3_ENV "EDITOR" /* which editor to use */ 268 269 #define CVSROOT_ENV "CVSROOT" /* source directory root */ 270 /* Define CVSROOT_DFLT to a fallback value for CVSROOT. 271 * 272 #undef CVSROOT_DFL 273 */ 274 275 #define IGNORE_ENV "CVSIGNORE" /* More files to ignore */ 276 #define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */ 277 278 #define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */ 279 280 /* 281 * If the beginning of the Repository matches the following string, strip it 282 * so that the output to the logfile does not contain a full pathname. 283 * 284 * If the CVSROOT environment variable is set, it overrides this define. 285 */ 286 #define REPOS_STRIP "/master/" 287 288 /* Large enough to hold DATEFORM. Not an arbitrary limit as long as 289 it is used for that purpose, and not to hold a string from the 290 command line, the client, etc. */ 291 #define MAXDATELEN 50 292 293 /* The type of an entnode. */ 294 enum ent_type 295 { 296 ENT_FILE, ENT_SUBDIR 297 }; 298 299 /* structure of a entry record */ 300 struct entnode 301 { 302 enum ent_type type; 303 char *user; 304 char *version; 305 306 /* Timestamp, or "" if none (never NULL). */ 307 char *timestamp; 308 309 /* Keyword expansion options, or "" if none (never NULL). */ 310 char *options; 311 312 char *tag; 313 char *date; 314 char *conflict; 315 }; 316 typedef struct entnode Entnode; 317 318 /* The type of request that is being done in do_module() */ 319 enum mtype 320 { 321 CHECKOUT, TAG, PATCH, EXPORT, MISC 322 }; 323 324 /* 325 * structure used for list-private storage by Entries_Open() and 326 * Version_TS() and Find_Directories(). 327 */ 328 struct stickydirtag 329 { 330 /* These fields pass sticky tag information from Entries_Open() to 331 Version_TS(). */ 332 int aflag; 333 char *tag; 334 char *date; 335 int nonbranch; 336 337 /* This field is set by Entries_Open() if there was subdirectory 338 information; Find_Directories() uses it to see whether it needs 339 to scan the directory itself. */ 340 int subdirs; 341 }; 342 343 /* Flags for find_{names,dirs} routines */ 344 #define W_LOCAL 0x01 /* look for files locally */ 345 #define W_REPOS 0x02 /* look for files in the repository */ 346 #define W_ATTIC 0x04 /* look for files in the attic */ 347 348 /* Flags for return values of direnter procs for the recursion processor */ 349 enum direnter_type 350 { 351 R_PROCESS = 1, /* process files and maybe dirs */ 352 R_SKIP_FILES, /* don't process files in this dir */ 353 R_SKIP_DIRS, /* don't process sub-dirs */ 354 R_SKIP_ALL /* don't process files or dirs */ 355 }; 356 #ifdef ENUMS_CAN_BE_TROUBLE 357 typedef int Dtype; 358 #else 359 typedef enum direnter_type Dtype; 360 #endif 361 362 /* Recursion processor lock types */ 363 #define CVS_LOCK_NONE 0 364 #define CVS_LOCK_READ 1 365 #define CVS_LOCK_WRITE 2 366 367 /* Option flags for Parse_Info() */ 368 #define PIOPT_ALL 1 /* accept "all" keyword */ 369 370 extern const char *program_name, *program_path, *cvs_cmd_name; 371 extern char *Editor; 372 extern int cvsadmin_root; 373 extern char *CurDir; 374 extern int really_quiet, quiet; 375 extern int use_editor; 376 extern int cvswrite; 377 extern mode_t cvsumask; 378 379 /* Temp dir abstraction. */ 380 /* From main.c. */ 381 const char *get_cvs_tmp_dir (void); 382 /* From filesubr.c. */ 383 const char *get_system_temp_dir (void); 384 void push_env_temp_dir (void); 385 386 387 /* This global variable holds the global -d option. It is NULL if -d 388 was not used, which means that we must get the CVSroot information 389 from the CVSROOT environment variable or from a CVS/Root file. */ 390 extern char *CVSroot_cmdline; 391 392 /* This variable keeps track of all of the CVSROOT directories that 393 * have been seen by the client. 394 */ 395 extern List *root_directories; 396 397 char *emptydir_name (void); 398 int safe_location (char *); 399 400 extern int trace; /* Show all commands */ 401 extern int noexec; /* Don't modify disk anywhere */ 402 extern int nolock; /* Don't create locks */ 403 extern int readonlyfs; /* fail on all write locks; succeed all read locks */ 404 extern int logoff; /* Don't write history entry */ 405 406 407 408 #define LOGMSG_REREAD_NEVER 0 /* do_verify - never reread message */ 409 #define LOGMSG_REREAD_ALWAYS 1 /* do_verify - always reread message */ 410 #define LOGMSG_REREAD_STAT 2 /* do_verify - reread message if changed */ 411 412 /* This header needs the LOGMSG_* defns above. */ 413 #include "parseinfo.h" 414 415 /* This structure holds the global configuration data. */ 416 extern struct config *config; 417 418 #ifdef CLIENT_SUPPORT 419 extern List *dirs_sent_to_server; /* used to decide which "Argument 420 xxx" commands to send to each 421 server in multiroot mode. */ 422 #endif 423 424 extern char *hostname; 425 426 /* Externs that are included directly in the CVS sources */ 427 428 int RCS_merge (RCSNode *, const char *, const char *, const char *, 429 const char *, const char *); 430 /* Flags used by RCS_* functions. See the description of the individual 431 functions for which flags mean what for each function. */ 432 #define RCS_FLAGS_FORCE 1 433 #define RCS_FLAGS_DEAD 2 434 #define RCS_FLAGS_QUIET 4 435 #define RCS_FLAGS_MODTIME 8 436 #define RCS_FLAGS_KEEPFILE 16 437 #define RCS_FLAGS_USETIME 32 438 439 int RCS_exec_rcsdiff (RCSNode *rcsfile, int diff_argc, 440 char * const *diff_argv, const char *options, 441 const char *rev1, const char *rev1_cache, 442 const char *rev2, 443 const char *label1, const char *label2, 444 const char *workfile); 445 int diff_exec (const char *file1, const char *file2, 446 const char *label1, const char *label2, 447 int iargc, char * const *iargv, const char *out); 448 449 450 #include "error.h" 451 452 /* If non-zero, error will use the CVS protocol to report error 453 * messages. This will only be set in the CVS server parent process; 454 * most other code is run via do_cvs_command, which forks off a child 455 * process and packages up its stderr in the protocol. 456 * 457 * This needs to be here rather than in error.h in order to use an unforked 458 * error.h from GNULIB. 459 */ 460 extern int error_use_protocol; 461 462 463 DBM *open_module (void); 464 List *Find_Directories (char *repository, int which, List *entries); 465 void Entries_Close (List *entries); 466 List *Entries_Open (int aflag, char *update_dir); 467 void Subdirs_Known (List *entries); 468 void Subdir_Register (List *, const char *, const char *); 469 void Subdir_Deregister (List *, const char *, const char *); 470 const char *getCVSDir (const char *); 471 472 void parse_tagdate (char **tag, char **date, const char *input); 473 char *Make_Date (const char *rawdate); 474 char *date_from_time_t (time_t); 475 void date_to_internet (char *, const char *); 476 void date_to_tm (struct tm *, const char *); 477 void tm_to_internet (char *, const struct tm *); 478 char *gmformat_time_t (time_t unixtime); 479 char *format_date_alloc (char *text); 480 481 char *Name_Repository (const char *dir, const char *update_dir); 482 const char *Short_Repository (const char *repository); 483 void Sanitize_Repository_Name (char *repository); 484 485 char *entries_time (time_t unixtime); 486 time_t unix_time_stamp (const char *file); 487 char *time_stamp (const char *file); 488 489 typedef int (*CALLPROC) (const char *repository, const char *value, 490 void *closure); 491 int Parse_Info (const char *infofile, const char *repository, 492 CALLPROC callproc, int opt, void *closure); 493 494 typedef RETSIGTYPE (*SIGCLEANUPPROC) (int); 495 int SIG_register (int sig, SIGCLEANUPPROC sigcleanup); 496 bool isdir (const char *file); 497 bool isfile (const char *file); 498 ssize_t islink (const char *file); 499 bool isdevice (const char *file); 500 bool isreadable (const char *file); 501 bool iswritable (const char *file); 502 bool isaccessible (const char *file, const int mode); 503 const char *last_component (const char *path); 504 char *get_homedir (void); 505 char *strcat_filename_onto_homedir (const char *, const char *); 506 char *cvs_temp_name (void); 507 FILE *cvs_temp_file (char **filename); 508 509 int ls (int argc, char *argv[]); 510 int unlink_file (const char *f); 511 int unlink_file_dir (const char *f); 512 513 /* This is the structure that the recursion processor passes to the 514 fileproc to tell it about a particular file. */ 515 struct file_info 516 { 517 /* Name of the file, without any directory component. */ 518 const char *file; 519 520 /* Name of the directory we are in, relative to the directory in 521 which this command was issued. We have cd'd to this directory 522 (either in the working directory or in the repository, depending 523 on which sort of recursion we are doing). If we are in the directory 524 in which the command was issued, this is "". */ 525 const char *update_dir; 526 527 /* update_dir and file put together, with a slash between them as 528 necessary. This is the proper way to refer to the file in user 529 messages. */ 530 const char *fullname; 531 532 /* Name of the directory corresponding to the repository which contains 533 this file. */ 534 const char *repository; 535 536 /* The pre-parsed entries for this directory. */ 537 List *entries; 538 539 RCSNode *rcs; 540 }; 541 542 /* This needs to be included after the struct file_info definition since some 543 * of the functions subr.h defines refer to struct file_info. 544 */ 545 #include "subr.h" 546 547 int update (int argc, char *argv[]); 548 /* The only place this is currently used outside of update.c is add.c. 549 * Restricting its use to update.c seems to be in the best interest of 550 * modularity, but I can't think of a good way to get an update of a 551 * resurrected file done and print the fact otherwise. 552 */ 553 void write_letter (struct file_info *finfo, int letter); 554 int xcmp (const char *file1, const char *file2); 555 void *valloc (size_t bytes); 556 557 int Create_Admin (const char *dir, const char *update_dir, 558 const char *repository, const char *tag, const char *date, 559 int nonbranch, int warn, int dotemplate); 560 int expand_at_signs (const char *, size_t, FILE *); 561 562 /* Locking subsystem (implemented in lock.c). */ 563 564 int Reader_Lock (char *xrepository); 565 void Simple_Lock_Cleanup (void); 566 void Lock_Cleanup (void); 567 568 /* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL, 569 and AFLAG, anyway. */ 570 void lock_tree_promotably (int argc, char **argv, int local, int which, 571 int aflag); 572 573 /* See lock.c for description. */ 574 void lock_dir_for_write (const char *); 575 576 /* Get a write lock for the history file. */ 577 int history_lock (const char *); 578 void clear_history_lock (void); 579 580 /* Get a write lock for the val-tags file. */ 581 int val_tags_lock (const char *); 582 void clear_val_tags_lock (void); 583 584 void Scratch_Entry (List * list, const char *fname); 585 void ParseTag (char **tagp, char **datep, int *nonbranchp); 586 void WriteTag (const char *dir, const char *tag, const char *date, 587 int nonbranch, const char *update_dir, const char *repository); 588 void WriteTemplate (const char *update_dir, int dotemplate, 589 const char *repository); 590 void cat_module (int status); 591 void check_entries (char *dir); 592 void close_module (DBM * db); 593 void copy_file (const char *from, const char *to); 594 void fperrmsg (FILE * fp, int status, int errnum, char *message,...); 595 596 int ign_name (char *name); 597 void ign_add (char *ign, int hold); 598 void ign_add_file (char *file, int hold); 599 void ign_setup (void); 600 void ign_dir_add (char *name); 601 int ignore_directory (const char *name); 602 typedef void (*Ignore_proc) (const char *, const char *); 603 void ignore_files (List *, List *, const char *, Ignore_proc); 604 extern int ign_inhibit_server; 605 606 #include "update.h" 607 608 void make_directories (const char *name); 609 void make_directory (const char *name); 610 int mkdir_if_needed (const char *name); 611 void rename_file (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 void expand_wild (int argc, char **argv, 620 int *pargc, char ***pargv); 621 622 /* exithandle.c */ 623 void signals_register (RETSIGTYPE (*handler)(int)); 624 void cleanup_register (void (*handler) (void)); 625 626 void update_delproc (Node * p); 627 void usage (const char *const *cpp); 628 void xchmod (const char *fname, int writable); 629 List *Find_Names (char *repository, int which, int aflag, 630 List ** optentries); 631 void Register (List * list, const char *fname, const char *vn, const char *ts, 632 const char *options, const char *tag, const char *date, 633 const char *ts_conflict); 634 void Update_Logfile (const char *repository, const char *xmessage, 635 FILE *xlogfp, List *xchanges); 636 void do_editor (const char *dir, char **messagep, 637 const char *repository, List *changes); 638 639 void do_verify (char **messagep, const char *repository, List *changes); 640 641 typedef int (*CALLBACKPROC) (int argc, char *argv[], char *where, 642 char *mwhere, char *mfile, int shorten, int local_specified, 643 char *omodule, char *msg); 644 645 646 typedef int (*FILEPROC) (void *callerdat, struct file_info *finfo); 647 typedef int (*FILESDONEPROC) (void *callerdat, int err, 648 const char *repository, const char *update_dir, 649 List *entries); 650 typedef Dtype (*DIRENTPROC) (void *callerdat, const char *dir, 651 const char *repos, const char *update_dir, 652 List *entries); 653 typedef int (*DIRLEAVEPROC) (void *callerdat, const char *dir, int err, 654 const char *update_dir, List *entries); 655 656 int mkmodules (char *dir); 657 int init (int argc, char **argv); 658 659 int do_module (DBM * db, char *mname, enum mtype m_type, char *msg, 660 CALLBACKPROC callback_proc, char *where, int shorten, 661 int local_specified, int run_module_prog, int build_dirs, 662 char *extra_arg); 663 void history_write (int type, const char *update_dir, const char *revs, 664 const char *name, const char *repository); 665 int start_recursion (FILEPROC fileproc, FILESDONEPROC filesdoneproc, 666 DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc, 667 void *callerdat, 668 int argc, char *argv[], int local, int which, 669 int aflag, int locktype, char *update_preload, 670 int dosrcs, char *repository); 671 void SIG_beginCrSect (void); 672 void SIG_endCrSect (void); 673 int SIG_inCrSect (void); 674 void read_cvsrc (int *argc, char ***argv, const char *cmdname); 675 676 /* flags for run_exec(), the fast system() for CVS */ 677 #define RUN_NORMAL 0x0000 /* no special behaviour */ 678 #define RUN_COMBINED 0x0001 /* stdout is duped to stderr */ 679 #define RUN_REALLY 0x0002 /* do the exec, even if noexec is on */ 680 #define RUN_STDOUT_APPEND 0x0004 /* append to stdout, don't truncate */ 681 #define RUN_STDERR_APPEND 0x0008 /* append to stderr, don't truncate */ 682 #define RUN_SIGIGNORE 0x0010 /* ignore interrupts for command */ 683 #define RUN_UNSETXID 0x0020 /* undo setxid in child */ 684 #define RUN_TTY (char *)0 /* for the benefit of lint */ 685 686 void run_add_arg_p (int *, size_t *, char ***, const char *s); 687 void run_arg_free_p (int, char **); 688 void run_add_arg (const char *s); 689 void run_print (FILE * fp); 690 void run_setup (const char *prog); 691 int run_exec (const char *stin, const char *stout, const char *sterr, 692 int flags); 693 int run_piped (int *, int *); 694 695 /* other similar-minded stuff from run.c. */ 696 FILE *run_popen (const char *, const char *); 697 int piped_child (char *const *, int *, int *, bool); 698 void close_on_exec (int); 699 700 pid_t waitpid (pid_t, int *, int); 701 702 /* 703 * a struct vers_ts contains all the information about a file including the 704 * user and rcs file names, and the version checked out and the head. 705 * 706 * this is usually obtained from a call to Version_TS which takes a 707 * tag argument for the RCS file if desired 708 */ 709 struct vers_ts 710 { 711 /* rcs version user file derives from, from CVS/Entries. 712 It can have the following special values: 713 714 NULL = file is not mentioned in Entries (this is also used for a 715 directory). 716 "" = INVALID! The comment used to say that it meant "no user file" 717 but as far as I know CVS didn't actually use it that way. 718 Note that according to cvs.texinfo, "" is not valid in the 719 Entries file. 720 0 = user file is new 721 -vers = user file to be removed. */ 722 char *vn_user; 723 724 /* Numeric revision number corresponding to ->vn_tag (->vn_tag 725 will often be symbolic). */ 726 char *vn_rcs; 727 /* If ->tag is a simple tag in the RCS file--a tag which really 728 exists which is not a magic revision--and if ->date is NULL, 729 then this is a copy of ->tag. Otherwise, it is a copy of 730 ->vn_rcs. */ 731 char *vn_tag; 732 733 /* This is the timestamp from stating the file in the working directory. 734 It is NULL if there is no file in the working directory. It is 735 "Is-modified" if we know the file is modified but don't have its 736 contents. */ 737 char *ts_user; 738 /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs 739 are computed in a slightly different way, but the fact remains that 740 if they are equal the file in the working directory is unmodified 741 and if they differ it is modified. */ 742 char *ts_rcs; 743 744 /* Options from CVS/Entries (keyword expansion), malloc'd. If none, 745 then it is an empty string (never NULL). */ 746 char *options; 747 748 /* If non-NULL, there was a conflict (or merely a merge? See merge_file) 749 and the time stamp in this field is the time stamp of the working 750 directory file which was created with the conflict markers in it. 751 This is from CVS/Entries. */ 752 char *ts_conflict; 753 754 /* Tag specified on the command line, or if none, tag stored in 755 CVS/Entries. */ 756 char *tag; 757 /* Date specified on the command line, or if none, date stored in 758 CVS/Entries. */ 759 char *date; 760 /* If this is 1, then tag is not a branch tag. If this is 0, then 761 tag may or may not be a branch tag. */ 762 int nonbranch; 763 764 /* Pointer to entries file node */ 765 Entnode *entdata; 766 767 /* Pointer to parsed src file info */ 768 RCSNode *srcfile; 769 }; 770 typedef struct vers_ts Vers_TS; 771 772 Vers_TS *Version_TS (struct file_info *finfo, char *options, char *tag, 773 char *date, int force_tag_match, 774 int set_time); 775 void freevers_ts (Vers_TS ** versp); 776 777 /* Miscellaneous CVS infrastructure which layers on top of the recursion 778 processor (for example, needs struct file_info). */ 779 780 int Checkin (int type, struct file_info *finfo, char *rev, 781 char *tag, char *options, char *message); 782 int No_Difference (struct file_info *finfo, Vers_TS *vers); 783 /* TODO: can the finfo argument to special_file_mismatch be changed? -twp */ 784 int special_file_mismatch (struct file_info *finfo, 785 char *rev1, char *rev2); 786 787 /* CVSADM_BASEREV stuff, from entries.c. */ 788 char *base_get (struct file_info *); 789 void base_register (struct file_info *, char *); 790 void base_deregister (struct file_info *); 791 792 /* 793 * defines for Classify_File() to determine the current state of a file. 794 * These are also used as types in the data field for the list we make for 795 * Update_Logfile in commit, import, and add. 796 */ 797 enum classify_type 798 { 799 T_UNKNOWN = 1, /* no old-style analog existed */ 800 T_CONFLICT, /* C (conflict) list */ 801 T_NEEDS_MERGE, /* G (needs merging) list */ 802 T_MODIFIED, /* M (needs checked in) list */ 803 T_CHECKOUT, /* O (needs checkout) list */ 804 T_ADDED, /* A (added file) list */ 805 T_REMOVED, /* R (removed file) list */ 806 T_REMOVE_ENTRY, /* W (removed entry) list */ 807 T_UPTODATE, /* File is up-to-date */ 808 T_PATCH, /* P Like C, but can patch */ 809 T_TITLE /* title for node type */ 810 }; 811 typedef enum classify_type Ctype; 812 813 Ctype Classify_File (struct file_info *finfo, char *tag, char *date, char *options, 814 int force_tag_match, int aflag, Vers_TS **versp, int pipeout); 815 816 /* 817 * structure used for list nodes passed to Update_Logfile() and 818 * do_editor(). 819 */ 820 struct logfile_info 821 { 822 enum classify_type type; 823 char *tag; 824 char *rev_old; /* rev number before a commit/modify, 825 NULL for add or import */ 826 char *rev_new; /* rev number after a commit/modify, 827 add, or import, NULL for remove */ 828 }; 829 830 /* Wrappers. */ 831 832 typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod; 833 typedef enum { 834 /* -t and -f wrapper options. Treating directories as single files. */ 835 WRAP_TOCVS, 836 WRAP_FROMCVS, 837 /* -k wrapper option. Default keyword expansion options. */ 838 WRAP_RCSOPTION 839 } WrapMergeHas; 840 841 void wrap_setup (void); 842 int wrap_name_has (const char *name,WrapMergeHas has); 843 char *wrap_rcsoption (const char *fileName, int asFlag); 844 char *wrap_tocvs_process_file (const char *fileName); 845 int wrap_merge_is_copy (const char *fileName); 846 void wrap_fromcvs_process_file (const char *fileName); 847 void wrap_add_file (const char *file,int temp); 848 void wrap_add (char *line,int temp); 849 void wrap_send (void); 850 #if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT) 851 void wrap_unparse_rcs_options (char **, int); 852 #endif /* SERVER_SUPPORT || CLIENT_SUPPORT */ 853 854 /* Pathname expansion */ 855 char *expand_path (const char *name, const char *cvsroot, bool formatsafe, 856 const char *file, int line); 857 858 /* User variables. */ 859 extern List *variable_list; 860 861 void variable_set (char *nameval); 862 863 int watch (int argc, char **argv); 864 int edit (int argc, char **argv); 865 int unedit (int argc, char **argv); 866 int editors (int argc, char **argv); 867 int watchers (int argc, char **argv); 868 int annotate (int argc, char **argv); 869 int add (int argc, char **argv); 870 int admin (int argc, char **argv); 871 int checkout (int argc, char **argv); 872 int commit (int argc, char **argv); 873 int diff (int argc, char **argv); 874 int history (int argc, char **argv); 875 int import (int argc, char **argv); 876 int cvslog (int argc, char **argv); 877 #ifdef AUTH_CLIENT_SUPPORT 878 /* Some systems (namely Mac OS X) have conflicting definitions for these 879 * functions. Avoid them. 880 */ 881 #ifdef HAVE_LOGIN 882 # define login cvs_login 883 #endif /* HAVE_LOGIN */ 884 #ifdef HAVE_LOGOUT 885 # define logout cvs_logout 886 #endif /* HAVE_LOGOUT */ 887 int login (int argc, char **argv); 888 int logout (int argc, char **argv); 889 #endif /* AUTH_CLIENT_SUPPORT */ 890 int patch (int argc, char **argv); 891 int release (int argc, char **argv); 892 int cvsremove (int argc, char **argv); 893 int rtag (int argc, char **argv); 894 int cvsstatus (int argc, char **argv); 895 int cvstag (int argc, char **argv); 896 int version (int argc, char **argv); 897 int admin_group_member (void); 898 void free_cvs_password (char *); 899 void getoptreset (void); 900 901 unsigned long int lookup_command_attribute (const char *); 902 903 #if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT) 904 char *scramble (char *str); 905 char *descramble (char *str); 906 #endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */ 907 908 #ifdef AUTH_CLIENT_SUPPORT 909 char *get_cvs_password (void); 910 /* get_cvs_port_number() is not pure since the /etc/services file could change 911 * between calls. */ 912 int get_cvs_port_number (const cvsroot_t *root); 913 /* normalize_cvsroot() is not pure since it calls get_cvs_port_number. */ 914 char *normalize_cvsroot (const cvsroot_t *root) 915 __attribute__ ((__malloc__)); 916 #endif /* AUTH_CLIENT_SUPPORT */ 917 918 void tag_check_valid (const char *, int, char **, int, int, char *, bool); 919 920 #include "server.h" 921 922 /* From server.c and documented there. */ 923 void cvs_output (const char *, size_t); 924 void cvs_output_binary (char *, size_t); 925 void cvs_outerr (const char *, size_t); 926 void cvs_flusherr (void); 927 void cvs_flushout (void); 928 void cvs_output_tagged (const char *, const char *); 929 930 extern const char *global_session_id; 931 932 /* From find_names.c. */ 933 List *find_files (const char *dir, const char *pat); 934