Fix compiler warning due to missing function prototype.
[svn.git] / subversion / libsvn_ra_svn / ra_svn.h
blob69937fde1f3d6f8f263374ba8fc16880247ea4bc
1 /*
2 * ra_svn.h : private declarations for the ra_svn module
4 * ====================================================================
5 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
21 #ifndef RA_SVN_H
22 #define RA_SVN_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
28 #include <apr_network_io.h>
29 #include <apr_file_io.h>
30 #include <apr_thread_proc.h>
31 #include "svn_ra.h"
32 #include "svn_ra_svn.h"
34 /* Callback function that indicates if a svn_ra_svn__stream_t has pending
35 * data.
37 typedef svn_boolean_t (*ra_svn_pending_fn_t)(void *baton);
39 /* Callback function that sets the timeout value for a svn_ra_svn__stream_t. */
40 typedef void (*ra_svn_timeout_fn_t)(void *baton, apr_interval_time_t timeout);
42 /* A stream abstraction for ra_svn.
44 * This is different from svn_stream_t in that it provides timeouts and
45 * the ability to check for pending data.
47 typedef struct svn_ra_svn__stream_st svn_ra_svn__stream_t;
49 /* Handler for blocked writes. */
50 typedef svn_error_t *(*ra_svn_block_handler_t)(svn_ra_svn_conn_t *conn,
51 apr_pool_t *pool,
52 void *baton);
54 /* The size of our per-connection read and write buffers. */
55 #define SVN_RA_SVN__READBUF_SIZE 4096
56 #define SVN_RA_SVN__WRITEBUF_SIZE 4096
58 /* Create forward reference */
59 typedef struct svn_ra_svn__session_baton_t svn_ra_svn__session_baton_t;
61 /* This structure is opaque to the server. The client pokes at the
62 * first few fields during setup and cleanup. */
63 struct svn_ra_svn_conn_st {
64 svn_ra_svn__stream_t *stream;
65 svn_ra_svn__session_baton_t *session;
66 #ifdef SVN_HAVE_SASL
67 /* Although all reads and writes go through the svn_ra_svn__stream_t
68 interface, SASL still needs direct access to the underlying socket
69 for stuff like IP addresses and port numbers. */
70 apr_socket_t *sock;
71 svn_boolean_t encrypted;
72 #endif
73 char read_buf[SVN_RA_SVN__READBUF_SIZE];
74 char *read_ptr;
75 char *read_end;
76 char write_buf[SVN_RA_SVN__WRITEBUF_SIZE];
77 int write_pos;
78 const char *uuid;
79 const char *repos_root;
80 ra_svn_block_handler_t block_handler;
81 void *block_baton;
82 apr_hash_t *capabilities;
83 char *remote_ip;
84 apr_pool_t *pool;
87 struct svn_ra_svn__session_baton_t {
88 apr_pool_t *pool;
89 svn_ra_svn_conn_t *conn;
90 svn_boolean_t is_tunneled;
91 const char *url;
92 const char *user;
93 const char *hostname; /* The remote hostname. */
94 const char *realm_prefix;
95 const char **tunnel_argv;
96 const svn_ra_callbacks2_t *callbacks;
97 void *callbacks_baton;
98 apr_off_t bytes_read, bytes_written; /* apr_off_t's because that's what
99 the callback interface uses */
102 /* Set a callback for blocked writes on conn. This handler may
103 * perform reads on the connection in order to prevent deadlock due to
104 * pipelining. If callback is NULL, the connection goes back to
105 * normal blocking I/O for writes.
107 void svn_ra_svn__set_block_handler(svn_ra_svn_conn_t *conn,
108 ra_svn_block_handler_t callback,
109 void *baton);
111 /* Return true if there is input waiting on conn. */
112 svn_boolean_t svn_ra_svn__input_waiting(svn_ra_svn_conn_t *conn,
113 apr_pool_t *pool);
115 /* CRAM-MD5 client implementation. */
116 svn_error_t *svn_ra_svn__cram_client(svn_ra_svn_conn_t *conn, apr_pool_t *pool,
117 const char *user, const char *password,
118 const char **message);
120 /* Return an error chain based on @a params (which contains a
121 * command response indicating failure). The error chain will be
122 * in the same order as the errors indicated in @a params. Use
123 * @a pool for temporary allocations. */
124 svn_error_t *svn_ra_svn__handle_failure_status(apr_array_header_t *params,
125 apr_pool_t *pool);
127 /* Returns a stream that reads/writes from/to SOCK. */
128 svn_ra_svn__stream_t *svn_ra_svn__stream_from_sock(apr_socket_t *sock,
129 apr_pool_t *pool);
131 /* Returns a stream that reads from IN_FILE and writes to OUT_FILE. */
132 svn_ra_svn__stream_t *svn_ra_svn__stream_from_files(apr_file_t *in_file,
133 apr_file_t *out_file,
134 apr_pool_t *pool);
136 /* Create an svn_ra_svn__stream_t using READ_CB, WRITE_CB, TIMEOUT_CB,
137 * PENDING_CB, and BATON.
139 svn_ra_svn__stream_t *svn_ra_svn__stream_create(void *baton,
140 svn_read_fn_t read_cb,
141 svn_write_fn_t write_cb,
142 ra_svn_timeout_fn_t timeout_cb,
143 ra_svn_pending_fn_t pending_cb,
144 apr_pool_t *pool);
146 /* Write *LEN bytes from DATA to STREAM, returning the number of bytes
147 * written in *LEN.
149 svn_error_t *svn_ra_svn__stream_write(svn_ra_svn__stream_t *stream,
150 const char *data, apr_size_t *len);
152 /* Read *LEN bytes from STREAM into DATA, returning the number of bytes
153 * read in *LEN.
155 svn_error_t *svn_ra_svn__stream_read(svn_ra_svn__stream_t *stream,
156 char *data, apr_size_t *len);
158 /* Set the timeout for operations on STREAM to INTERVAL. */
159 void svn_ra_svn__stream_timeout(svn_ra_svn__stream_t *stream,
160 apr_interval_time_t interval);
162 /* Return whether or not there is data pending on STREAM. */
163 svn_boolean_t svn_ra_svn__stream_pending(svn_ra_svn__stream_t *stream);
165 /* Respond to an auth request and perform authentication. Use the Cyrus
166 * SASL library for mechanism negotiation and for creating authentication
167 * tokens. */
168 svn_error_t *
169 svn_ra_svn__do_cyrus_auth(svn_ra_svn__session_baton_t *sess,
170 apr_array_header_t *mechlist,
171 const char *realm, apr_pool_t *pool);
173 /* Same as svn_ra_svn__do_cyrus_auth, but uses the built-in implementation of
174 * the CRAM-MD5, ANONYMOUS and EXTERNAL mechanisms. Return the error
175 * SVN_ERR_RA_SVN_NO_MECHANSIMS if we cannot negotiate an authentication
176 * mechanism with the server. */
177 svn_error_t *
178 svn_ra_svn__do_internal_auth(svn_ra_svn__session_baton_t *sess,
179 apr_array_header_t *mechlist,
180 const char *realm, apr_pool_t *pool);
182 /* Having picked a mechanism, start authentication by writing out an
183 * auth response. MECH_ARG may be NULL for mechanisms with no
184 * initial client response. */
185 svn_error_t *svn_ra_svn__auth_response(svn_ra_svn_conn_t *conn,
186 apr_pool_t *pool,
187 const char *mech, const char *mech_arg);
189 /* Initialize the SASL library. */
190 svn_error_t *svn_ra_svn__sasl_init(void);
193 #ifdef __cplusplus
195 #endif /* __cplusplus */
197 #endif /* RA_SVN_H */