1/* 2 * Copyright (C) 1994-2008 The Free Software Foundation, Inc. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2, or (at your option) 7 * any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 */ 14 15/* Interface between the client and the rest of CVS. */ 16 17/* Stuff shared with the server. */ 18extern char *mode_to_string PROTO((mode_t)); 19extern int change_mode PROTO((char *, char *, int)); 20 21extern int gzip_level; 22extern int file_gzip_level; 23 24#if defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT) 25 26/* Whether the connection should be encrypted. */ 27extern int cvsencrypt; 28 29/* Whether the connection should use per-packet authentication. */ 30extern int cvsauthenticate; 31 32#ifdef __STDC__ 33struct buffer; 34#endif 35 36# ifdef ENCRYPTION 37 38# ifdef HAVE_KERBEROS 39 40/* We can't declare the arguments without including krb.h, and I don't 41 want to do that in every file. */ 42extern struct buffer *krb_encrypt_buffer_initialize (); 43 44# endif /* HAVE_KERBEROS */ 45 46# ifdef HAVE_GSSAPI 47 48/* Set this to turn on GSSAPI encryption. */ 49extern int cvs_gssapi_encrypt; 50 51# endif /* HAVE_GSSAPI */ 52 53# endif /* ENCRYPTION */ 54 55# ifdef HAVE_GSSAPI 56 57/* We can't declare the arguments without including gssapi.h, and I 58 don't want to do that in every file. */ 59extern struct buffer *cvs_gssapi_wrap_buffer_initialize (); 60 61# endif /* HAVE_GSSAPI */ 62 63#endif /* defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT) */ 64 65#ifdef CLIENT_SUPPORT 66/* 67 * Flag variable for seeing whether the server has been started yet. 68 * As of this writing, only edit.c:cvs_notify_check() uses it. 69 */ 70extern int server_started; 71 72/* Is the -P option to checkout or update specified? */ 73extern int client_prune_dirs; 74 75# ifdef AUTH_CLIENT_SUPPORT 76extern int use_authenticating_server; 77# endif /* AUTH_CLIENT_SUPPORT */ 78# if defined (AUTH_CLIENT_SUPPORT) || defined (HAVE_GSSAPI) 79void connect_to_pserver PROTO ((cvsroot_t *, 80 struct buffer **, 81 struct buffer **, 82 int, int )); 83# ifndef CVS_AUTH_PORT 84# define CVS_AUTH_PORT 2401 85# endif /* CVS_AUTH_PORT */ 86# endif /* (AUTH_CLIENT_SUPPORT) || defined (HAVE_GSSAPI) */ 87 88# if HAVE_KERBEROS 89# ifndef CVS_PORT 90# define CVS_PORT 1999 91# endif 92# endif /* HAVE_KERBEROS */ 93 94/* Talking to the server. */ 95void send_to_server PROTO((const char *str, size_t len)); 96void read_from_server PROTO((char *buf, size_t len)); 97 98/* Internal functions that handle client communication to server, etc. */ 99int supported_request PROTO ((char *)); 100void option_with_arg PROTO((char *option, char *arg)); 101 102/* Get the responses and then close the connection. */ 103extern int get_responses_and_close PROTO((void)); 104 105extern int get_server_responses PROTO((void)); 106 107/* Start up the connection to the server on the other end. */ 108void 109start_server PROTO((void)); 110 111/* Send the names of all the argument files to the server. */ 112void 113send_file_names PROTO((int argc, char **argv, unsigned int flags)); 114 115/* Flags for send_file_names. */ 116/* Expand wild cards? */ 117# define SEND_EXPAND_WILD 1 118 119/* 120 * Send Repository, Modified and Entry. argc and argv contain only 121 * the files to operate on (or empty for everything), not options. 122 * local is nonzero if we should not recurse (-l option). 123 */ 124void 125send_files PROTO((int argc, char **argv, int local, int aflag, 126 unsigned int flags)); 127 128/* Flags for send_files. */ 129# define SEND_BUILD_DIRS 1 130# define SEND_FORCE 2 131# define SEND_NO_CONTENTS 4 132# define BACKUP_MODIFIED_FILES 8 133 134/* Send an argument to the remote server. */ 135void 136send_arg PROTO((const char *string)); 137 138/* Send a string of single-char options to the remote server, one by one. */ 139void send_options PROTO ((int argc, char * const *argv)); 140 141extern void send_a_repository PROTO ((const char *, const char *, 142 const char *)); 143 144#endif /* CLIENT_SUPPORT */ 145 146/* 147 * This structure is used to catalog the responses the client is 148 * prepared to see from the server. 149 */ 150 151struct response 152{ 153 /* Name of the response. */ 154 char *name; 155 156#ifdef CLIENT_SUPPORT 157 /* 158 * Function to carry out the response. ARGS is the text of the 159 * command after name and, if present, a single space, have been 160 * stripped off. The function can scribble into ARGS if it wants. 161 * Note that although LEN is given, ARGS is also guaranteed to be 162 * '\0' terminated. 163 */ 164 void (*func) PROTO((char *args, int len)); 165 166 /* 167 * ok and error are special; they indicate we are at the end of the 168 * responses, and error indicates we should exit with nonzero 169 * exitstatus. 170 */ 171 enum {response_type_normal, response_type_ok, response_type_error} type; 172#endif 173 174 /* Used by the server to indicate whether response is supported by 175 the client, as set by the Valid-responses request. */ 176 enum { 177 /* 178 * Failure to implement this response can imply a fatal 179 * error. This should be set only for responses which were in the 180 * original version of the protocol; it should not be set for new 181 * responses. 182 */ 183 rs_essential, 184 185 /* Some clients might not understand this response. */ 186 rs_optional, 187 188 /* 189 * Set by the server to one of the following based on what this 190 * client actually supports. 191 */ 192 rs_supported, 193 rs_not_supported 194 } status; 195}; 196 197/* Table of responses ending in an entry with a NULL name. */ 198 199extern struct response responses[]; 200 201#ifdef CLIENT_SUPPORT 202 203extern void client_senddate PROTO((const char *date)); 204extern void client_expand_modules PROTO((int argc, char **argv, int local)); 205extern void client_send_expansions PROTO((int local, char *where, 206 int build_dirs)); 207extern void client_nonexpanded_setup PROTO((void)); 208 209extern void send_init_command PROTO ((void)); 210 211extern char **failed_patches; 212extern int failed_patches_count; 213extern char *toplevel_wd; 214extern void client_import_setup PROTO((char *repository)); 215extern int client_process_import_file 216 PROTO((char *message, char *vfile, char *vtag, 217 int targc, char *targv[], char *repository, int all_files_binary, 218 int modtime)); 219extern void client_import_done PROTO((void)); 220extern void client_notify PROTO((const char *, const char *, const char *, int, 221 const char *)); 222#endif /* CLIENT_SUPPORT */ 223