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