forked from libgit2/php-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexer.c
112 lines (98 loc) · 3.07 KB
/
indexer.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "php_git2.h"
#include "php_git2_priv.h"
#include "indexer.h"
/* {{{ proto resource git_indexer_new(string $path, long $mode, resource $odb, $progress_cb, $progress_cb_payload)
*/
PHP_FUNCTION(git_indexer_new)
{
php_git2_t *result = NULL, *_odb = NULL;
git_indexer *out = NULL;
char *path = NULL;
int path_len = 0, error = 0;
long mode = 0;
zval *odb = NULL, *progress_cb_payload = NULL;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
php_git2_cb_t *cb = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"slrfz", &path, &path_len, &mode, &odb, &fci, &fcc, &progress_cb_payload) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_odb, php_git2_t*, &odb, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (php_git2_cb_init(&cb, &fci, &fcc, progress_cb_payload TSRMLS_CC)) {
RETURN_FALSE;
}
//error = git_indexer_new(&out, path, mode, PHP_GIT2_V(_odb, odb), progress_cb, cb);
if (php_git2_check_error(error, "git_indexer_new" TSRMLS_CC)) {
RETURN_FALSE;
}
if (php_git2_make_resource(&result, PHP_GIT2_TYPE_INDEXER, out, 1 TSRMLS_CC)) {
RETURN_FALSE;
}
ZVAL_RESOURCE(return_value, GIT2_RVAL_P(result));
}
/* }}} */
/* {{{ proto long git_indexer_append(resource $idx, $data, long $size, $stats)
*/
PHP_FUNCTION(git_indexer_append)
{
// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
// "r<void>l<git_transfer_progress>", &idx, &data, &size, &stats) == FAILURE) {
// return;
// }
//
// ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
// result = git_indexer_append(PHP_GIT2_V(_idx, indexer), data, size, stats);
// RETURN_LONG(result);
}
/* }}} */
/* {{{ proto long git_indexer_commit(resource $idx, $stats)
*/
PHP_FUNCTION(git_indexer_commit)
{
// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
// "r<git_transfer_progress>", &idx, &stats) == FAILURE) {
// return;
// }
//
// ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
// result = git_indexer_commit(PHP_GIT2_V(_idx, indexer), stats);
// RETURN_LONG(result);
}
/* }}} */
/* {{{ proto resource git_indexer_hash(resource $idx)
*/
PHP_FUNCTION(git_indexer_hash)
{
const git_oid *result = NULL;
zval *idx = NULL;
php_git2_t *_idx = NULL;
char __result[GIT2_OID_HEXSIZE] = {0};
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &idx) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
result = git_indexer_hash(PHP_GIT2_V(_idx, indexer));
git_oid_fmt(__result, result);
RETURN_STRING(__result, 1);
}
/* }}} */
/* {{{ proto void git_indexer_free(resource $idx)
*/
PHP_FUNCTION(git_indexer_free)
{
zval *idx = NULL;
php_git2_t *_idx = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &idx) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_idx, php_git2_t*, &idx, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
if (GIT2_SHOULD_FREE(_idx)) {
git_indexer_free(PHP_GIT2_V(_idx, indexer));
GIT2_SHOULD_FREE(_idx) = 0;
};
zval_ptr_dtor(&idx);
}
/* }}} */