@@ -28,12 +28,40 @@ PHP_FUNCTION(git_blob_create_frombuffer)
28
28
git_oid_fmt (out , & id );
29
29
RETURN_STRING (out , 1 );
30
30
}
31
+ /* }}} */
31
32
32
- /* {{{ proto resource git_blob_create_fromchunks(resource $repository , string $hintpath, Callable $callback, mixed payload)
33
- */
33
+ /* {{{ proto long git_blob_create_fromchunks(string $id, resource $repo , string $hintpath, Callable $callback, $ payload)
34
+ */
34
35
PHP_FUNCTION (git_blob_create_fromchunks )
35
36
{
37
+ int result = 0 , id_len = 0 , hintpath_len = 0 , error = 0 ;
38
+ char * id = NULL , * hintpath = NULL ;
39
+ git_oid __id = {0 };
40
+ zval * repo = NULL , * callback = NULL , * payload = NULL ;
41
+ php_git2_t * _repo = NULL ;
42
+ zend_fcall_info fci = empty_fcall_info ;
43
+ zend_fcall_info_cache fcc = empty_fcall_info_cache ;
44
+ php_git2_cb_t * cb = NULL ;
45
+
46
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
47
+ "srsfz" , & id , & id_len , & repo , & hintpath , & hintpath_len , & fci , & fcc , & payload ) == FAILURE ) {
48
+ return ;
49
+ }
50
+
51
+ ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
52
+ if (git_oid_fromstrn (& __id , id , id_len )) {
53
+ RETURN_FALSE ;
54
+ }
55
+ if (php_git2_cb_init (& cb , & fci , & fcc , payload TSRMLS_CC )) {
56
+ RETURN_FALSE ;
57
+ }
58
+ // TODO(chobie) implement this */
59
+ //result = git_blob_create_fromchunks(__id, PHP_GIT2_V(_repo, repository), hintpath, <CHANGEME>, cb);
60
+ php_git2_cb_free (cb );
61
+ RETURN_LONG (result );
36
62
}
63
+ /* }}} */
64
+
37
65
38
66
/* {{{ proto resource git_blob_create_fromdisk(resource $repository, string $path)
39
67
*/
@@ -62,6 +90,7 @@ PHP_FUNCTION(git_blob_create_fromdisk)
62
90
git_oid_fmt (out , & id );
63
91
RETURN_STRING (out , 1 );
64
92
}
93
+ /* }}} */
65
94
66
95
/* {{{ proto resource git_blob_create_fromworkdir(resource $repository, string $relative_path)
67
96
*/
@@ -90,32 +119,56 @@ PHP_FUNCTION(git_blob_create_fromworkdir)
90
119
git_oid_fmt (out , & id );
91
120
RETURN_STRING (out , 1 );
92
121
}
122
+ /* }}} */
93
123
94
- /* {{{ proto resource git_blob_filtered_content($blob, $as_path, $check_for_binary_data)
95
- */
124
+ /* {{{ proto resource git_blob_filtered_content(resource $blob, string $as_path, long $check_for_binary_data)
125
+ */
96
126
PHP_FUNCTION (git_blob_filtered_content )
97
127
{
128
+ php_git2_t * result = NULL , * _blob = NULL ;
129
+ git_buf out = NULL ;
130
+ zval * blob = NULL ;
131
+ char * as_path = NULL ;
132
+ int as_path_len = 0 , error = 0 ;
133
+ long check_for_binary_data = 0 ;
134
+
135
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
136
+ "rsl" , & blob , & as_path , & as_path_len , & check_for_binary_data ) == FAILURE ) {
137
+ return ;
138
+ }
139
+
140
+ ZEND_FETCH_RESOURCE (_blob , php_git2_t * , & blob , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
141
+ error = git_blob_filtered_content (& out , PHP_GIT2_V (_blob , blob ), as_path , check_for_binary_data );
142
+ if (php_git2_check_error (error , "git_blob_filtered_content" TSRMLS_CC )) {
143
+ RETURN_FALSE ;
144
+ }
145
+ if (php_git2_make_resource (& result , PHP_GIT2_TYPE_BUF , out , 1 TSRMLS_CC )) {
146
+ RETURN_FALSE ;
147
+ }
148
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (result ));
98
149
}
150
+ /* }}} */
99
151
100
- /* {{{ proto resource git_blob_free(resource $blob)
101
- */
152
+ /* {{{ proto void git_blob_free(resource $blob)
153
+ */
102
154
PHP_FUNCTION (git_blob_free )
103
155
{
104
- zval * blob ;
105
- php_git2_t * git2 ;
156
+ zval * blob = NULL ;
157
+ php_git2_t * _blob = NULL ;
106
158
107
159
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
108
160
"r" , & blob ) == FAILURE ) {
109
161
return ;
110
162
}
111
163
112
- ZEND_FETCH_RESOURCE (git2 , php_git2_t * , & blob , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
113
- if (git2 -> should_free_v ) {
114
- git_blob_free (PHP_GIT2_V (git2 , blob ));
115
- git2 -> should_free_v = 0 ;
116
- }
164
+ ZEND_FETCH_RESOURCE (_blob , php_git2_t * , & blob , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
165
+ if (GIT2_SHOULD_FREE ( _blob ) ) {
166
+ git_blob_free (PHP_GIT2_V (_blob , blob ));
167
+ GIT2_SHOULD_FREE ( _blob ) = 0 ;
168
+ };
117
169
zval_ptr_dtor (& blob );
118
170
}
171
+ /* }}} */
119
172
120
173
/* {{{ proto resource git_blob_id(resource $blob)
121
174
*/
@@ -137,6 +190,7 @@ PHP_FUNCTION(git_blob_id)
137
190
git_oid_fmt (out , id );
138
191
RETURN_STRING (out , 1 );
139
192
}
193
+ /* }}} */
140
194
141
195
/* {{{ proto resource git_blob_is_binary(resource $blob)
142
196
*/
@@ -155,75 +209,89 @@ PHP_FUNCTION(git_blob_is_binary)
155
209
result = git_blob_is_binary (PHP_GIT2_V (git2 , blob ));
156
210
RETURN_BOOL (result );
157
211
}
212
+ /* }}} */
158
213
159
- /* {{{ proto resource git_blob_lookup(resource $repository , string $oid )
160
- */
214
+ /* {{{ proto long git_blob_lookup(resource $repo , string $id )
215
+ */
161
216
PHP_FUNCTION (git_blob_lookup )
162
217
{
163
- zval * repository ;
164
- php_git2_t * git2 , * result ;
165
- git_blob * blob ;
166
- char * hash ;
167
- int hash_len ;
168
- int error ;
169
- git_oid id ;
218
+ int result = 0 , id_len = 0 , error = 0 ;
219
+ git_blob * blob = NULL ;
220
+ zval * repo = NULL ;
221
+ php_git2_t * _repo = NULL , * _result = NULL ;
222
+ char * id = NULL ;
223
+ git_oid __id = {0 };
170
224
171
225
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
172
- "rs" , & repository , & hash , & hash_len ) == FAILURE ) {
226
+ "rs" , & repo , & id , & id_len ) == FAILURE ) {
173
227
return ;
174
228
}
175
229
176
- if (git_oid_fromstrn (& id , hash , hash_len ) != GIT_OK ) {
177
- return ;
230
+ ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
231
+ if (git_oid_fromstrn (& __id , id , id_len )) {
232
+ RETURN_FALSE ;
178
233
}
179
-
180
- ZEND_FETCH_RESOURCE (git2 , php_git2_t * , & repository , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
181
-
182
- error = git_blob_lookup (& blob , PHP_GIT2_V (git2 , repository ), & id );
183
- if (php_git2_check_error (error , "git_blob_lookup" TSRMLS_CC )) {
184
- RETURN_FALSE
234
+ result = git_blob_lookup (& blob , PHP_GIT2_V (_repo , repository ), & __id );
235
+ if (php_git2_make_resource (& _result , PHP_GIT2_TYPE_BLOB , result , 0 TSRMLS_CC )) {
236
+ RETURN_FALSE ;
185
237
}
186
-
187
- PHP_GIT2_MAKE_RESOURCE (result );
188
- PHP_GIT2_V (result , blob ) = blob ;
189
- result -> type = PHP_GIT2_TYPE_BLOB ;
190
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
191
- result -> should_free_v = 0 ;
192
-
193
- ZVAL_RESOURCE (return_value , result -> resource_id );
238
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (_result ));
194
239
}
240
+ /* }}} */
195
241
196
- /* {{{ proto resource git_blob_lookup_prefix(resource $blob, string $oid)
197
- */
242
+
243
+ /* {{{ proto long git_blob_lookup_prefix(resource $repo, string $id, long $len)
244
+ */
198
245
PHP_FUNCTION (git_blob_lookup_prefix )
199
246
{
247
+ int result = 0 , id_len = 0 , error = 0 ;
248
+ git_blob * blob = NULL ;
249
+ zval * repo = NULL ;
250
+ php_git2_t * _repo = NULL , * _result = NULL ;
251
+ char * id = NULL ;
252
+ git_oid __id = {0 };
253
+ long len = 0 ;
254
+
255
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
256
+ "rsl" , & repo , & id , & id_len , & len ) == FAILURE ) {
257
+ return ;
258
+ }
259
+
260
+ ZEND_FETCH_RESOURCE (_repo , php_git2_t * , & repo , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
261
+ if (git_oid_fromstrn (& __id , id , id_len )) {
262
+ RETURN_FALSE ;
263
+ }
264
+ result = git_blob_lookup_prefix (& blob , PHP_GIT2_V (_repo , repository ), & __id , len );
265
+ if (php_git2_make_resource (& _result , PHP_GIT2_TYPE_BLOB , blob , 0 TSRMLS_CC )) {
266
+ RETURN_FALSE ;
267
+ }
268
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (_result ));
200
269
}
270
+ /* }}} */
201
271
202
- /* {{{ proto resource git_blob_owner(resource $blob, string $oid)
203
- */
272
+
273
+ /* {{{ proto resource git_blob_owner(resource $blob)
274
+ */
204
275
PHP_FUNCTION (git_blob_owner )
205
276
{
206
- zval * blob ;
207
- php_git2_t * git2 , * result ;
208
- git_repository * repository ;
277
+ git_repository * result = NULL ;
278
+ zval * blob = NULL ;
279
+ php_git2_t * _blob = NULL , * __result = NULL ;
209
280
210
281
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
211
282
"r" , & blob ) == FAILURE ) {
212
283
return ;
213
284
}
214
285
215
- ZEND_FETCH_RESOURCE (git2 , php_git2_t * , & blob , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
216
-
217
- PHP_GIT2_MAKE_RESOURCE (result );
218
- repository = git_blob_owner (PHP_GIT2_V (git2 , blob ));
219
-
220
- PHP_GIT2_V (result , repository ) = repository ;
221
- result -> type = PHP_GIT2_TYPE_REPOSITORY ;
222
- result -> resource_id = PHP_GIT2_LIST_INSERT (result , git2_resource_handle );
223
- result -> should_free_v = 0 ;
224
-
225
- ZVAL_RESOURCE (return_value , result -> resource_id );
286
+ ZEND_FETCH_RESOURCE (_blob , php_git2_t * , & blob , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
287
+ result = git_blob_owner (PHP_GIT2_V (_blob , blob ));
288
+ if (php_git2_make_resource (& __result , PHP_GIT2_TYPE_BLOB , result , 0 TSRMLS_CC )) {
289
+ RETURN_FALSE ;
290
+ }
291
+ ZVAL_RESOURCE (return_value , GIT2_RVAL_P (__result ));
226
292
}
293
+ /* }}} */
294
+
227
295
228
296
/* {{{ proto resource git_blob_rawcontent(resource $blob)
229
297
*/
@@ -248,6 +316,7 @@ PHP_FUNCTION(git_blob_rawcontent)
248
316
size = git_blob_rawsize (PHP_GIT2_V (git2 , blob ));
249
317
RETURN_STRINGL (buffer , size , 1 );
250
318
}
319
+ /* }}} */
251
320
252
321
/* {{{ proto resource git_blob_rawsize(resource $blob, string $oid)
253
322
*/
@@ -265,4 +334,5 @@ PHP_FUNCTION(git_blob_rawsize)
265
334
ZEND_FETCH_RESOURCE (git2 , php_git2_t * , & blob , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
266
335
size = git_blob_rawsize (PHP_GIT2_V (git2 , blob ));
267
336
RETURN_LONG (size );
268
- }
337
+ }
338
+ /* }}} */
0 commit comments