server.h revision 54427
126159Sse/* Interface between the server and the rest of CVS.  */
226159Sse
326159Sse/* Miscellaneous stuff which isn't actually particularly server-specific.  */
426159Sse#ifndef STDIN_FILENO
526159Sse#define STDIN_FILENO 0
626159Sse#define STDOUT_FILENO 1
726159Sse#define STDERR_FILENO 2
826159Sse#endif
926159Sse
1026159Sse
1126159Sse/*
1226159Sse * Expand to `S', ` ', or the empty string.  Used in `%s-> ...' trace printfs.
1326159Sse */
1426159Sse#ifdef SERVER_SUPPORT
1526159Sse# define CLIENT_SERVER_STR ((server_active) ? "S" : " ")
1626159Sse#else
1726159Sse# define CLIENT_SERVER_STR ""
1826159Sse#endif
1926159Sse
2026159Sse#ifdef SERVER_SUPPORT
2126159Sse
2226159Sse/*
2326159Sse * Nonzero if we are using the server.  Used by various places to call
2426159Sse * server-specific functions.
2526159Sse */
2650477Speterextern int server_active;
2726159Sseextern int server_expanding;
2826159Sse
296100Sse/* Server functions exported to the rest of CVS.  */
3039231Sgibbs
3139231Sgibbs/* Run the server.  */
3239231Sgibbsextern int server PROTO((int argc, char **argv));
3339231Sgibbs
3439231Sgibbs/* See server.c for description.  */
3526159Sseextern void server_pathname_check PROTO ((char *));
366767Sse
3726159Sse/* We have a new Entries line for a file.  TAG or DATE can be NULL.  */
3826159Sseextern void server_register
3926159Sse    PROTO((char *name, char *version, char *timestamp,
4026159Sse	     char *options, char *tag, char *date, char *conflict));
416100Sse
4226159Sse/* Set the modification time of the next file sent.  This must be
4326159Sse   followed by a call to server_updated on the same file.  */
4426159Sseextern void server_modtime PROTO ((struct file_info *finfo,
456100Sse				   Vers_TS *vers_ts));
4626159Sse
476100Sse/*
4826159Sse * We want to nuke the Entries line for a file, and (unless
4926159Sse * server_scratch_entry_only is subsequently called) the file itself.
5026159Sse */
5126159Sseextern void server_scratch PROTO((char *name));
5226159Sse
536100Sse/*
5426159Sse * The file which just had server_scratch called on it needs to have only
556100Sse * the Entries line removed, not the file itself.
5626159Sse */
5745720Speterextern void server_scratch_entry_only PROTO((void));
586100Sse
5926159Sse/*
6026159Sse * We just successfully checked in FILE (which is just the bare
6126159Sse * filename, with no directory).  REPOSITORY is the directory for the
6226159Sse * repository.
636100Sse */
6426159Sseextern void server_checked_in
6526159Sse    PROTO((char *file, char *update_dir, char *repository));
667233Sse
6738304Sgibbsextern void server_copy_file
6826159Sse    PROTO((char *file, char *update_dir, char *repository, char *newfile));
6926159Sse
7026159Sse/* Send the appropriate responses for a file described by FINFO and
716100Sse   VERS.  This is called after server_register or server_scratch.  In
7226159Sse   the latter case the file is to be removed (and VERS can be NULL).
7326159Sse   In the former case, VERS must be non-NULL, and UPDATED indicates
7426159Sse   whether the file is now up to date (SERVER_UPDATED, yes,
7526159Sse   SERVER_MERGED, no, SERVER_PATCHED, yes, but file is a diff from
766100Sse   user version to repository version, SERVER_RCS_DIFF, yes, like
7726159Sse   SERVER_PATCHED but with an RCS style diff).  MODE is the mode the
7826159Sse   file should get, or (mode_t) -1 if this should be obtained from the
7926159Sse   file itself.  CHECKSUM is the MD5 checksum of the file, or NULL if
806100Sse   this need not be sent.  If FILEBUF is not NULL, it holds the
8126159Sse   contents of the file, in which case the file itself may not exist.
8226159Sse   If FILEBUF is not NULL, server_updated will free it.  */
837233Sseenum server_updated_arg4
8426159Sse{
8526159Sse    SERVER_UPDATED,
8626159Sse    SERVER_MERGED,
877233Sse    SERVER_PATCHED,
8869953Smsmith    SERVER_RCS_DIFF
8969953Smsmith};
9069953Smsmith#ifdef __STDC__
9169953Smsmithstruct buffer;
9269953Smsmith#endif
9326159Sse
946100Sseextern void server_updated
9526159Sse    PROTO((struct file_info *finfo, Vers_TS *vers,
966100Sse	   enum server_updated_arg4 updated, mode_t mode,
9726159Sse	   unsigned char *checksum, struct buffer *filebuf));
9826159Sse
9926159Sse/* Whether we should send RCS format patches.  */
10026159Sseextern int server_use_rcs_diff PROTO((void));
10126159Sse
10226159Sse/* Set the Entries.Static flag.  */
10326159Sseextern void server_set_entstat PROTO((char *update_dir, char *repository));
1046100Sse/* Clear it.  */
10526159Sseextern void server_clear_entstat PROTO((char *update_dir, char *repository));
10626159Sse
1077233Sse/* Set or clear a per-directory sticky tag or date.  */
10826159Sseextern void server_set_sticky PROTO((char *update_dir, char *repository,
10926159Sse				     char *tag, char *date, int nonbranch));
11026159Sse/* Send Template response.  */
11126159Sseextern void server_template PROTO ((char *, char *));
11226159Sse
11326159Sseextern void server_update_entries
11426159Sse    PROTO((char *file, char *update_dir, char *repository,
11526159Sse	   enum server_updated_arg4 updated));
11626159Sse
11726159Sse/* Pointer to a malloc'd string which is the directory which
11826159Sse   the server should prepend to the pathnames which it sends
1196100Sse   to the client.  */
12026159Sseextern char *server_dir;
12126159Sse
12226159Sseenum progs {PROG_CHECKIN, PROG_UPDATE};
12326159Sseextern void server_prog PROTO((char *, char *, enum progs));
12426159Sseextern void server_cleanup PROTO((int sig));
12526159Sse
12626159Sse#ifdef SERVER_FLOWCONTROL
12726159Sse/* Pause if it's convenient to avoid memory blowout */
12826159Sseextern void server_pause_check PROTO((void));
12926159Sse#endif /* SERVER_FLOWCONTROL */
13026159Sse
13126159Sse#ifdef AUTH_SERVER_SUPPORT
13226159Sseextern char *CVS_Username;
13326159Sseextern int system_auth;
13426159Sse#endif /* AUTH_SERVER_SUPPORT */
13526159Sse
13626159Sse#endif /* SERVER_SUPPORT */
13739231Sgibbs
13839231Sgibbs/* Stuff shared with the client.  */
13961047Speterstruct request
14061047Speter{
14161047Speter  /* Name of the request.  */
14261047Speter  char *name;
14361047Speter
14461047Speter#ifdef SERVER_SUPPORT
14561047Speter  /*
14661047Speter   * Function to carry out the request.  ARGS is the text of the command
14761047Speter   * after name and, if present, a single space, have been stripped off.
14839231Sgibbs   */
14940004Sdfr  void (*func) PROTO((char *args));
15040004Sdfr#endif
15140004Sdfr
15240004Sdfr  /* One or more of the RQ_* flags described below.  */
15345720Speter  int flags;
15445720Speter
15545720Speter  /* If set, failure to implement this request can imply a fatal
15645720Speter     error.  This should be set only for commands which were in the
15745720Speter     original version of the protocol; it should not be set for new
15852243Sdfr     commands.  */
15952243Sdfr#define RQ_ESSENTIAL 1
16052243Sdfr
16152243Sdfr  /* Set by the client if the server we are talking to supports it.  */
16252243Sdfr#define RQ_SUPPORTED 2
16352243Sdfr
16452243Sdfr  /* If set, and client and server both support the request, the
16545720Speter     client should tell the server by making the request.  */
16669953Smsmith#define RQ_ENABLEME 4
16769953Smsmith
16869953Smsmith  /* The server may accept this request before "Root".  */
16969953Smsmith#define RQ_ROOTLESS 8
17069953Smsmith};
17169953Smsmith
17269953Smsmith/* Table of requests ending with an entry with a NULL name.  */
17369953Smsmithextern struct request requests[];
17469953Smsmith
17569953Smsmith/* Gzip library, see zlib.c.  */
17669953Smsmithextern int gunzip_and_write PROTO ((int, char *, unsigned char *, size_t));
17769953Smsmithextern int read_and_gzip PROTO ((int, char *, unsigned char **, size_t *,
17869953Smsmith				 size_t *, int));
17969953Smsmith