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