* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
[svn.git] / subversion / bindings / swig / python / libsvn_swig_py / swigutil_py.h
blobce249898679c363907bbb9765a08fda022d67a0d
1 /*
2 * swigutil_py.h : utility functions and stuff for the SWIG Python bindings
4 * ====================================================================
5 * Copyright (c) 2000-2004 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 * ====================================================================
20 #ifndef SVN_SWIG_SWIGUTIL_PY_H
21 #define SVN_SWIG_SWIGUTIL_PY_H
23 #include <Python.h>
25 #include <apr.h>
26 #include <apr_pools.h>
27 #include <apr_strings.h>
28 #include <apr_hash.h>
29 #include <apr_tables.h>
31 #include "svn_types.h"
32 #include "svn_string.h"
33 #include "svn_delta.h"
34 #include "svn_client.h"
35 #include "svn_repos.h"
37 /* Define DLL export magic on Windows. */
38 #ifdef WIN32
39 # ifdef SVN_SWIG_SWIGUTIL_PY_C
40 # define SVN_SWIG_SWIGUTIL_EXPORT __declspec(dllexport)
41 # else
42 # define SVN_SWIG_SWIGUTIL_EXPORT __declspec(dllimport)
43 # endif
44 #else
45 # define SVN_SWIG_SWIGUTIL_EXPORT
46 #endif
48 #ifdef __cplusplus
49 extern "C" {
50 #endif /* __cplusplus */
54 /* Initialize the libsvn_swig_py library. */
55 SVN_SWIG_SWIGUTIL_EXPORT
56 apr_status_t svn_swig_py_initialize(void);
60 /* Functions to manage python's global interpreter lock */
61 SVN_SWIG_SWIGUTIL_EXPORT
62 void svn_swig_py_release_py_lock(void);
64 SVN_SWIG_SWIGUTIL_EXPORT
65 void svn_swig_py_acquire_py_lock(void);
68 /*** Automatic Pool Management Functions ***/
70 /* Set the application pool */
71 SVN_SWIG_SWIGUTIL_EXPORT
72 void svn_swig_py_set_application_pool(PyObject *py_pool, apr_pool_t *pool);
74 /* Clear the application pool */
75 SVN_SWIG_SWIGUTIL_EXPORT
76 void svn_swig_py_clear_application_pool(void);
78 /* Get the pool argument from the last element of tuple args.
79 * If the last element of args is not a pool, create a new
80 * subpool. Return 0 if successful. Return 1 if an error
81 * occurs.
83 SVN_SWIG_SWIGUTIL_EXPORT
84 int svn_swig_py_get_pool_arg(PyObject *args, swig_type_info *type,
85 PyObject **py_pool, apr_pool_t **pool);
87 /* Get the parent pool of the first argument in the specified
88 * argument list. Return 0 if successful. Return 1 if an error
89 * occurs.
91 SVN_SWIG_SWIGUTIL_EXPORT
92 int svn_swig_py_get_parent_pool(PyObject *args, swig_type_info *type,
93 PyObject **py_pool, apr_pool_t **pool);
96 /*** SWIG Wrappers ***/
98 /* Wrapper for SWIG_NewPointerObj */
99 SVN_SWIG_SWIGUTIL_EXPORT
100 PyObject *svn_swig_NewPointerObj(void *obj, swig_type_info *type,
101 PyObject *pool, PyObject *args);
103 /* Wrapper for SWIG_ConvertPtr */
104 SVN_SWIG_SWIGUTIL_EXPORT
105 int svn_swig_ConvertPtr(PyObject *input, void **obj, swig_type_info *type);
107 /* Wrapper for SWIG_MustGetPtr */
108 SVN_SWIG_SWIGUTIL_EXPORT
109 void *svn_swig_MustGetPtr(void *input, swig_type_info *type, int argnum);
111 /*** Functions to expose a custom SubversionException ***/
113 /* raise a subversion exception, created from a normal subversion
114 error. consume the error. */
115 SVN_SWIG_SWIGUTIL_EXPORT
116 void svn_swig_py_svn_exception(svn_error_t *err);
120 /* helper function to convert an apr_hash_t* (char* -> svnstring_t*) to
121 a Python dict */
122 SVN_SWIG_SWIGUTIL_EXPORT
123 PyObject *svn_swig_py_prophash_to_dict(apr_hash_t *hash);
125 /* helper function to convert an apr_hash_t* (svn_revnum_t* -> const
126 char *) to a Python dict */
127 SVN_SWIG_SWIGUTIL_EXPORT
128 PyObject *svn_swig_py_locationhash_to_dict(apr_hash_t *hash);
130 /* helper function to convert an apr_array_header_t* (of
131 svn_merge_range_t *) to a Python list */
132 SVN_SWIG_SWIGUTIL_EXPORT
133 PyObject *svn_swig_py_rangelist_to_list(apr_array_header_t *rangelist,
134 swig_type_info *type,
135 PyObject *py_pool);
137 /* helper function to convert an apr_hash_t* (const char *->array of
138 svn_merge_range_t *) to a Python dict */
139 SVN_SWIG_SWIGUTIL_EXPORT
140 PyObject *svn_swig_py_mergeinfo_to_dict(apr_hash_t *hash,
141 swig_type_info *type,
142 PyObject *py_pool);
144 /* helper function to convert an apr_hash_t* (const char *->hash of
145 mergeinfo hashes) to a Python dict */
146 SVN_SWIG_SWIGUTIL_EXPORT
147 PyObject *svn_swig_py_mergeinfo_catalog_to_dict(apr_hash_t *hash,
148 swig_type_info *type,
149 PyObject *py_pool);
151 /* helper function to convert an apr_hash_t *(const char *->const char
152 *) to a Python dict */
154 SVN_SWIG_SWIGUTIL_EXPORT
155 PyObject *svn_swig_py_stringhash_to_dict(apr_hash_t *hash);
157 /* convert a hash of 'const char *' -> TYPE into a Python dict */
158 SVN_SWIG_SWIGUTIL_EXPORT
159 PyObject *svn_swig_py_convert_hash(apr_hash_t *hash, swig_type_info *type,
160 PyObject *py_pool);
162 /* helper function to convert a 'char **' into a Python list of string
163 objects */
164 SVN_SWIG_SWIGUTIL_EXPORT
165 PyObject *svn_swig_py_c_strings_to_list(char **strings);
167 /* helper function to convert an array of 'const char *' to a Python list
168 of string objects */
169 SVN_SWIG_SWIGUTIL_EXPORT
170 PyObject *svn_swig_py_array_to_list(const apr_array_header_t *strings);
172 /* helper function to convert a hash mapping char * to svn_string_t * to a
173 * Python dict mapping str to str. */
174 SVN_SWIG_SWIGUTIL_EXPORT
175 PyObject *svn_swig_py_changed_path_hash_to_dict(apr_hash_t *hash);
177 SVN_SWIG_SWIGUTIL_EXPORT
178 apr_array_header_t *svn_swig_py_rangelist_to_array(PyObject *list,
179 apr_pool_t *pool);
181 /* helper function to convert an array of 'svn_revnum_t' to a Python list
182 of int objects */
183 SVN_SWIG_SWIGUTIL_EXPORT
184 PyObject *svn_swig_py_revarray_to_list(const apr_array_header_t *revs);
186 /* helper function to convert a Python dictionary mapping strings to
187 strings into an apr_hash_t mapping const char *'s to const char *'s,
188 allocated in POOL. */
189 SVN_SWIG_SWIGUTIL_EXPORT
190 apr_hash_t *svn_swig_py_stringhash_from_dict(PyObject *dict,
191 apr_pool_t *pool);
193 /* helper function to convert a Python dictionary mapping strings to
194 rangelists into an apr_hash_t mapping const char *'s to rangelists,
195 allocated in POOL. */
196 SVN_SWIG_SWIGUTIL_EXPORT
197 apr_hash_t *svn_swig_py_mergeinfo_from_dict(PyObject *dict,
198 apr_pool_t *pool);
200 /* helper function to convert a Python dictionary mapping strings to
201 strings into an 'apr_array_header_t *' of svn_prop_t *
202 allocated in POOL. */
203 SVN_SWIG_SWIGUTIL_EXPORT
204 apr_array_header_t *svn_swig_py_proparray_from_dict(PyObject *dict,
205 apr_pool_t *pool);
207 /* helper function to convert a 'apr_array_header_t *' of 'svn_prop_t
208 to a Python dictionary mapping strings to strings. */
209 SVN_SWIG_SWIGUTIL_EXPORT
210 PyObject *svn_swig_py_proparray_to_dict(const apr_array_header_t *array);
212 /* helper function to convert a Python dictionary mapping strings to
213 strings into an apr_hash_t mapping const char *'s to svn_string_t's,
214 allocated in POOL. */
215 SVN_SWIG_SWIGUTIL_EXPORT
216 apr_hash_t *svn_swig_py_prophash_from_dict(PyObject *dict,
217 apr_pool_t *pool);
219 /* helper function to convert a Python dictionary mapping strings to
220 integers into an apr_hash_t mapping const char *'s to revnums,
221 allocated in POOL. */
222 SVN_SWIG_SWIGUTIL_EXPORT
223 apr_hash_t *svn_swig_py_path_revs_hash_from_dict(PyObject *dict,
224 apr_pool_t *pool);
226 /* helper function to convert a Python dictionary mapping strings to
227 strings into an apr_hash_t mapping const char *'s to svn_string_t *'s,
228 allocated in POOL. */
229 SVN_SWIG_SWIGUTIL_EXPORT
230 apr_hash_t *svn_swig_py_changed_path_hash_from_dict(PyObject *dict,
231 apr_pool_t *pool);
233 /* helper function to convert a Python sequence of strings into an
234 'apr_array_header_t *' of 'const char *' objects. Note that the
235 objects must remain alive -- the values are not copied. This is
236 appropriate for incoming arguments which are defined to last the
237 duration of the function's execution. */
238 SVN_SWIG_SWIGUTIL_EXPORT
239 const apr_array_header_t *svn_swig_py_strings_to_array(PyObject *source,
240 apr_pool_t *pool);
242 /* like svn_swig_py_strings_to_array(), but for array's of 'svn_revnum_t's. */
243 SVN_SWIG_SWIGUTIL_EXPORT
244 const apr_array_header_t *svn_swig_py_revnums_to_array(PyObject *source,
245 apr_pool_t *pool);
247 /* make an editor that "thunks" from C callbacks up to Python */
248 SVN_SWIG_SWIGUTIL_EXPORT
249 void svn_swig_py_make_editor(const svn_delta_editor_t **editor,
250 void **edit_baton,
251 PyObject *py_editor,
252 apr_pool_t *pool);
254 SVN_SWIG_SWIGUTIL_EXPORT
255 apr_file_t *svn_swig_py_make_file(PyObject *py_file,
256 apr_pool_t *pool);
258 SVN_SWIG_SWIGUTIL_EXPORT
259 svn_stream_t *svn_swig_py_make_stream(PyObject *py_io,
260 apr_pool_t *pool);
262 /* a notify function that executes a Python function that is passed in
263 via the baton argument */
264 SVN_SWIG_SWIGUTIL_EXPORT
265 void svn_swig_py_notify_func(void *baton,
266 const char *path,
267 svn_wc_notify_action_t action,
268 svn_node_kind_t kind,
269 const char *mime_type,
270 svn_wc_notify_state_t content_state,
271 svn_wc_notify_state_t prop_state,
272 svn_revnum_t revision);
274 SVN_SWIG_SWIGUTIL_EXPORT
275 void svn_swig_py_notify_func2(void *baton,
276 const svn_wc_notify_t *notify,
277 apr_pool_t *pool);
279 /* a status function that executes a Python function that is passed in
280 via the baton argument */
281 SVN_SWIG_SWIGUTIL_EXPORT
282 void svn_swig_py_status_func(void *baton,
283 const char *path,
284 svn_wc_status_t *status);
286 /* a svn_delta_path_driver callback that executes a Python function
287 that is passed in via the baton argument */
288 SVN_SWIG_SWIGUTIL_EXPORT
289 svn_error_t *svn_swig_py_delta_path_driver_cb_func(void **dir_baton,
290 void *parent_baton,
291 void *callback_baton,
292 const char *path,
293 apr_pool_t *pool);
295 /* a status function that executes a Python function that is passed in
296 via the baton argument */
297 SVN_SWIG_SWIGUTIL_EXPORT
298 void svn_swig_py_status_func2(void *baton,
299 const char *path,
300 svn_wc_status2_t *status);
302 /* a cancel function that executes a Python function passed in via the
303 cancel_baton argument. */
304 SVN_SWIG_SWIGUTIL_EXPORT
305 svn_error_t *svn_swig_py_cancel_func(void *cancel_baton);
307 /* thunked fs get_locks function */
308 SVN_SWIG_SWIGUTIL_EXPORT
309 svn_error_t *svn_swig_py_fs_get_locks_func(void *baton,
310 svn_lock_t *lock,
311 apr_pool_t *pool);
313 /* thunked commit log fetcher */
314 SVN_SWIG_SWIGUTIL_EXPORT
315 svn_error_t *svn_swig_py_get_commit_log_func(const char **log_msg,
316 const char **tmp_file,
317 const apr_array_header_t *
318 commit_items,
319 void *baton,
320 apr_pool_t *pool);
322 /* thunked repos authz callback function */
323 SVN_SWIG_SWIGUTIL_EXPORT
324 svn_error_t *svn_swig_py_repos_authz_func(svn_boolean_t *allowed,
325 svn_fs_root_t *root,
326 const char *path,
327 void *baton,
328 apr_pool_t *pool);
330 /* thunked history callback function */
331 SVN_SWIG_SWIGUTIL_EXPORT
332 svn_error_t *svn_swig_py_repos_history_func(void *baton,
333 const char *path,
334 svn_revnum_t revision,
335 apr_pool_t *pool);
337 /* thunked log receiver function */
338 SVN_SWIG_SWIGUTIL_EXPORT
339 svn_error_t *svn_swig_py_log_receiver(void *py_receiver,
340 apr_hash_t *changed_paths,
341 svn_revnum_t rev,
342 const char *author,
343 const char *date,
344 const char *msg,
345 apr_pool_t *pool);
347 /* thunked log receiver2 function */
348 SVN_SWIG_SWIGUTIL_EXPORT
349 svn_error_t *svn_swig_py_log_entry_receiver(void *baton,
350 svn_log_entry_t *log_entry,
351 apr_pool_t *pool);
353 /* thunked info receiver function */
354 SVN_SWIG_SWIGUTIL_EXPORT
355 svn_error_t *svn_swig_py_info_receiver_func(void *py_receiver,
356 const char *path,
357 const svn_info_t *info,
358 apr_pool_t *pool);
360 /* thunked location segments receiver function */
361 SVN_SWIG_SWIGUTIL_EXPORT
362 svn_error_t *
363 svn_swig_py_location_segment_receiver_func(svn_location_segment_t *segment,
364 void *baton,
365 apr_pool_t *pool);
367 /* thunked blame receiver function */
368 SVN_SWIG_SWIGUTIL_EXPORT
369 svn_error_t *svn_swig_py_client_blame_receiver_func(void *baton,
370 apr_int64_t line_no,
371 svn_revnum_t revision,
372 const char *author,
373 const char *date,
374 const char *line,
375 apr_pool_t *pool);
377 /* thunked changelist receiver function */
378 SVN_SWIG_SWIGUTIL_EXPORT
379 svn_error_t *svn_swig_py_changelist_receiver_func(void *baton,
380 const char *path,
381 const char *changelist,
382 apr_pool_t *pool);
384 /* auth provider callbacks */
385 SVN_SWIG_SWIGUTIL_EXPORT
386 svn_error_t *svn_swig_py_auth_simple_prompt_func(
387 svn_auth_cred_simple_t **cred,
388 void *baton,
389 const char *realm,
390 const char *username,
391 svn_boolean_t may_save,
392 apr_pool_t *pool);
394 SVN_SWIG_SWIGUTIL_EXPORT
395 svn_error_t *svn_swig_py_auth_username_prompt_func(
396 svn_auth_cred_username_t **cred,
397 void *baton,
398 const char *realm,
399 svn_boolean_t may_save,
400 apr_pool_t *pool);
402 SVN_SWIG_SWIGUTIL_EXPORT
403 svn_error_t *svn_swig_py_auth_ssl_server_trust_prompt_func(
404 svn_auth_cred_ssl_server_trust_t **cred,
405 void *baton,
406 const char *realm,
407 apr_uint32_t failures,
408 const svn_auth_ssl_server_cert_info_t *cert_info,
409 svn_boolean_t may_save,
410 apr_pool_t *pool);
412 SVN_SWIG_SWIGUTIL_EXPORT
413 svn_error_t *svn_swig_py_auth_ssl_client_cert_prompt_func(
414 svn_auth_cred_ssl_client_cert_t **cred,
415 void *baton,
416 const char *realm,
417 svn_boolean_t may_save,
418 apr_pool_t *pool);
420 SVN_SWIG_SWIGUTIL_EXPORT
421 svn_error_t *svn_swig_py_auth_ssl_client_cert_pw_prompt_func(
422 svn_auth_cred_ssl_client_cert_pw_t **cred,
423 void *baton,
424 const char *realm,
425 svn_boolean_t may_save,
426 apr_pool_t *pool);
428 SVN_SWIG_SWIGUTIL_EXPORT
429 void
430 svn_swig_py_setup_ra_callbacks(svn_ra_callbacks2_t **callbacks,
431 void **baton,
432 PyObject *py_callbacks,
433 apr_pool_t *pool);
434 SVN_SWIG_SWIGUTIL_EXPORT
435 svn_error_t *svn_swig_py_commit_callback2(const svn_commit_info_t *commit_info,
436 void *baton,
437 apr_pool_t *pool);
439 SVN_SWIG_SWIGUTIL_EXPORT
440 svn_error_t *svn_swig_py_commit_callback(svn_revnum_t new_revision,
441 const char *date,
442 const char *author,
443 void *baton);
446 SVN_SWIG_SWIGUTIL_EXPORT
447 svn_error_t *svn_swig_py_ra_file_rev_handler_func(
448 void *baton,
449 const char *path,
450 svn_revnum_t rev,
451 apr_hash_t *rev_props,
452 svn_txdelta_window_handler_t *delta_handler,
453 void **delta_baton,
454 apr_array_header_t *prop_diffs,
455 apr_pool_t *pool);
457 SVN_SWIG_SWIGUTIL_EXPORT
458 svn_error_t *svn_swig_py_ra_lock_callback(
459 void *baton,
460 const char *path,
461 svn_boolean_t do_lock,
462 const svn_lock_t *lock,
463 svn_error_t *ra_err,
464 apr_pool_t *pool);
466 SVN_SWIG_SWIGUTIL_EXPORT
467 extern const svn_ra_reporter2_t swig_py_ra_reporter2;
469 #ifdef __cplusplus
471 #endif /* __cplusplus */
473 #endif /* SVN_SWIG_SWIGUTIL_PY_H */