pamac-classic/util/alpm-util.c

60 lines
1.2 KiB
C
Raw Normal View History

2014-10-22 13:44:02 -03:00
#include "alpm-util.h"
2016-02-02 05:28:07 -03:00
alpm_pkg_t* alpm_pkg_load_file (alpm_handle_t* handle, const char* filename, int full, alpm_siglevel_t level) {
alpm_pkg_t* p;
if (alpm_pkg_load(handle, filename, full, level, &p) != -1) {
return p;
} else {
return NULL;
}
2014-10-22 13:44:02 -03:00
}
alpm_list_t* alpm_pkg_get_files_list (alpm_pkg_t* pkg) {
2016-02-02 05:28:07 -03:00
alpm_list_t* list = NULL;
alpm_filelist_t* pkgfiles;
2014-10-22 13:44:02 -03:00
size_t i;
pkgfiles = alpm_pkg_get_files(pkg);
for(i = 0; i < pkgfiles->count; i++) {
2016-02-02 05:28:07 -03:00
const alpm_file_t* file = pkgfiles->files + i;
2014-10-22 13:44:02 -03:00
list = alpm_list_add(list, file);
}
return list;
}
2016-02-02 05:28:07 -03:00
void* alpm_list_get_data (alpm_list_t* list) {
if (list) {
return list->data;
} else {
return NULL;
}
2014-10-22 13:44:02 -03:00
}
2016-02-02 05:28:07 -03:00
alpm_list_t* alpm_list_sort (alpm_list_t* list, alpm_list_fn_cmp fn) {
2014-10-22 13:44:02 -03:00
list = alpm_list_msort (list, alpm_list_count (list), fn);
return list;
}
2016-02-02 05:28:07 -03:00
alpm_list_t* alpm_list_new () {
2014-12-03 12:02:14 -03:00
return NULL;
2014-10-22 13:44:02 -03:00
}
2016-02-02 05:28:07 -03:00
void alpm_list_free_data (alpm_list_t* list) {
alpm_list_free_inner (list, free);
2014-12-03 12:02:14 -03:00
}
2016-02-02 05:28:07 -03:00
void alpm_list_iterator (alpm_list_t* list, alpm_list_iterator_t* iter) {
2014-10-22 13:44:02 -03:00
iter->pos = list;
}
2016-02-02 05:28:07 -03:00
void* alpm_list_iterator_next_value (alpm_list_iterator_t* iter) {
2014-10-22 13:44:02 -03:00
if (iter->pos) {
2016-02-02 05:28:07 -03:00
void* data = alpm_list_get_data (iter->pos);
2014-12-03 12:02:14 -03:00
iter->pos = alpm_list_next (iter->pos);
2016-02-02 05:28:07 -03:00
return data;
} else {
return NULL;
2014-10-22 13:44:02 -03:00
}
}