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