@@ -156,25 +156,30 @@ PHP_FUNCTION(git_odb_read_header)
156
156
{
157
157
php_git2_t * result = NULL , * _db = NULL ;
158
158
size_t len_out = NULL ;
159
- zval * type_out = NULL , * db = NULL ;
159
+ zval * db = NULL , * _result = NULL ;
160
+ git_otype type_out ;
160
161
char * id = NULL ;
161
162
int id_len = 0 , error = 0 ;
162
163
git_oid __id = {0 };
163
164
164
165
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC ,
165
- "<git_otype> rs" , & type_out , & db , & id , & id_len ) == FAILURE ) {
166
+ "rs" , & db , & id , & id_len ) == FAILURE ) {
166
167
return ;
167
168
}
168
169
169
170
ZEND_FETCH_RESOURCE (_db , php_git2_t * , & db , -1 , PHP_GIT2_RESOURCE_NAME , git2_resource_handle );
170
171
if (git_oid_fromstrn (& __id , id , id_len )) {
171
172
RETURN_FALSE ;
172
173
}
173
- error = git_odb_read_header (& len_out , type_out , PHP_GIT2_V (_db , odb ), & __id );
174
+ error = git_odb_read_header (& len_out , & type_out , PHP_GIT2_V (_db , odb ), & __id );
174
175
if (php_git2_check_error (error , "git_odb_read_header" TSRMLS_CC )) {
175
176
RETURN_FALSE ;
176
177
}
177
- RETURN_LONG (len_out );
178
+ MAKE_STD_ZVAL (_result );
179
+ array_init (_result );
180
+ add_next_index_long (_result , len_out );
181
+ add_next_index_long (_result , type_out );
182
+ RETURN_ZVAL (_result , 0 , 1 );
178
183
}
179
184
/* }}} */
180
185
@@ -791,6 +796,39 @@ static int php_git2_odb_backend_read_prefix(git_oid *out_oid,
791
796
792
797
static int php_git2_odb_backend_read_header (size_t * len_p , git_otype * type_p , git_odb_backend * backend , const git_oid * oid )
793
798
{
799
+ php_git2_t * result ;
800
+ php_git2_odb_backend * php_backend = (php_git2_odb_backend * )backend ;
801
+ zval * param_oid = NULL , * retval_ptr = NULL ;
802
+ php_git2_multi_cb_t * p = php_backend -> multi ;
803
+ int i = 0 , retval = 0 ;
804
+ GIT2_TSRMLS_SET (p -> tsrm_ls );
805
+ char buf [41 ] = {0 };
806
+
807
+ git_oid_fmt (buf , oid );
808
+ MAKE_STD_ZVAL (param_oid );
809
+ ZVAL_STRING (param_oid , buf , 1 );
810
+
811
+ if (php_git2_call_function_v (& p -> callbacks [3 ].fci , & p -> callbacks [3 ].fcc TSRMLS_CC , & retval_ptr , 1 , & param_oid )) {
812
+ return GIT_EUSER ;
813
+ }
814
+ if (Z_TYPE_P (retval_ptr ) == IS_ARRAY ) {
815
+ zval * * value , * * otype ;
816
+
817
+ if (zend_hash_num_elements (Z_ARRVAL_P (retval_ptr )) != 2 ) {
818
+ return GIT_ENOTFOUND ;
819
+ }
820
+
821
+ zend_hash_get_current_data (Z_ARRVAL_P (retval_ptr ), (void * * )& value );
822
+ * len_p = Z_LVAL_PP (value );
823
+ zend_hash_move_forward (Z_ARRVAL_P (retval_ptr ));
824
+ zend_hash_get_current_data (Z_ARRVAL_P (retval_ptr ), (void * * )& otype );
825
+ * type_p = Z_LVAL_PP (otype );
826
+ } else {
827
+ retval = GIT_ENOTFOUND ;
828
+ }
829
+
830
+ zval_ptr_dtor (& retval_ptr );
831
+ return retval ;
794
832
}
795
833
static int php_git2_odb_backend_writestream (git_odb_stream * * stream_out , git_odb_backend * _backend , size_t length , git_otype type )
796
834
{
@@ -868,6 +906,10 @@ PHP_FUNCTION(git_odb_backend_new)
868
906
php_git2_fcall_info_wrapper2 (tmp , & write_fci , & write_fcc TSRMLS_CC );
869
907
}
870
908
909
+ tmp = php_git2_read_arrval (callbacks , ZEND_STRS ("read_header" ) TSRMLS_CC );
910
+ if (tmp ) {
911
+ php_git2_fcall_info_wrapper2 (tmp , & read_header_fci , & read_header_fcc TSRMLS_CC );
912
+ }
871
913
tmp = php_git2_read_arrval (callbacks , ZEND_STRS ("exists" ) TSRMLS_CC );
872
914
if (tmp ) {
873
915
php_git2_fcall_info_wrapper2 (tmp , & exists_fci , & exists_fcc TSRMLS_CC );
0 commit comments