@@ -209,72 +209,3 @@ xbps_file_sha256_check(const char *file, const char *sha256)
209209
210210 return 0 ;
211211}
212-
213- static const char *
214- file_hash_dictionary (xbps_dictionary_t d , const char * key , const char * file )
215- {
216- xbps_object_t obj ;
217- xbps_object_iterator_t iter ;
218- const char * curfile = NULL , * sha256 = NULL ;
219-
220- assert (xbps_object_type (d ) == XBPS_TYPE_DICTIONARY );
221- assert (key != NULL );
222- assert (file != NULL );
223-
224- iter = xbps_array_iter_from_dict (d , key );
225- if (iter == NULL ) {
226- errno = ENOENT ;
227- return NULL ;
228- }
229- while ((obj = xbps_object_iterator_next (iter )) != NULL ) {
230- xbps_dictionary_get_cstring_nocopy (obj ,
231- "file" , & curfile );
232- if (strcmp (file , curfile ) == 0 ) {
233- /* file matched */
234- xbps_dictionary_get_cstring_nocopy (obj ,
235- "sha256" , & sha256 );
236- break ;
237- }
238- }
239- xbps_object_iterator_release (iter );
240- if (sha256 == NULL )
241- errno = ENOENT ;
242-
243- return sha256 ;
244- }
245-
246- int HIDDEN
247- xbps_file_hash_check_dictionary (struct xbps_handle * xhp ,
248- xbps_dictionary_t d ,
249- const char * key ,
250- const char * file )
251- {
252- const char * sha256d = NULL ;
253- char * buf ;
254- int rv ;
255-
256- assert (xbps_object_type (d ) == XBPS_TYPE_DICTIONARY );
257- assert (key != NULL );
258- assert (file != NULL );
259-
260- if ((sha256d = file_hash_dictionary (d , key , file )) == NULL ) {
261- if (errno == ENOENT )
262- return 1 ; /* no match, file not found */
263-
264- return -1 ; /* error */
265- }
266-
267- if (strcmp (xhp -> rootdir , "/" ) == 0 ) {
268- rv = xbps_file_sha256_check (file , sha256d );
269- } else {
270- buf = xbps_xasprintf ("%s/%s" , xhp -> rootdir , file );
271- rv = xbps_file_sha256_check (buf , sha256d );
272- free (buf );
273- }
274- if (rv == 0 )
275- return 0 ; /* matched */
276- else if (rv == ERANGE || rv == ENOENT )
277- return 1 ; /* no match */
278- else
279- return -1 ; /* error */
280- }
0 commit comments