From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 61892138336 for ; Mon, 6 May 2019 16:05:01 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 04BB2E086D; Mon, 6 May 2019 16:05:00 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BEF58E086D for ; Mon, 6 May 2019 16:04:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6C6D234394E for ; Mon, 6 May 2019 16:04:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 14B3B5D3 for ; Mon, 6 May 2019 16:04:57 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1557158522.f837df90e2b14ca2840c1f4280765f5357b9579a.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/vdb.c libq/vdb.h X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: f837df90e2b14ca2840c1f4280765f5357b9579a X-VCS-Branch: master Date: Mon, 6 May 2019 16:04:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 73b0f035-d498-4732-bf7c-e202b20bd6b3 X-Archives-Hash: 9fd472e001f8fc04d393513919a3e592 commit: f837df90e2b14ca2840c1f4280765f5357b9579a Author: Fabian Groffen gentoo org> AuthorDate: Mon May 6 16:02:02 2019 +0000 Commit: Fabian Groffen gentoo 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 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 - * Copyright 2005-2014 Mike Frysinger - + * Copyright 2019- Fabian Groffen - */ #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