Bring cvs-1.12.9 into the CVS repository
[dragonfly.git] / contrib / cvs-1.12.9 / src / server.h
1 /*
2  * Copyright (c) 2003 The Free Software Foundation.
3  *
4  * Portions Copyright (c) 2003 Derek Price
5  *                         and Ximbiot <http://ximbiot.com>,
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  * Expand to `S', ` ', or the empty string.  Used in `%s-> ...' trace printfs.
25  */
26 #ifdef SERVER_SUPPORT
27 # define CLIENT_SERVER_STR ((server_active) ? "S" : " ")
28 #else
29 # define CLIENT_SERVER_STR ""
30 #endif
31
32 #ifdef SERVER_SUPPORT
33
34 /*
35  * Nonzero if we are using the server.  Used by various places to call
36  * server-specific functions.
37  */
38 extern int server_active;
39
40 /* Server functions exported to the rest of CVS.  */
41
42 /* Run the server.  */
43 int server (int argc, char **argv);
44
45 /* kserver user authentication.  */
46 # ifdef HAVE_KERBEROS
47 void kserver_authenticate_connection (void);
48 # endif
49
50 /* pserver user authentication.  */
51 # if defined (AUTH_SERVER_SUPPORT) || defined (HAVE_GSSAPI)
52 void pserver_authenticate_connection (void);
53 # endif
54
55 /* See server.c for description.  */
56 void server_pathname_check (char *);
57
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);
62
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);
66
67 /*
68  * We want to nuke the Entries line for a file, and (unless
69  * server_scratch_entry_only is subsequently called) the file itself.
70  */
71 void server_scratch (const char *name);
72
73 /*
74  * The file which just had server_scratch called on it needs to have only
75  * the Entries line removed, not the file itself.
76  */
77 void server_scratch_entry_only (void);
78
79 /*
80  * We just successfully checked in FILE (which is just the bare
81  * filename, with no directory).  REPOSITORY is the directory for the
82  * repository.
83  */
84 void server_checked_in (const char *file, const char *update_dir,
85                         const char *repository);
86
87 void server_copy_file (const char *file, const char *update_dir,
88                        const char *repository, const char *newfile);
89
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
104 {
105     SERVER_UPDATED,
106     SERVER_MERGED,
107     SERVER_PATCHED,
108     SERVER_RCS_DIFF
109 };
110
111 struct buffer;
112
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);
116
117 /* Whether we should send RCS format patches.  */
118 int server_use_rcs_diff (void);
119
120 /* Set the Entries.Static flag.  */
121 void server_set_entstat (const char *update_dir, const char *repository);
122 /* Clear it.  */
123 void server_clear_entstat (const char *update_dir, const char *repository);
124
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);
128
129 /* Send Clear-template response.  */
130 void server_clear_template (const char *update_dir, const char *repository);
131
132 /* Send Template response.  */
133 void server_template (const char *update_dir, const char *repository);
134
135 void server_update_entries (const char *file, const char *update_dir,
136                             const char *repository,
137                             enum server_updated_arg4 updated);
138
139 /* Pointer to a malloc'd string which is the directory which
140    the server should prepend to the pathnames which it sends
141    to the client.  */
142 extern char *server_dir;
143
144 void server_cleanup (void);
145
146 #ifdef SERVER_FLOWCONTROL
147 /* Pause if it's convenient to avoid memory blowout */
148 void server_pause_check (void);
149 #endif /* SERVER_FLOWCONTROL */
150
151 #ifdef AUTH_SERVER_SUPPORT
152 extern char *CVS_Username;
153 extern int system_auth;
154 #endif /* AUTH_SERVER_SUPPORT */
155
156 #endif /* SERVER_SUPPORT */
157 \f
158 /* Stuff shared with the client.  */
159 struct request
160 {
161   /* Name of the request.  */
162   char *name;
163
164 #ifdef SERVER_SUPPORT
165   /*
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.
168    */
169   void (*func) (char *args);
170 #endif
171
172   /* One or more of the RQ_* flags described below.  */
173   int flags;
174
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
178      commands.  */
179 #define RQ_ESSENTIAL 1
180
181   /* Set by the client if the server we are talking to supports it.  */
182 #define RQ_SUPPORTED 2
183
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
187
188   /* The server may accept this request before "Root".  */
189 #define RQ_ROOTLESS 8
190 };
191
192 /* Table of requests ending with an entry with a NULL name.  */
193 extern struct request requests[];
194
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 *,
198                    int);