-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathphp_git2_priv.h
100 lines (85 loc) · 2.92 KB
/
php_git2_priv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* PHP Libgit2 Extension
*
* https://github.com/libgit2/php-git
*
* Copyright 2014 Shuhei Tanuma. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef PHP_GIT2_PRIV_H
#define PHP_GIT2_PRIV_H
extern int git2_resource_handle;
#if PHP_VERSION_ID>=50399
#define PHP_GIT2_LIST_INSERT(type, handle) zend_list_insert(type, handle TSRMLS_CC)
#else
#define PHP_GIT2_LIST_INSERT(type, handle) zend_list_insert(type, handle)
#endif
#define PHP_GIT2_V(git2, type) git2->v.type
#define GIT2_RVAL_P(git2) git2->resource_id
#define GIT2_SHOULD_FREE(git2) git2->should_free_v
#ifdef ZTS
#define GIT2_TSRMLS_SET(target) void ***tsrm_ls = target;
#define GIT2_TSRMLS_DECL void ***tsrm_ls;
#define GIT2_TSRMLS_SET2(target, value) target->tsrm_ls = value;
#else
#define GIT2_TSRMLS_SET(target)
#define GIT2_TSRMLS_SET2(target, value)
#define GIT2_TSRMLS_DECL
#endif
#define PHP_GIT2_MAKE_RESOURCE(val) \
do {\
val = (php_git2_t *)emalloc(sizeof(php_git2_t));\
if (!val) {\
php_error_docref(NULL TSRMLS_CC, E_ERROR, "emalloc failed");\
RETURN_FALSE;\
}\
val->should_free_v = 0;\
val->type = 0;\
val->mutable = 0;\
} while (0);\
#define PHP_GIT2_MAKE_RESOURCE_NOCHECK(val) \
do {\
val = (php_git2_t *)emalloc(sizeof(php_git2_t));\
val->should_free_v = 0;\
val->type = 0;\
val->mutable = 0;\
} while (0);\
#define GIT2_OID_HEXSIZE (GIT_OID_HEXSZ+1)
#define GIT2_BUFFER_SIZE 512
typedef struct php_git2_cb_t {
zval *payload;
zend_fcall_info *fci;
zend_fcall_info_cache *fcc;
GIT2_TSRMLS_DECL
} php_git2_cb_t;
typedef struct php_git2_fcall_t {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
zval *value;
} php_git2_fcall_t;
typedef struct php_git2_multi_cb_t {
int num_callbacks;
php_git2_fcall_t *callbacks;
zval *payload;
GIT2_TSRMLS_DECL
} php_git2_multi_cb_t;
int php_git2_make_resource(php_git2_t **out, enum php_git2_resource_type type, void *resource, int should_free TSRMLS_DC);
#include "helper.h"
#endif