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