ignore build output.
[jelmer/subvertpy.git] / util.h
1 /*
2  * Copyright © 2008 Jelmer Vernooij <jelmer@samba.org>
3  * -*- coding: utf-8 -*-
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef _BZR_SVN_UTIL_H_
21 #define _BZR_SVN_UTIL_H_
22
23 /* There's no Py_ssize_t in 2.4, apparently */
24 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
25 typedef int Py_ssize_t;
26 #endif
27
28 #pragma GCC visibility push(hidden)
29
30 __attribute__((warn_unused_result)) apr_pool_t *Pool(apr_pool_t *parent);
31 __attribute__((warn_unused_result)) bool check_error(svn_error_t *error);
32 bool string_list_to_apr_array(apr_pool_t *pool, PyObject *l, apr_array_header_t **);
33 bool path_list_to_apr_array(apr_pool_t *pool, PyObject *l, apr_array_header_t **);
34 PyObject *prop_hash_to_dict(apr_hash_t *props);
35 apr_hash_t *prop_dict_to_hash(apr_pool_t *pool, PyObject *py_props);
36 svn_error_t *py_svn_log_wrapper(void *baton, apr_hash_t *changed_paths, 
37                                                                 long revision, const char *author, 
38                                                                 const char *date, const char *message, 
39                                                                 apr_pool_t *pool);
40 svn_error_t *py_svn_error(void);
41 void PyErr_SetSubversionException(svn_error_t *error);
42
43 #define RUN_SVN(cmd) { \
44         svn_error_t *err; \
45         PyThreadState *_save; \
46         _save = PyEval_SaveThread(); \
47         err = (cmd); \
48         PyEval_RestoreThread(_save); \
49         if (!check_error(err)) { \
50                 return NULL; \
51         } \
52 }
53
54 #define RUN_SVN_WITH_POOL(pool, cmd) { \
55         svn_error_t *err; \
56         PyThreadState *_save; \
57         _save = PyEval_SaveThread(); \
58         err = (cmd); \
59         PyEval_RestoreThread(_save); \
60         if (!check_error(err)) { \
61                 apr_pool_destroy(pool); \
62                 return NULL; \
63         } \
64 }
65
66 PyObject *wrap_lock(svn_lock_t *lock);
67 apr_array_header_t *revnum_list_to_apr_array(apr_pool_t *pool, PyObject *l);
68 svn_stream_t *new_py_stream(apr_pool_t *pool, PyObject *py);
69 PyObject *PyErr_NewSubversionException(svn_error_t *error);
70 svn_error_t *py_cancel_func(void *cancel_baton);
71 apr_hash_t *config_hash_from_object(PyObject *config, apr_pool_t *pool);
72 void PyErr_SetAprStatus(apr_status_t status);
73
74 #if SVN_VER_MAJOR == 1 && SVN_VER_MINOR >= 5
75 svn_error_t *py_svn_log_entry_receiver(void *baton, svn_log_entry_t *log_entry, apr_pool_t *pool);
76 #endif
77
78 #pragma GCC visibility pop
79
80 #define CB_CHECK_PYRETVAL(ret) \
81         if (ret == NULL) { \
82                 PyGILState_Release(state); \
83                 return py_svn_error(); \
84         }
85
86 #endif /* _BZR_SVN_UTIL_H_ */