|
| 1 | +#include "php_git2.h" |
| 2 | +#include "php_git2_priv.h" |
| 3 | +#include "push.h" |
| 4 | + |
| 5 | +/* {{{ proto resource git_push_new(resource $remote) |
| 6 | + */ |
| 7 | +PHP_FUNCTION(git_push_new) |
| 8 | +{ |
| 9 | + php_git2_t *result = NULL, *_remote = NULL; |
| 10 | + git_push *out = NULL; |
| 11 | + zval *remote = NULL; |
| 12 | + int error = 0; |
| 13 | + |
| 14 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 15 | + "r", &remote) == FAILURE) { |
| 16 | + return; |
| 17 | + } |
| 18 | + |
| 19 | + ZEND_FETCH_RESOURCE(_remote, php_git2_t*, &remote, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 20 | + error = git_push_new(&out, PHP_GIT2_V(_remote, remote)); |
| 21 | + if (php_git2_check_error(error, "git_push_new" TSRMLS_CC)) { |
| 22 | + RETURN_FALSE; |
| 23 | + } |
| 24 | + if (php_git2_make_resource(&result, PHP_GIT2_TYPE_PUSH, out, 1 TSRMLS_CC)) { |
| 25 | + RETURN_FALSE; |
| 26 | + } |
| 27 | + ZVAL_RESOURCE(return_value, GIT2_RVAL_P(result)); |
| 28 | +} |
| 29 | +/* }}} */ |
| 30 | + |
| 31 | +/* {{{ proto long git_push_set_options(resource $push, $opts) |
| 32 | + */ |
| 33 | +PHP_FUNCTION(git_push_set_options) |
| 34 | +{ |
| 35 | + int result = 0, error = 0; |
| 36 | + zval *push = NULL, *opts = NULL; |
| 37 | + php_git2_t *_push = NULL; |
| 38 | + |
| 39 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 40 | + "r<git_push_options>", &push, &opts) == FAILURE) { |
| 41 | + return; |
| 42 | + } |
| 43 | + |
| 44 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 45 | + //result = git_push_set_options(PHP_GIT2_V(_push, push), opts); |
| 46 | + RETURN_LONG(result); |
| 47 | +} |
| 48 | +/* }}} */ |
| 49 | + |
| 50 | +/* {{{ proto long git_push_set_callbacks(resource $push, $pack_progress_cb, $pack_progress_cb_payload, $transfer_progress_cb, $transfer_progress_cb_payload) |
| 51 | + */ |
| 52 | +PHP_FUNCTION(git_push_set_callbacks) |
| 53 | +{ |
| 54 | + int result = 0, error = 0; |
| 55 | + zval *push = NULL, *pack_progress_cb = NULL, *pack_progress_cb_payload = NULL, *transfer_progress_cb = NULL, *transfer_progress_cb_payload = NULL; |
| 56 | + php_git2_t *_push = NULL; |
| 57 | + zend_fcall_info fci = empty_fcall_info; |
| 58 | + zend_fcall_info_cache fcc = empty_fcall_info_cache; |
| 59 | + php_git2_cb_t *cb = NULL; |
| 60 | + |
| 61 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 62 | + "rfz<git_push_transfer_progress>z", &push, &fci, &fcc, &pack_progress_cb_payload, &transfer_progress_cb, &transfer_progress_cb_payload) == FAILURE) { |
| 63 | + return; |
| 64 | + } |
| 65 | + |
| 66 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 67 | +// if (php_git2_cb_init(&cb, &fci, &fcc, payload TSRMLS_CC)) { |
| 68 | +// RETURN_FALSE; |
| 69 | +// } |
| 70 | + //result = git_push_set_callbacks(PHP_GIT2_V(_push, push), <CHANGEME>, cb, transfer_progress_cb, cb); |
| 71 | + php_git2_cb_free(cb); |
| 72 | + RETURN_LONG(result); |
| 73 | +} |
| 74 | +/* }}} */ |
| 75 | + |
| 76 | +/* {{{ proto long git_push_add_refspec(resource $push, string $refspec) |
| 77 | + */ |
| 78 | +PHP_FUNCTION(git_push_add_refspec) |
| 79 | +{ |
| 80 | + int result = 0, refspec_len = 0, error = 0; |
| 81 | + zval *push = NULL; |
| 82 | + php_git2_t *_push = NULL; |
| 83 | + char *refspec = NULL; |
| 84 | + |
| 85 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 86 | + "rs", &push, &refspec, &refspec_len) == FAILURE) { |
| 87 | + return; |
| 88 | + } |
| 89 | + |
| 90 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 91 | + result = git_push_add_refspec(PHP_GIT2_V(_push, push), refspec); |
| 92 | + RETURN_LONG(result); |
| 93 | +} |
| 94 | +/* }}} */ |
| 95 | + |
| 96 | +/* {{{ proto long git_push_update_tips(resource $push) |
| 97 | + */ |
| 98 | +PHP_FUNCTION(git_push_update_tips) |
| 99 | +{ |
| 100 | + int result = 0, error = 0; |
| 101 | + zval *push = NULL; |
| 102 | + php_git2_t *_push = NULL; |
| 103 | + |
| 104 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 105 | + "r", &push) == FAILURE) { |
| 106 | + return; |
| 107 | + } |
| 108 | + |
| 109 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 110 | + result = git_push_update_tips(PHP_GIT2_V(_push, push)); |
| 111 | + RETURN_LONG(result); |
| 112 | +} |
| 113 | +/* }}} */ |
| 114 | + |
| 115 | +/* {{{ proto long git_push_finish(resource $push) |
| 116 | + */ |
| 117 | +PHP_FUNCTION(git_push_finish) |
| 118 | +{ |
| 119 | + int result = 0, error = 0; |
| 120 | + zval *push = NULL; |
| 121 | + php_git2_t *_push = NULL; |
| 122 | + |
| 123 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 124 | + "r", &push) == FAILURE) { |
| 125 | + return; |
| 126 | + } |
| 127 | + |
| 128 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 129 | + result = git_push_finish(PHP_GIT2_V(_push, push)); |
| 130 | + RETURN_LONG(result); |
| 131 | +} |
| 132 | +/* }}} */ |
| 133 | + |
| 134 | +/* {{{ proto long git_push_unpack_ok(resource $push) |
| 135 | + */ |
| 136 | +PHP_FUNCTION(git_push_unpack_ok) |
| 137 | +{ |
| 138 | + int result = 0, error = 0; |
| 139 | + zval *push = NULL; |
| 140 | + php_git2_t *_push = NULL; |
| 141 | + |
| 142 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 143 | + "r", &push) == FAILURE) { |
| 144 | + return; |
| 145 | + } |
| 146 | + |
| 147 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 148 | + result = git_push_unpack_ok(PHP_GIT2_V(_push, push)); |
| 149 | + RETURN_LONG(result); |
| 150 | +} |
| 151 | +/* }}} */ |
| 152 | + |
| 153 | +/* {{{ proto long git_push_status_foreach(resource $push, string $ref, string $msg, $data), $data) |
| 154 | + */ |
| 155 | +PHP_FUNCTION(git_push_status_foreach) |
| 156 | +{ |
| 157 | + int result = 0, ref_len = 0, msg_len = 0, error = 0; |
| 158 | + zval *push = NULL; |
| 159 | + php_git2_t *_push = NULL; |
| 160 | + char *ref = NULL, *msg = NULL; |
| 161 | + |
| 162 | +// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 163 | +// "rss<void><void>", &push, &ref, &ref_len, &msg, &msg_len, &data, &data) == FAILURE) { |
| 164 | +// return; |
| 165 | +// } |
| 166 | + |
| 167 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 168 | + //result = git_push_status_foreach(PHP_GIT2_V(_push, push), ref, msg, data); |
| 169 | + RETURN_LONG(result); |
| 170 | +} |
| 171 | +/* }}} */ |
| 172 | + |
| 173 | +/* {{{ proto void git_push_free(resource $push) |
| 174 | + */ |
| 175 | +PHP_FUNCTION(git_push_free) |
| 176 | +{ |
| 177 | + zval *push = NULL; |
| 178 | + php_git2_t *_push = NULL; |
| 179 | + |
| 180 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 181 | + "r", &push) == FAILURE) { |
| 182 | + return; |
| 183 | + } |
| 184 | + |
| 185 | + ZEND_FETCH_RESOURCE(_push, php_git2_t*, &push, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 186 | + if (GIT2_SHOULD_FREE(_push)) { |
| 187 | + git_push_free(PHP_GIT2_V(_push, push)); |
| 188 | + GIT2_SHOULD_FREE(_push) = 0; |
| 189 | + }; |
| 190 | + zval_ptr_dtor(&push); |
| 191 | +} |
| 192 | +/* }}} */ |
| 193 | + |
0 commit comments