2 * Copyright (c) 2003 The Free Software Foundation.
4 * Portions Copyright (c) 2003 Derek Price
5 * and 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 * Expand to `S', ` ', or the empty string. Used in `%s-> ...' trace printfs.
27 # define CLIENT_SERVER_STR ((server_active) ? "S" : " ")
29 # define CLIENT_SERVER_STR ""
35 * Nonzero if we are using the server. Used by various places to call
36 * server-specific functions.
38 extern int server_active;
40 /* Server functions exported to the rest of CVS. */
43 int server (int argc, char **argv);
45 /* kserver user authentication. */
47 void kserver_authenticate_connection (void);
50 /* pserver user authentication. */
51 # if defined (AUTH_SERVER_SUPPORT) || defined (HAVE_GSSAPI)
52 void pserver_authenticate_connection (void);
55 /* See server.c for description. */
56 void server_pathname_check (char *);
58 /* We have a new Entries line for a file. TAG or DATE can be NULL. */
59 void server_register (const char *name, const char *version,
60 const char *timestamp, const char *options,
61 const char *tag, const char *date, const char *conflict);
63 /* Set the modification time of the next file sent. This must be
64 followed by a call to server_updated on the same file. */
65 void server_modtime (struct file_info *finfo, Vers_TS *vers_ts);
68 * We want to nuke the Entries line for a file, and (unless
69 * server_scratch_entry_only is subsequently called) the file itself.
71 void server_scratch (const char *name);
74 * The file which just had server_scratch called on it needs to have only
75 * the Entries line removed, not the file itself.
77 void server_scratch_entry_only (void);
80 * We just successfully checked in FILE (which is just the bare
81 * filename, with no directory). REPOSITORY is the directory for the
84 void server_checked_in (const char *file, const char *update_dir,
85 const char *repository);
87 void server_copy_file (const char *file, const char *update_dir,
88 const char *repository, const char *newfile);
90 /* Send the appropriate responses for a file described by FINFO and
91 VERS. This is called after server_register or server_scratch. In
92 the latter case the file is to be removed (and VERS can be NULL).
93 In the former case, VERS must be non-NULL, and UPDATED indicates
94 whether the file is now up to date (SERVER_UPDATED, yes,
95 SERVER_MERGED, no, SERVER_PATCHED, yes, but file is a diff from
96 user version to repository version, SERVER_RCS_DIFF, yes, like
97 SERVER_PATCHED but with an RCS style diff). MODE is the mode the
98 file should get, or (mode_t) -1 if this should be obtained from the
99 file itself. CHECKSUM is the MD5 checksum of the file, or NULL if
100 this need not be sent. If FILEBUF is not NULL, it holds the
101 contents of the file, in which case the file itself may not exist.
102 If FILEBUF is not NULL, server_updated will free it. */
103 enum server_updated_arg4
113 void server_updated (struct file_info *finfo, Vers_TS *vers,
114 enum server_updated_arg4 updated, mode_t mode,
115 unsigned char *checksum, struct buffer *filebuf);
117 /* Whether we should send RCS format patches. */
118 int server_use_rcs_diff (void);
120 /* Set the Entries.Static flag. */
121 void server_set_entstat (const char *update_dir, const char *repository);
123 void server_clear_entstat (const char *update_dir, const char *repository);
125 /* Set or clear a per-directory sticky tag or date. */
126 void server_set_sticky (const char *update_dir, const char *repository,
127 const char *tag, const char *date, int nonbranch);
129 /* Send Clear-template response. */
130 void server_clear_template (const char *update_dir, const char *repository);
132 /* Send Template response. */
133 void server_template (const char *update_dir, const char *repository);
135 void server_update_entries (const char *file, const char *update_dir,
136 const char *repository,
137 enum server_updated_arg4 updated);
139 /* Pointer to a malloc'd string which is the directory which
140 the server should prepend to the pathnames which it sends
142 extern char *server_dir;
144 void server_cleanup (void);
146 #ifdef SERVER_FLOWCONTROL
147 /* Pause if it's convenient to avoid memory blowout */
148 void server_pause_check (void);
149 #endif /* SERVER_FLOWCONTROL */
151 #ifdef AUTH_SERVER_SUPPORT
152 extern char *CVS_Username;
153 extern int system_auth;
154 #endif /* AUTH_SERVER_SUPPORT */
156 #endif /* SERVER_SUPPORT */
158 /* Stuff shared with the client. */
161 /* Name of the request. */
164 #ifdef SERVER_SUPPORT
166 * Function to carry out the request. ARGS is the text of the command
167 * after name and, if present, a single space, have been stripped off.
169 void (*func) (char *args);
172 /* One or more of the RQ_* flags described below. */
175 /* If set, failure to implement this request can imply a fatal
176 error. This should be set only for commands which were in the
177 original version of the protocol; it should not be set for new
179 #define RQ_ESSENTIAL 1
181 /* Set by the client if the server we are talking to supports it. */
182 #define RQ_SUPPORTED 2
184 /* If set, and client and server both support the request, the
185 client should tell the server by making the request. */
186 #define RQ_ENABLEME 4
188 /* The server may accept this request before "Root". */
189 #define RQ_ROOTLESS 8
192 /* Table of requests ending with an entry with a NULL name. */
193 extern struct request requests[];
195 /* Gzip library, see zlib.c. */
196 int gunzip_and_write (int, char *, unsigned char *, size_t);
197 int read_and_gzip (int, const char *, unsigned char **, size_t *, size_t *,