server.h revision 54427
1/* Interface between the server and the rest of CVS. */ 2 3/* Miscellaneous stuff which isn't actually particularly server-specific. */ 4#ifndef STDIN_FILENO 5#define STDIN_FILENO 0 6#define STDOUT_FILENO 1 7#define STDERR_FILENO 2 8#endif 9 10 11/* 12 * Expand to `S', ` ', or the empty string. Used in `%s-> ...' trace printfs. 13 */ 14#ifdef SERVER_SUPPORT 15# define CLIENT_SERVER_STR ((server_active) ? "S" : " ") 16#else 17# define CLIENT_SERVER_STR "" 18#endif 19 20#ifdef SERVER_SUPPORT 21 22/* 23 * Nonzero if we are using the server. Used by various places to call 24 * server-specific functions. 25 */ 26extern int server_active; 27extern int server_expanding; 28 29/* Server functions exported to the rest of CVS. */ 30 31/* Run the server. */ 32extern int server PROTO((int argc, char **argv)); 33 34/* See server.c for description. */ 35extern void server_pathname_check PROTO ((char *)); 36 37/* We have a new Entries line for a file. TAG or DATE can be NULL. */ 38extern void server_register 39 PROTO((char *name, char *version, char *timestamp, 40 char *options, char *tag, char *date, char *conflict)); 41 42/* Set the modification time of the next file sent. This must be 43 followed by a call to server_updated on the same file. */ 44extern void server_modtime PROTO ((struct file_info *finfo, 45 Vers_TS *vers_ts)); 46 47/* 48 * We want to nuke the Entries line for a file, and (unless 49 * server_scratch_entry_only is subsequently called) the file itself. 50 */ 51extern void server_scratch PROTO((char *name)); 52 53/* 54 * The file which just had server_scratch called on it needs to have only 55 * the Entries line removed, not the file itself. 56 */ 57extern void server_scratch_entry_only PROTO((void)); 58 59/* 60 * We just successfully checked in FILE (which is just the bare 61 * filename, with no directory). REPOSITORY is the directory for the 62 * repository. 63 */ 64extern void server_checked_in 65 PROTO((char *file, char *update_dir, char *repository)); 66 67extern void server_copy_file 68 PROTO((char *file, char *update_dir, char *repository, char *newfile)); 69 70/* Send the appropriate responses for a file described by FINFO and 71 VERS. This is called after server_register or server_scratch. In 72 the latter case the file is to be removed (and VERS can be NULL). 73 In the former case, VERS must be non-NULL, and UPDATED indicates 74 whether the file is now up to date (SERVER_UPDATED, yes, 75 SERVER_MERGED, no, SERVER_PATCHED, yes, but file is a diff from 76 user version to repository version, SERVER_RCS_DIFF, yes, like 77 SERVER_PATCHED but with an RCS style diff). MODE is the mode the 78 file should get, or (mode_t) -1 if this should be obtained from the 79 file itself. CHECKSUM is the MD5 checksum of the file, or NULL if 80 this need not be sent. If FILEBUF is not NULL, it holds the 81 contents of the file, in which case the file itself may not exist. 82 If FILEBUF is not NULL, server_updated will free it. */ 83enum server_updated_arg4 84{ 85 SERVER_UPDATED, 86 SERVER_MERGED, 87 SERVER_PATCHED, 88 SERVER_RCS_DIFF 89}; 90#ifdef __STDC__ 91struct buffer; 92#endif 93 94extern void server_updated 95 PROTO((struct file_info *finfo, Vers_TS *vers, 96 enum server_updated_arg4 updated, mode_t mode, 97 unsigned char *checksum, struct buffer *filebuf)); 98 99/* Whether we should send RCS format patches. */ 100extern int server_use_rcs_diff PROTO((void)); 101 102/* Set the Entries.Static flag. */ 103extern void server_set_entstat PROTO((char *update_dir, char *repository)); 104/* Clear it. */ 105extern void server_clear_entstat PROTO((char *update_dir, char *repository)); 106 107/* Set or clear a per-directory sticky tag or date. */ 108extern void server_set_sticky PROTO((char *update_dir, char *repository, 109 char *tag, char *date, int nonbranch)); 110/* Send Template response. */ 111extern void server_template PROTO ((char *, char *)); 112 113extern void server_update_entries 114 PROTO((char *file, char *update_dir, char *repository, 115 enum server_updated_arg4 updated)); 116 117/* Pointer to a malloc'd string which is the directory which 118 the server should prepend to the pathnames which it sends 119 to the client. */ 120extern char *server_dir; 121 122enum progs {PROG_CHECKIN, PROG_UPDATE}; 123extern void server_prog PROTO((char *, char *, enum progs)); 124extern void server_cleanup PROTO((int sig)); 125 126#ifdef SERVER_FLOWCONTROL 127/* Pause if it's convenient to avoid memory blowout */ 128extern void server_pause_check PROTO((void)); 129#endif /* SERVER_FLOWCONTROL */ 130 131#ifdef AUTH_SERVER_SUPPORT 132extern char *CVS_Username; 133extern int system_auth; 134#endif /* AUTH_SERVER_SUPPORT */ 135 136#endif /* SERVER_SUPPORT */ 137 138/* Stuff shared with the client. */ 139struct request 140{ 141 /* Name of the request. */ 142 char *name; 143 144#ifdef SERVER_SUPPORT 145 /* 146 * Function to carry out the request. ARGS is the text of the command 147 * after name and, if present, a single space, have been stripped off. 148 */ 149 void (*func) PROTO((char *args)); 150#endif 151 152 /* One or more of the RQ_* flags described below. */ 153 int flags; 154 155 /* If set, failure to implement this request can imply a fatal 156 error. This should be set only for commands which were in the 157 original version of the protocol; it should not be set for new 158 commands. */ 159#define RQ_ESSENTIAL 1 160 161 /* Set by the client if the server we are talking to supports it. */ 162#define RQ_SUPPORTED 2 163 164 /* If set, and client and server both support the request, the 165 client should tell the server by making the request. */ 166#define RQ_ENABLEME 4 167 168 /* The server may accept this request before "Root". */ 169#define RQ_ROOTLESS 8 170}; 171 172/* Table of requests ending with an entry with a NULL name. */ 173extern struct request requests[]; 174 175/* Gzip library, see zlib.c. */ 176extern int gunzip_and_write PROTO ((int, char *, unsigned char *, size_t)); 177extern int read_and_gzip PROTO ((int, char *, unsigned char **, size_t *, 178 size_t *, int)); 179