Skip to content

Commit f231641

Browse files
committed
lib: remove xbps_file_hash_check_dictionary
1 parent 33e81e7 commit f231641

2 files changed

Lines changed: 0 additions & 71 deletions

File tree

include/xbps_api_impl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ int HIDDEN xbps_transaction_internalize(struct xbps_handle *, xbps_object_iterat
107107

108108
char HIDDEN *xbps_get_remote_repo_string(const char *);
109109
int HIDDEN xbps_repo_sync(struct xbps_handle *, const char *);
110-
int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *,
111-
xbps_dictionary_t, const char *, const char *);
112110
int HIDDEN xbps_file_exec(struct xbps_handle *, const char *, ...);
113111
void HIDDEN xbps_set_cb_fetch(struct xbps_handle *, off_t, off_t, off_t,
114112
const char *, bool, bool, bool);

lib/util_hash.c

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)