-
Notifications
You must be signed in to change notification settings - Fork 78
/
giterr.c
81 lines (68 loc) · 1.39 KB
/
giterr.c
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
#include "php_git2.h"
#include "php_git2_priv.h"
#include "giterr.h"
static void php_git2_error_to_array(const git_error *error, zval **out)
{
zval *array;
MAKE_STD_ZVAL(array);
array_init(array);
if (error == NULL) {
add_next_index_string(array, "", 1);
add_next_index_long(array, 0);
} else {
add_next_index_string(array, error->message, 1);
add_next_index_long(array, error->klass);
}
*out = array;
}
/* {{{ proto resource giterr_last()
*/
PHP_FUNCTION(giterr_last)
{
const git_error *result = {0};
zval *array;
result = giterr_last();
php_git2_error_to_array(result, &array);
RETURN_ZVAL(array, 0, 1);
}
/* }}} */
/* {{{ proto void giterr_clear()
*/
PHP_FUNCTION(giterr_clear)
{
giterr_clear();
}
/* }}} */
/* {{{ proto array giterr_detach()
*/
PHP_FUNCTION(giterr_detach)
{
int result = 0;
git_error cpy;
zval *array;
result = giterr_detach(&cpy);
php_git2_error_to_array(&cpy, &array);
RETURN_ZVAL(array, 0, 1);
}
/* }}} */
/* {{{ proto void giterr_set_str(long $error_class, string $string)
*/
PHP_FUNCTION(giterr_set_str)
{
long error_class = 0;
char *string = NULL;
int string_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ls", &error_class, &string, &string_len) == FAILURE) {
return;
}
giterr_set_str(error_class, string);
}
/* }}} */
/* {{{ proto void giterr_set_oom()
*/
PHP_FUNCTION(giterr_set_oom)
{
giterr_set_oom();
}
/* }}} */