-
Notifications
You must be signed in to change notification settings - Fork 118
/
signature.c
77 lines (68 loc) · 2.07 KB
/
signature.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
#include "php_git2.h"
#include "php_git2_priv.h"
#include "signature.h"
/* {{{ proto resource git_signature_new(string $name, string $email, array $time, long $offset)
*/
PHP_FUNCTION(git_signature_new)
{
git_signature *out = NULL;
char *name = NULL, *email = NULL;
int name_len = 0, email_len = 0, error = 0;
long time = 0, offset = 0;
zval *signature = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ssll", &name, &name_len, &email, &email_len, &time, &offset) == FAILURE) {
return;
}
error = git_signature_new(&out, name, email, time, offset);
if (php_git2_check_error(error, "git_signature_new" TSRMLS_CC)) {
RETURN_FALSE;
}
php_git2_signature_to_array(out, &signature TSRMLS_CC);
git_signature_free(out);
RETURN_ZVAL(signature, 0, 1);
}
/* }}} */
/* {{{ proto resource git_signature_now(string $name, string $email)
*/
PHP_FUNCTION(git_signature_now)
{
git_signature *out = NULL;
char *name = NULL, *email = NULL;
int name_len = 0, email_len = 0, error = 0;
zval *signature = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ss", &name, &name_len, &email, &email_len) == FAILURE) {
return;
}
error = git_signature_now(&out, name, email);
if (php_git2_check_error(error, "git_signature_now" TSRMLS_CC)) {
RETURN_FALSE;
}
php_git2_signature_to_array(out, &signature TSRMLS_CC);
git_signature_free(out);
RETURN_ZVAL(signature, 0, 1);
}
/* }}} */
/* {{{ proto resource git_signature_default(resource $repo)
*/
PHP_FUNCTION(git_signature_default)
{
php_git2_t *_repo = NULL;
git_signature *out = NULL;
zval *repo = NULL, *signature = NULL;
int error = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &repo) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(_repo, php_git2_t*, &repo, -1, PHP_GIT2_RESOURCE_NAME, git2_resource_handle);
error = git_signature_default(&out, PHP_GIT2_V(_repo, repository));
if (php_git2_check_error(error, "git_signature_default" TSRMLS_CC)) {
RETURN_FALSE;
}
php_git2_signature_to_array(out, &signature TSRMLS_CC);
git_signature_free(out);
RETURN_ZVAL(signature, 0, 1);
}
/* }}} */