commit: f837df90e2b14ca2840c1f4280765f5357b9579a Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Mon May 6 16:02:02 2019 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Mon May 6 16:02:02 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f837df90
libq/vdb: add q_vdb_get_atom to retrieve filled up depend_atom The atom from q_vdb_get_atom gets freed on q_vdb_close_pkg, and is filled with SLOT and repository information from VDB. Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> libq/vdb.c | 19 +++++++++++++++++++ libq/vdb.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/libq/vdb.c b/libq/vdb.c index 447bd6f..034a28c 100644 --- a/libq/vdb.c +++ b/libq/vdb.c @@ -4,6 +4,7 @@ * * Copyright 2005-2010 Ned Ludd - <[email protected]> * Copyright 2005-2014 Mike Frysinger - <[email protected]> + * Copyright 2019- Fabian Groffen - <[email protected]> */ #include "main.h" @@ -334,6 +335,8 @@ q_vdb_close_pkg(q_vdb_pkg_ctx *pkg_ctx) { if (pkg_ctx->fd != -1) close(pkg_ctx->fd); + if (pkg_ctx->atom != NULL) + atom_implode(pkg_ctx->atom); free(pkg_ctx->slot); free(pkg_ctx->repo); free(pkg_ctx); @@ -409,6 +412,22 @@ next_entry: return ret; } +depend_atom * +q_vdb_get_atom(q_vdb_pkg_ctx *pkg_ctx) +{ + pkg_ctx->atom = atom_explode(pkg_ctx->name); + if (pkg_ctx->atom == NULL) + return NULL; + pkg_ctx->atom->CATEGORY = (char *)pkg_ctx->cat_ctx->name; + + q_vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot, &pkg_ctx->slot_len); + pkg_ctx->atom->SLOT = pkg_ctx->slot; + q_vdb_pkg_eat(pkg_ctx, "repository", &pkg_ctx->repo, &pkg_ctx->repo_len); + pkg_ctx->atom->REPO = pkg_ctx->repo; + + return pkg_ctx->atom; +} + set * get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv) { diff --git a/libq/vdb.h b/libq/vdb.h index ee2ee69..3cfa95b 100644 --- a/libq/vdb.h +++ b/libq/vdb.h @@ -59,6 +59,7 @@ struct q_vdb_pkg_ctx { size_t repo_len; int fd; q_vdb_cat_ctx *cat_ctx; + depend_atom *atom; }; /* Global helpers */ @@ -90,5 +91,6 @@ int q_vdb_foreach_pkg_sorted(const char *sroot, const char *svdb, q_vdb_pkg_cb callback, void *priv); struct dirent *q_vdb_get_next_dir(DIR *dir); set *get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv); +depend_atom *q_vdb_get_atom(q_vdb_pkg_ctx *pkg_ctx); #endif
