2 * Copyright (C) 1986-2005 The Free Software Foundation, Inc.
4 * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>,
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.
12 * This file contains the interface between the server and the rest of CVS.
15 /* Miscellaneous stuff which isn't actually particularly server-specific. */
17 #define STDIN_FILENO 0
18 #define STDOUT_FILENO 1
19 #define STDERR_FILENO 2
24 * Nonzero if we are using the server. Used by various places to call
25 * server-specific functions.
27 extern int server_active;
30 * Expand to `S', ` ', or the empty string. Used in `%s-> ...' trace printfs.
33 # define CLIENT_SERVER_STR ((server_active) ? "S" : " ")
35 # define CLIENT_SERVER_STR ""
40 /* Server functions exported to the rest of CVS. */
43 extern int server PROTO((int argc, char **argv));
45 /* kserver user authentication. */
47 extern void kserver_authenticate_connection PROTO ((void));
50 /* pserver user authentication. */
51 # if defined (AUTH_SERVER_SUPPORT) || defined (HAVE_GSSAPI)
52 extern void pserver_authenticate_connection PROTO ((void));
55 /* See server.c for description. */
56 extern void server_pathname_check PROTO ((char *));
58 /* We have a new Entries line for a file. TAG or DATE can be NULL. */
59 extern 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));
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. */
66 extern void server_modtime PROTO ((struct file_info *finfo,
70 * We want to nuke the Entries line for a file, and (unless
71 * server_scratch_entry_only is subsequently called) the file itself.
73 extern void server_scratch PROTO((const char *name));
76 * The file which just had server_scratch called on it needs to have only
77 * the Entries line removed, not the file itself.
79 extern void server_scratch_entry_only PROTO((void));
82 * We just successfully checked in FILE (which is just the bare
83 * filename, with no directory). REPOSITORY is the directory for the
86 extern void server_checked_in
87 PROTO((const char *file, const char *update_dir, const char *repository));
89 extern void server_copy_file
90 PROTO((const char *file, const char *update_dir, const char *repository,
91 const char *newfile));
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. */
106 enum server_updated_arg4
117 extern 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));
122 /* Whether we should send RCS format patches. */
123 extern int server_use_rcs_diff PROTO((void));
125 /* Set the Entries.Static flag. */
126 extern void server_set_entstat PROTO((const char *update_dir,
127 const char *repository));
129 extern void server_clear_entstat PROTO((const char *update_dir,
130 const char *repository));
132 /* Set or clear a per-directory sticky tag or date. */
133 extern 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. */
137 extern void server_template PROTO ((const char *, const char *));
139 extern void server_update_entries
140 PROTO((const char *file, const char *update_dir, const char *repository,
141 enum server_updated_arg4 updated));
143 /* Pointer to a malloc'd string which is the directory which
144 the server should prepend to the pathnames which it sends
146 extern char *server_dir;
148 extern void server_cleanup PROTO((int sig));
150 #ifdef SERVER_FLOWCONTROL
151 /* Pause if it's convenient to avoid memory blowout */
152 extern void server_pause_check PROTO((void));
153 #endif /* SERVER_FLOWCONTROL */
155 #ifdef AUTH_SERVER_SUPPORT
156 extern char *CVS_Username;
157 extern int system_auth;
158 #endif /* AUTH_SERVER_SUPPORT */
160 #endif /* SERVER_SUPPORT */
162 /* Stuff shared with the client. */
165 /* Name of the request. */
168 #ifdef SERVER_SUPPORT
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.
173 void (*func) PROTO((char *args));
176 /* One or more of the RQ_* flags described below. */
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
183 #define RQ_ESSENTIAL 1
185 /* Set by the client if the server we are talking to supports it. */
186 #define RQ_SUPPORTED 2
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
192 /* The server may accept this request before "Root". */
193 #define RQ_ROOTLESS 8
196 /* Table of requests ending with an entry with a NULL name. */
197 extern struct request requests[];
199 /* Gzip library, see zlib.c. */
200 extern int gunzip_and_write PROTO ((int, char *, unsigned char *, size_t));
201 extern int read_and_gzip PROTO ((int, const char *, unsigned char **, size_t *,