1175261Sobrien/* 2177391Sobrien * Copyright (C) 1994-2008 The Free Software Foundation, Inc. 3175261Sobrien * 4175261Sobrien * This program is free software; you can redistribute it and/or modify 5175261Sobrien * it under the terms of the GNU General Public License as published by 6175261Sobrien * the Free Software Foundation; either version 2, or (at your option) 7175261Sobrien * any later version. 8175261Sobrien * 9175261Sobrien * This program is distributed in the hope that it will be useful, 10175261Sobrien * but WITHOUT ANY WARRANTY; without even the implied warranty of 11175261Sobrien * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12175261Sobrien * GNU General Public License for more details. 13175261Sobrien */ 14175261Sobrien 1517721Speter/* Interface between the client and the rest of CVS. */ 1617721Speter 1717721Speter/* Stuff shared with the server. */ 1817721Speterextern char *mode_to_string PROTO((mode_t)); 1934461Speterextern int change_mode PROTO((char *, char *, int)); 2017721Speter 2117721Speterextern int gzip_level; 2225839Speterextern int file_gzip_level; 2317721Speter 2425839Speter#if defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT) 2517721Speter 2632785Speter/* Whether the connection should be encrypted. */ 2725839Speterextern int cvsencrypt; 2817721Speter 2932785Speter/* Whether the connection should use per-packet authentication. */ 3032785Speterextern int cvsauthenticate; 3132785Speter 32102840Speter#ifdef __STDC__ 33102840Speterstruct buffer; 34102840Speter#endif 3532785Speter 36102840Speter# ifdef ENCRYPTION 3725839Speter 38102840Speter# ifdef HAVE_KERBEROS 39102840Speter 4025839Speter/* We can't declare the arguments without including krb.h, and I don't 4125839Speter want to do that in every file. */ 4225839Speterextern struct buffer *krb_encrypt_buffer_initialize (); 4325839Speter 44102840Speter# endif /* HAVE_KERBEROS */ 4532785Speter 46102840Speter# ifdef HAVE_GSSAPI 4732785Speter 4832785Speter/* Set this to turn on GSSAPI encryption. */ 4932785Speterextern int cvs_gssapi_encrypt; 5032785Speter 51102840Speter# endif /* HAVE_GSSAPI */ 5232785Speter 53102840Speter# endif /* ENCRYPTION */ 5425839Speter 55102840Speter# ifdef HAVE_GSSAPI 5632785Speter 5732785Speter/* We can't declare the arguments without including gssapi.h, and I 5832785Speter don't want to do that in every file. */ 5932785Speterextern struct buffer *cvs_gssapi_wrap_buffer_initialize (); 6032785Speter 61102840Speter# endif /* HAVE_GSSAPI */ 6232785Speter 6325839Speter#endif /* defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT) */ 6425839Speter 6525839Speter#ifdef CLIENT_SUPPORT 6617721Speter/* 6717721Speter * Flag variable for seeing whether the server has been started yet. 68177391Sobrien * As of this writing, only edit.c:cvs_notify_check() uses it. 6917721Speter */ 7017721Speterextern int server_started; 7117721Speter 7217721Speter/* Is the -P option to checkout or update specified? */ 7317721Speterextern int client_prune_dirs; 7417721Speter 75102840Speter# ifdef AUTH_CLIENT_SUPPORT 7617721Speterextern int use_authenticating_server; 77128266Speter# endif /* AUTH_CLIENT_SUPPORT */ 78128266Speter# if defined (AUTH_CLIENT_SUPPORT) || defined (HAVE_GSSAPI) 79102840Spetervoid connect_to_pserver PROTO ((cvsroot_t *, 80102840Speter struct buffer **, 81102840Speter struct buffer **, 82102840Speter int, int )); 83102840Speter# ifndef CVS_AUTH_PORT 84102840Speter# define CVS_AUTH_PORT 2401 85102840Speter# endif /* CVS_AUTH_PORT */ 86128266Speter# endif /* (AUTH_CLIENT_SUPPORT) || defined (HAVE_GSSAPI) */ 8717721Speter 88102840Speter# if HAVE_KERBEROS 89102840Speter# ifndef CVS_PORT 90102840Speter# define CVS_PORT 1999 91102840Speter# endif 92102840Speter# endif /* HAVE_KERBEROS */ 93102840Speter 9417721Speter/* Talking to the server. */ 95128266Spetervoid send_to_server PROTO((const char *str, size_t len)); 9617721Spetervoid read_from_server PROTO((char *buf, size_t len)); 9717721Speter 9817721Speter/* Internal functions that handle client communication to server, etc. */ 9917721Speterint supported_request PROTO ((char *)); 10017721Spetervoid option_with_arg PROTO((char *option, char *arg)); 10117721Speter 10217721Speter/* Get the responses and then close the connection. */ 10317721Speterextern int get_responses_and_close PROTO((void)); 10417721Speter 10517721Speterextern int get_server_responses PROTO((void)); 10617721Speter 10717721Speter/* Start up the connection to the server on the other end. */ 10817721Spetervoid 10917721Speterstart_server PROTO((void)); 11017721Speter 11117721Speter/* Send the names of all the argument files to the server. */ 11217721Spetervoid 11317721Spetersend_file_names PROTO((int argc, char **argv, unsigned int flags)); 11417721Speter 11517721Speter/* Flags for send_file_names. */ 11617721Speter/* Expand wild cards? */ 117102840Speter# define SEND_EXPAND_WILD 1 11817721Speter 11917721Speter/* 12017721Speter * Send Repository, Modified and Entry. argc and argv contain only 12117721Speter * the files to operate on (or empty for everything), not options. 12217721Speter * local is nonzero if we should not recurse (-l option). 12317721Speter */ 12417721Spetervoid 12525839Spetersend_files PROTO((int argc, char **argv, int local, int aflag, 12625839Speter unsigned int flags)); 12717721Speter 12825839Speter/* Flags for send_files. */ 129102840Speter# define SEND_BUILD_DIRS 1 130102840Speter# define SEND_FORCE 2 131102840Speter# define SEND_NO_CONTENTS 4 132102840Speter# define BACKUP_MODIFIED_FILES 8 13317721Speter 13417721Speter/* Send an argument to the remote server. */ 13517721Spetervoid 136175261Sobriensend_arg PROTO((const char *string)); 13717721Speter 13817721Speter/* Send a string of single-char options to the remote server, one by one. */ 139175261Sobrienvoid send_options PROTO ((int argc, char * const *argv)); 14017721Speter 141128266Speterextern void send_a_repository PROTO ((const char *, const char *, 142128266Speter const char *)); 14332785Speter 14417721Speter#endif /* CLIENT_SUPPORT */ 14517721Speter 14617721Speter/* 14717721Speter * This structure is used to catalog the responses the client is 14817721Speter * prepared to see from the server. 14917721Speter */ 15017721Speter 15117721Speterstruct response 15217721Speter{ 15317721Speter /* Name of the response. */ 15417721Speter char *name; 15517721Speter 15617721Speter#ifdef CLIENT_SUPPORT 15717721Speter /* 15817721Speter * Function to carry out the response. ARGS is the text of the 15917721Speter * command after name and, if present, a single space, have been 16017721Speter * stripped off. The function can scribble into ARGS if it wants. 16132896Speter * Note that although LEN is given, ARGS is also guaranteed to be 16232896Speter * '\0' terminated. 16317721Speter */ 16417721Speter void (*func) PROTO((char *args, int len)); 16517721Speter 16617721Speter /* 16717721Speter * ok and error are special; they indicate we are at the end of the 16817721Speter * responses, and error indicates we should exit with nonzero 16917721Speter * exitstatus. 17017721Speter */ 17117721Speter enum {response_type_normal, response_type_ok, response_type_error} type; 17217721Speter#endif 17317721Speter 17417721Speter /* Used by the server to indicate whether response is supported by 17517721Speter the client, as set by the Valid-responses request. */ 17617721Speter enum { 17717721Speter /* 17817721Speter * Failure to implement this response can imply a fatal 17917721Speter * error. This should be set only for responses which were in the 18017721Speter * original version of the protocol; it should not be set for new 18117721Speter * responses. 18217721Speter */ 18317721Speter rs_essential, 18417721Speter 18517721Speter /* Some clients might not understand this response. */ 18617721Speter rs_optional, 18717721Speter 18817721Speter /* 18917721Speter * Set by the server to one of the following based on what this 19017721Speter * client actually supports. 19117721Speter */ 19217721Speter rs_supported, 19317721Speter rs_not_supported 19417721Speter } status; 19517721Speter}; 19617721Speter 19717721Speter/* Table of responses ending in an entry with a NULL name. */ 19817721Speter 19917721Speterextern struct response responses[]; 20017721Speter 20117721Speter#ifdef CLIENT_SUPPORT 20217721Speter 20317721Speterextern void client_senddate PROTO((const char *date)); 20417721Speterextern void client_expand_modules PROTO((int argc, char **argv, int local)); 20525839Speterextern void client_send_expansions PROTO((int local, char *where, 20625839Speter int build_dirs)); 20717721Speterextern void client_nonexpanded_setup PROTO((void)); 20817721Speter 20917721Speterextern void send_init_command PROTO ((void)); 21017721Speter 21117721Speterextern char **failed_patches; 21217721Speterextern int failed_patches_count; 21325839Speterextern char *toplevel_wd; 21417721Speterextern void client_import_setup PROTO((char *repository)); 21517721Speterextern int client_process_import_file 21617721Speter PROTO((char *message, char *vfile, char *vtag, 21754427Speter int targc, char *targv[], char *repository, int all_files_binary, 21854427Speter int modtime)); 21917721Speterextern void client_import_done PROTO((void)); 220128266Speterextern void client_notify PROTO((const char *, const char *, const char *, int, 221128266Speter const char *)); 22217721Speter#endif /* CLIENT_SUPPORT */ 223