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