|
| 1 | +#include "php_git2.h" |
| 2 | +#include "php_git2_priv.h" |
| 3 | +#include "signature.h" |
| 4 | + |
| 5 | +/* {{{ proto resource git_signature_new(string $name, string $email, $time, long $offset) |
| 6 | + */ |
| 7 | +PHP_FUNCTION(git_signature_new) |
| 8 | +{ |
| 9 | + php_git2_t *result = NULL; |
| 10 | + git_signature *out = NULL; |
| 11 | + char *name = NULL, *email = NULL; |
| 12 | + int name_len = 0, email_len = 0, error = 0; |
| 13 | + zval *time = NULL; |
| 14 | + long offset = 0; |
| 15 | + |
| 16 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 17 | + "ssal", &name, &name_len, &email, &email_len, &time, &offset) == FAILURE) { |
| 18 | + return; |
| 19 | + } |
| 20 | + |
| 21 | + error = git_signature_new(&out, name, email, time, offset); |
| 22 | + if (php_git2_check_error(error, "git_signature_new" TSRMLS_CC)) { |
| 23 | + RETURN_FALSE; |
| 24 | + } |
| 25 | +} |
| 26 | +/* }}} */ |
| 27 | + |
| 28 | +/* {{{ proto resource git_signature_now(string $name, string $email) |
| 29 | + */ |
| 30 | +PHP_FUNCTION(git_signature_now) |
| 31 | +{ |
| 32 | + php_git2_t *result = NULL; |
| 33 | + git_signature *out = NULL; |
| 34 | + char *name = NULL, *email = NULL; |
| 35 | + int name_len = 0, email_len = 0, error = 0; |
| 36 | + |
| 37 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 38 | + "ss", &name, &name_len, &email, &email_len) == FAILURE) { |
| 39 | + return; |
| 40 | + } |
| 41 | + |
| 42 | + error = git_signature_now(&out, name, email); |
| 43 | + if (php_git2_check_error(error, "git_signature_now" TSRMLS_CC)) { |
| 44 | + RETURN_FALSE; |
| 45 | + } |
| 46 | +} |
| 47 | +/* }}} */ |
| 48 | + |
| 49 | +/* {{{ proto resource git_signature_default(resource $repo) |
| 50 | + */ |
| 51 | +PHP_FUNCTION(git_signature_default) |
| 52 | +{ |
| 53 | + php_git2_t *result = NULL, *_repo = NULL; |
| 54 | + git_signature *out = NULL; |
| 55 | + zval *repo = NULL; |
| 56 | + int error = 0; |
| 57 | + |
| 58 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 59 | + "r", &repo) == FAILURE) { |
| 60 | + return; |
| 61 | + } |
| 62 | + |
| 63 | + ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle); |
| 64 | + error = git_signature_default(&out, PHP_GIT2_V(_repo, repository)); |
| 65 | + if (php_git2_check_error(error, "git_signature_default" TSRMLS_CC)) { |
| 66 | + RETURN_FALSE; |
| 67 | + } |
| 68 | +} |
| 69 | +/* }}} */ |
| 70 | + |
| 71 | +/* {{{ proto array git_signature_dup(array $sig) |
| 72 | + */ |
| 73 | +PHP_FUNCTION(git_signature_dup) |
| 74 | +{ |
| 75 | + git_signature *result = NULL; |
| 76 | + zval *__result = NULL, *sig = NULL; |
| 77 | + |
| 78 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 79 | + "a", &sig) == FAILURE) { |
| 80 | + return; |
| 81 | + } |
| 82 | + |
| 83 | + result = git_signature_dup(sig); |
| 84 | + php_git2_signature_to_array(result, &__result TSRMLS_CC); |
| 85 | + RETURN_ZVAL(__result, 0, 1); |
| 86 | +} |
| 87 | +/* }}} */ |
| 88 | + |
| 89 | +/* {{{ proto void git_signature_free(array $sig) |
| 90 | + */ |
| 91 | +PHP_FUNCTION(git_signature_free) |
| 92 | +{ |
| 93 | +// zval *sig = NULL; |
| 94 | +// |
| 95 | +// if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |
| 96 | +// "a", &sig) == FAILURE) { |
| 97 | +// return; |
| 98 | +// } |
| 99 | +// |
| 100 | +// if (GIT2_SHOULD_FREE(_sig)) { |
| 101 | +// git_signature_free(sig); |
| 102 | +// GIT2_SHOULD_FREE(_sig) = 0; |
| 103 | +// }; |
| 104 | +// zval_ptr_dtor(&sig); |
| 105 | +} |
| 106 | +/* }}} */ |
| 107 | + |
0 commit comments