#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
# define __attribute__(Spec)
# else
# if __GNUC__ == 2 && __GNUC_MINOR__ < 96
# define __pure__
# endif
# if __GNUC__ < 3
# define __malloc__
# endif
# endif
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __const__ const
# define __format__ format
# define __noreturn__ noreturn
# define __printf__ printf
# endif
#endif
#include "system.h"
#include "dirname.h"
#include "exit.h"
#include "getdate.h"
#include "minmax.h"
#include "regex.h"
#include "strcase.h"
#include "stat-macros.h"
#include "timespec.h"
#include "unlocked-io.h"
#include "xalloc.h"
#include "xgetcwd.h"
#include "xreadlink.h"
#include "xsize.h"
#if ! STDC_HEADERS
char *getenv();
#endif
#ifdef USE_OWN_POPEN
#include "popen.h"
#endif
#ifdef SERVER_SUPPORT
char *strerror (int);
#endif
#include "hash.h"
#include "stack.h"
#include "root.h"
#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
# include "client.h"
#endif
#ifdef MY_NDBM
#include "myndbm.h"
#else
#include <ndbm.h>
#endif
#include "wait.h"
#include "rcs.h"
#include "pathmax.h"
#ifdef USE_VMS_FILENAMES
#define CVSADM "CVS"
#define CVSADM_ENT "CVS/Entries."
#define CVSADM_ENTBAK "CVS/Entries.Backup"
#define CVSADM_ENTLOG "CVS/Entries.Log"
#define CVSADM_ENTSTAT "CVS/Entries.Static"
#define CVSADM_REP "CVS/Repository."
#define CVSADM_ROOT "CVS/Root."
#define CVSADM_TAG "CVS/Tag."
#define CVSADM_NOTIFY "CVS/Notify."
#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
#define CVSADM_BASE "CVS/Base"
#define CVSADM_BASEREV "CVS/Baserev."
#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
#define CVSADM_TEMPLATE "CVS/Template."
#else
#define CVSADM "CVS"
#define CVSADM_ENT "CVS/Entries"
#define CVSADM_ENTBAK "CVS/Entries.Backup"
#define CVSADM_ENTLOG "CVS/Entries.Log"
#define CVSADM_ENTSTAT "CVS/Entries.Static"
#define CVSADM_REP "CVS/Repository"
#define CVSADM_ROOT "CVS/Root"
#define CVSADM_TAG "CVS/Tag"
#define CVSADM_NOTIFY "CVS/Notify"
#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
#define CVSADM_BASE "CVS/Base"
#define CVSADM_BASEREV "CVS/Baserev"
#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
#define CVSADM_TEMPLATE "CVS/Template"
#endif
#define CVSREP "CVS"
#define CVSROOTADM "CVSROOT"
#define CVSROOTADM_CHECKOUTLIST "checkoutlist"
#define CVSROOTADM_COMMITINFO "commitinfo"
#define CVSROOTADM_CONFIG "config"
#define CVSROOTADM_HISTORY "history"
#define CVSROOTADM_IGNORE "cvsignore"
#define CVSROOTADM_LOGINFO "loginfo"
#define CVSROOTADM_MODULES "modules"
#define CVSROOTADM_NOTIFY "notify"
#define CVSROOTADM_PASSWD "passwd"
#define CVSROOTADM_POSTADMIN "postadmin"
#define CVSROOTADM_POSTPROXY "postproxy"
#define CVSROOTADM_POSTTAG "posttag"
#define CVSROOTADM_POSTWATCH "postwatch"
#define CVSROOTADM_PREPROXY "preproxy"
#define CVSROOTADM_RCSINFO "rcsinfo"
#define CVSROOTADM_READERS "readers"
#define CVSROOTADM_TAGINFO "taginfo"
#define CVSROOTADM_USERS "users"
#define CVSROOTADM_VALTAGS "val-tags"
#define CVSROOTADM_VERIFYMSG "verifymsg"
#define CVSROOTADM_WRAPPER "cvswrappers"
#define CVSROOTADM_WRITERS "writers"
#define CVSNULLREPOS "Emptydir"
#define CVSATTIC "Attic"
#define CVSLCK "#cvs.lock"
#define CVSHISTORYLCK "#cvs.history.lock"
#define CVSVALTAGSLCK "#cvs.val-tags.lock"
#define CVSRFL "#cvs.rfl"
#define CVSPFL "#cvs.pfl"
#define CVSWFL "#cvs.wfl"
#define CVSPFLPAT "#cvs.pfl.*"
#define CVSRFLPAT "#cvs.rfl.*"
#define CVSEXT_LOG ",t"
#define CVSPREFIX ",,"
#define CVSDOTIGNORE ".cvsignore"
#define CVSDOTWRAPPER ".cvswrappers"
#define CVS_CMD_IGNORE_ADMROOT 1
#define CVS_CMD_USES_WORK_DIR 2
#define CVS_CMD_MODIFIES_REPOSITORY 4
#define CVSEDITPREFIX "CVS: "
#define CVSEDITPREFIXLEN 4
#define CVSLCKAGE (60*60)
#define CVSLCKSLEEP 30
#define CVSBRANCH "1.1.1"
#ifdef USE_VMS_FILENAMES
# define BAKPREFIX "_$"
#else
# define BAKPREFIX ".#"
#endif
#define TAG_HEAD "HEAD"
#define TAG_BASE "BASE"
#define CVSREAD_ENV "CVSREAD"
#define CVSREAD_DFLT 0
#define CVSREADONLYFS_ENV "CVSREADONLYFS"
#define TMPDIR_ENV "TMPDIR"
#define CVS_PID_ENV "CVS_PID"
#define EDITOR1_ENV "CVSEDITOR"
#define EDITOR2_ENV "VISUAL"
#define EDITOR3_ENV "EDITOR"
#define CVSROOT_ENV "CVSROOT"
#define IGNORE_ENV "CVSIGNORE"
#define WRAPPER_ENV "CVSWRAPPERS"
#define CVSUMASK_ENV "CVSUMASK"
#define REPOS_STRIP "/master/"
#define MAXDATELEN 50
enum ent_type
{
ENT_FILE, ENT_SUBDIR
};
struct entnode
{
enum ent_type type;
char *user;
char *version;
char *timestamp;
char *options;
char *tag;
char *date;
char *conflict;
};
typedef struct entnode Entnode;
enum mtype
{
CHECKOUT, TAG, PATCH, EXPORT, MISC
};
struct stickydirtag
{
int aflag;
char *tag;
char *date;
int nonbranch;
int subdirs;
};
#define W_LOCAL 0x01
#define W_REPOS 0x02
#define W_ATTIC 0x04
enum direnter_type
{
R_PROCESS = 1,
R_SKIP_FILES,
R_SKIP_DIRS,
R_SKIP_ALL
};
#ifdef ENUMS_CAN_BE_TROUBLE
typedef int Dtype;
#else
typedef enum direnter_type Dtype;
#endif
#define CVS_LOCK_NONE 0
#define CVS_LOCK_READ 1
#define CVS_LOCK_WRITE 2
#define PIOPT_ALL 1
extern const char *program_name, *program_path, *cvs_cmd_name;
extern char *Editor;
extern int cvsadmin_root;
extern char *CurDir;
extern int really_quiet, quiet;
extern int use_editor;
extern int cvswrite;
extern mode_t cvsumask;
const char *get_cvs_tmp_dir (void);
const char *get_system_temp_dir (void);
void push_env_temp_dir (void);
extern char *CVSroot_cmdline;
extern List *root_directories;
char *emptydir_name (void);
int safe_location (char *);
extern int trace;
extern int noexec;
extern int readonlyfs;
extern int logoff;
#define LOGMSG_REREAD_NEVER 0
#define LOGMSG_REREAD_ALWAYS 1
#define LOGMSG_REREAD_STAT 2
#include "parseinfo.h"
extern struct config *config;
#ifdef CLIENT_SUPPORT
extern List *dirs_sent_to_server;
#endif
extern char *hostname;
int RCS_merge (RCSNode *, const char *, const char *, const char *,
const char *, const char *);
#define RCS_FLAGS_FORCE 1
#define RCS_FLAGS_DEAD 2
#define RCS_FLAGS_QUIET 4
#define RCS_FLAGS_MODTIME 8
#define RCS_FLAGS_KEEPFILE 16
#define RCS_FLAGS_USETIME 32
int RCS_exec_rcsdiff (RCSNode *rcsfile, int diff_argc,
char * const *diff_argv, const char *options,
const char *rev1, const char *rev1_cache,
const char *rev2,
const char *label1, const char *label2,
const char *workfile);
int diff_exec (const char *file1, const char *file2,
const char *label1, const char *label2,
int iargc, char * const *iargv, const char *out);
#include "error.h"
extern int error_use_protocol;
DBM *open_module (void);
List *Find_Directories (char *repository, int which, List *entries);
void Entries_Close (List *entries);
List *Entries_Open (int aflag, char *update_dir);
void Subdirs_Known (List *entries);
void Subdir_Register (List *, const char *, const char *);
void Subdir_Deregister (List *, const char *, const char *);
void parse_tagdate (char **tag, char **date, const char *input);
char *Make_Date (const char *rawdate);
char *date_from_time_t (time_t);
void date_to_internet (char *, const char *);
void date_to_tm (struct tm *, const char *);
void tm_to_internet (char *, const struct tm *);
char *gmformat_time_t (time_t unixtime);
char *format_date_alloc (char *text);
char *Name_Repository (const char *dir, const char *update_dir);
const char *Short_Repository (const char *repository);
void Sanitize_Repository_Name (char *repository);
char *entries_time (time_t unixtime);
time_t unix_time_stamp (const char *file);
char *time_stamp (const char *file);
typedef int (*CALLPROC) (const char *repository, const char *value,
void *closure);
int Parse_Info (const char *infofile, const char *repository,
CALLPROC callproc, int opt, void *closure);
typedef RETSIGTYPE (*SIGCLEANUPPROC) (int);
int SIG_register (int sig, SIGCLEANUPPROC sigcleanup);
bool isdir (const char *file);
bool isfile (const char *file);
ssize_t islink (const char *file);
bool isdevice (const char *file);
bool isreadable (const char *file);
bool iswritable (const char *file);
bool isaccessible (const char *file, const int mode);
const char *last_component (const char *path);
char *get_homedir (void);
char *strcat_filename_onto_homedir (const char *, const char *);
char *cvs_temp_name (void);
FILE *cvs_temp_file (char **filename);
int ls (int argc, char *argv[]);
int unlink_file (const char *f);
int unlink_file_dir (const char *f);
struct file_info
{
const char *file;
const char *update_dir;
const char *fullname;
const char *repository;
List *entries;
RCSNode *rcs;
};
#include "subr.h"
int update (int argc, char *argv[]);
void write_letter (struct file_info *finfo, int letter);
int xcmp (const char *file1, const char *file2);
void *valloc (size_t bytes);
int Create_Admin (const char *dir, const char *update_dir,
const char *repository, const char *tag, const char *date,
int nonbranch, int warn, int dotemplate);
int expand_at_signs (const char *, size_t, FILE *);
int Reader_Lock (char *xrepository);
void Simple_Lock_Cleanup (void);
void Lock_Cleanup (void);
void lock_tree_promotably (int argc, char **argv, int local, int which,
int aflag);
void lock_dir_for_write (const char *);
int history_lock (const char *);
void clear_history_lock (void);
int val_tags_lock (const char *);
void clear_val_tags_lock (void);
void Scratch_Entry (List * list, const char *fname);
void ParseTag (char **tagp, char **datep, int *nonbranchp);
void WriteTag (const char *dir, const char *tag, const char *date,
int nonbranch, const char *update_dir, const char *repository);
void WriteTemplate (const char *update_dir, int dotemplate,
const char *repository);
void cat_module (int status);
void check_entries (char *dir);
void close_module (DBM * db);
void copy_file (const char *from, const char *to);
void fperrmsg (FILE * fp, int status, int errnum, char *message,...);
int ign_name (char *name);
void ign_add (char *ign, int hold);
void ign_add_file (char *file, int hold);
void ign_setup (void);
void ign_dir_add (char *name);
int ignore_directory (const char *name);
typedef void (*Ignore_proc) (const char *, const char *);
void ignore_files (List *, List *, const char *, Ignore_proc);
extern int ign_inhibit_server;
#include "update.h"
void make_directories (const char *name);
void make_directory (const char *name);
int mkdir_if_needed (const char *name);
void rename_file (const char *from, const char *to);
void expand_wild (int argc, char **argv,
int *pargc, char ***pargv);
void signals_register (RETSIGTYPE (*handler)(int));
void cleanup_register (void (*handler) (void));
void update_delproc (Node * p);
void usage (const char *const *cpp);
void xchmod (const char *fname, int writable);
List *Find_Names (char *repository, int which, int aflag,
List ** optentries);
void Register (List * list, const char *fname, const char *vn, const char *ts,
const char *options, const char *tag, const char *date,
const char *ts_conflict);
void Update_Logfile (const char *repository, const char *xmessage,
FILE *xlogfp, List *xchanges);
void do_editor (const char *dir, char **messagep,
const char *repository, List *changes);
void do_verify (char **messagep, const char *repository, List *changes);
typedef int (*CALLBACKPROC) (int argc, char *argv[], char *where,
char *mwhere, char *mfile, int shorten, int local_specified,
char *omodule, char *msg);
typedef int (*FILEPROC) (void *callerdat, struct file_info *finfo);
typedef int (*FILESDONEPROC) (void *callerdat, int err,
const char *repository, const char *update_dir,
List *entries);
typedef Dtype (*DIRENTPROC) (void *callerdat, const char *dir,
const char *repos, const char *update_dir,
List *entries);
typedef int (*DIRLEAVEPROC) (void *callerdat, const char *dir, int err,
const char *update_dir, List *entries);
int mkmodules (char *dir);
int init (int argc, char **argv);
int do_module (DBM * db, char *mname, enum mtype m_type, char *msg,
CALLBACKPROC callback_proc, char *where, int shorten,
int local_specified, int run_module_prog, int build_dirs,
char *extra_arg);
void history_write (int type, const char *update_dir, const char *revs,
const char *name, const char *repository);
int start_recursion (FILEPROC fileproc, FILESDONEPROC filesdoneproc,
DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
void *callerdat,
int argc, char *argv[], int local, int which,
int aflag, int locktype, char *update_preload,
int dosrcs, char *repository);
void SIG_beginCrSect (void);
void SIG_endCrSect (void);
int SIG_inCrSect (void);
void read_cvsrc (int *argc, char ***argv, const char *cmdname);
#define RUN_NORMAL 0x0000
#define RUN_COMBINED 0x0001
#define RUN_REALLY 0x0002
#define RUN_STDOUT_APPEND 0x0004
#define RUN_STDERR_APPEND 0x0008
#define RUN_SIGIGNORE 0x0010
#define RUN_TTY (char *)0
void run_add_arg_p (int *, size_t *, char ***, const char *s);
void run_arg_free_p (int, char **);
void run_add_arg (const char *s);
void run_print (FILE * fp);
void run_setup (const char *prog);
int run_exec (const char *stin, const char *stout, const char *sterr,
int flags);
int run_piped (int *, int *);
FILE *run_popen (const char *, const char *);
int piped_child (char *const *, int *, int *, bool);
void close_on_exec (int);
pid_t waitpid (pid_t, int *, int);
struct vers_ts
{
char *vn_user;
char *vn_rcs;
char *vn_tag;
char *ts_user;
char *ts_rcs;
char *options;
char *ts_conflict;
char *tag;
char *date;
int nonbranch;
Entnode *entdata;
RCSNode *srcfile;
};
typedef struct vers_ts Vers_TS;
Vers_TS *Version_TS (struct file_info *finfo, char *options, char *tag,
char *date, int force_tag_match,
int set_time);
void freevers_ts (Vers_TS ** versp);
int Checkin (int type, struct file_info *finfo, char *rev,
char *tag, char *options, char *message);
int No_Difference (struct file_info *finfo, Vers_TS *vers);
int special_file_mismatch (struct file_info *finfo,
char *rev1, char *rev2);
char *base_get (struct file_info *);
void base_register (struct file_info *, char *);
void base_deregister (struct file_info *);
enum classify_type
{
T_UNKNOWN = 1,
T_CONFLICT,
T_NEEDS_MERGE,
T_MODIFIED,
T_CHECKOUT,
T_ADDED,
T_REMOVED,
T_REMOVE_ENTRY,
T_UPTODATE,
T_PATCH,
T_TITLE
};
typedef enum classify_type Ctype;
Ctype Classify_File (struct file_info *finfo, char *tag, char *date, char *options,
int force_tag_match, int aflag, Vers_TS **versp, int pipeout);
struct logfile_info
{
enum classify_type type;
char *tag;
char *rev_old;
char *rev_new;
};
typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
typedef enum {
WRAP_TOCVS,
WRAP_FROMCVS,
WRAP_RCSOPTION
} WrapMergeHas;
void wrap_setup (void);
int wrap_name_has (const char *name,WrapMergeHas has);
char *wrap_rcsoption (const char *fileName, int asFlag);
char *wrap_tocvs_process_file (const char *fileName);
int wrap_merge_is_copy (const char *fileName);
void wrap_fromcvs_process_file (const char *fileName);
void wrap_add_file (const char *file,int temp);
void wrap_add (char *line,int temp);
void wrap_send (void);
#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
void wrap_unparse_rcs_options (char **, int);
#endif
char *expand_path (const char *name, const char *cvsroot, bool formatsafe,
const char *file, int line);
extern List *variable_list;
void variable_set (char *nameval);
int watch (int argc, char **argv);
int edit (int argc, char **argv);
int unedit (int argc, char **argv);
int editors (int argc, char **argv);
int watchers (int argc, char **argv);
int annotate (int argc, char **argv);
int add (int argc, char **argv);
int admin (int argc, char **argv);
int checkout (int argc, char **argv);
int commit (int argc, char **argv);
int diff (int argc, char **argv);
int history (int argc, char **argv);
int import (int argc, char **argv);
int cvslog (int argc, char **argv);
#ifdef AUTH_CLIENT_SUPPORT
#ifdef HAVE_LOGIN
# define login cvs_login
#endif
#ifdef HAVE_LOGOUT
# define logout cvs_logout
#endif
int login (int argc, char **argv);
int logout (int argc, char **argv);
#endif
int patch (int argc, char **argv);
int release (int argc, char **argv);
int cvsremove (int argc, char **argv);
int rtag (int argc, char **argv);
int cvsstatus (int argc, char **argv);
int cvstag (int argc, char **argv);
int version (int argc, char **argv);
unsigned long int lookup_command_attribute (const char *);
#if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
char *scramble (char *str);
char *descramble (char *str);
#endif
#ifdef AUTH_CLIENT_SUPPORT
char *get_cvs_password (void);
int get_cvs_port_number (const cvsroot_t *root);
char *normalize_cvsroot (const cvsroot_t *root)
__attribute__ ((__malloc__));
#endif
void tag_check_valid (const char *, int, char **, int, int, char *, bool);
#include "server.h"
void cvs_output (const char *, size_t);
void cvs_output_binary (char *, size_t);
void cvs_outerr (const char *, size_t);
void cvs_flusherr (void);
void cvs_flushout (void);
void cvs_output_tagged (const char *, const char *);
extern const char *global_session_id;
List *find_files (const char *dir, const char *pat);