server.h revision 25839
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/*
33 * We want to nuke the Entries line for a file, and (unless
34 * server_scratch_entry_only is subsequently called) the file itself.
35 */
36extern void server_scratch PROTO((char *name));
37
38/*
39 * The file which just had server_scratch called on it needs to have only
40 * the Entries line removed, not the file itself.
41 */
42extern void server_scratch_entry_only PROTO((void));
43
44/*
45 * We just successfully checked in FILE (which is just the bare
46 * filename, with no directory).  REPOSITORY is the directory for the
47 * repository.
48 */
49extern void server_checked_in
50    PROTO((char *file, char *update_dir, char *repository));
51
52extern void server_copy_file
53    PROTO((char *file, char *update_dir, char *repository, char *newfile));
54
55/* Send the appropriate responses for a file described by FILE,
56   UPDATE_DIR, REPOSITORY, and VERS.  FILE_INFO is the result of
57   statting the file, or NULL if it hasn't been statted yet.  This is
58   called after server_register or server_scratch.  In the latter case
59   the file is to be removed (and vers can be NULL).  In the former
60   case, vers must be non-NULL, and UPDATED indicates whether the file
61   is now up to date (SERVER_UPDATED, yes, SERVER_MERGED, no,
62   SERVER_PATCHED, yes, but file is a diff from user version to
63   repository version, SERVER_RCS_DIFF, yes, like SERVER_PATCHED but
64   with an RCS style diff).  */
65enum server_updated_arg4
66{
67    SERVER_UPDATED,
68    SERVER_MERGED,
69    SERVER_PATCHED,
70    SERVER_RCS_DIFF
71};
72extern void server_updated
73    PROTO((struct file_info *finfo, Vers_TS *vers,
74	   enum server_updated_arg4 updated, struct stat *,
75	   unsigned char *checksum));
76
77/* Whether we should send RCS format patches.  */
78extern int server_use_rcs_diff PROTO((void));
79
80/* Set the Entries.Static flag.  */
81extern void server_set_entstat PROTO((char *update_dir, char *repository));
82/* Clear it.  */
83extern void server_clear_entstat PROTO((char *update_dir, char *repository));
84
85/* Set or clear a per-directory sticky tag or date.  */
86extern void server_set_sticky PROTO((char *update_dir, char *repository,
87				     char *tag, char *date, int nonbranch));
88/* Send Template response.  */
89extern void server_template PROTO ((char *, char *));
90
91extern void server_update_entries
92    PROTO((char *file, char *update_dir, char *repository,
93	   enum server_updated_arg4 updated));
94
95/* Pointer to a malloc'd string which is the directory which
96   the server should prepend to the pathnames which it sends
97   to the client.  */
98extern char *server_dir;
99
100enum progs {PROG_CHECKIN, PROG_UPDATE};
101extern void server_prog PROTO((char *, char *, enum progs));
102extern void server_cleanup PROTO((int sig));
103
104#ifdef SERVER_FLOWCONTROL
105/* Pause if it's convenient to avoid memory blowout */
106extern void server_pause_check PROTO((void));
107#endif /* SERVER_FLOWCONTROL */
108
109#endif /* SERVER_SUPPORT */
110
111/* Stuff shared with the client.  */
112struct request
113{
114  /* Name of the request.  */
115  char *name;
116
117#ifdef SERVER_SUPPORT
118  /*
119   * Function to carry out the request.  ARGS is the text of the command
120   * after name and, if present, a single space, have been stripped off.
121   */
122  void (*func) PROTO((char *args));
123#endif
124
125  /* Stuff for use by the client.  */
126  enum {
127      /*
128       * Failure to implement this request can imply a fatal
129       * error.  This should be set only for commands which were in the
130       * original version of the protocol; it should not be set for new
131       * commands.
132       */
133      rq_essential,
134
135      /* Some servers might lack this request.  */
136      rq_optional,
137
138      /*
139       * Set by the client to one of the following based on what this
140       * server actually supports.
141       */
142      rq_supported,
143      rq_not_supported,
144
145      /*
146       * If the server supports this request, and we do too, tell the
147       * server by making the request.
148       */
149      rq_enableme
150      } status;
151};
152
153/* Table of requests ending with an entry with a NULL name.  */
154extern struct request requests[];
155