Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /, libq/
Date: Mon, 06 May 2019 17:33:11
Message-Id: 1557163889.d87d181cd692247a5a7411fd6284c862bc73f28b.grobian@gentoo
1 commit: d87d181cd692247a5a7411fd6284c862bc73f28b
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 6 17:31:29 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon May 6 17:31:29 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d87d181c
7
8 libq/vdb: drop q_ prefix
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 TODO.md | 2 +-
13 libq/cache.c | 40 +++++++++----------
14 libq/cache.h | 6 +--
15 libq/vdb.c | 127 ++++++++++++++++++++++++++++++-----------------------------
16 libq/vdb.h | 74 +++++++++++++++++-----------------
17 qcheck.c | 10 ++---
18 qdepends.c | 8 ++--
19 qfile.c | 10 ++---
20 qgrep.c | 4 +-
21 qlist.c | 24 +++++------
22 qmerge.c | 48 +++++++++++-----------
23 qpkg.c | 14 +++----
24 qsize.c | 6 +--
25 13 files changed, 187 insertions(+), 186 deletions(-)
26
27 diff --git a/TODO.md b/TODO.md
28 index bc4f524..6fda56d 100644
29 --- a/TODO.md
30 +++ b/TODO.md
31 @@ -23,7 +23,7 @@
32 we end up getting just:<br>
33 `ACCEPT_LICENSE=" bar"`
34
35 -- q\_vdb\_foreach\_pkg should have variant that takes an atom (or just
36 +- vdb\_foreach\_pkg should have variant that takes an atom (or just
37 cat?) to reduce search space, same for cache\_foreach\_pkg
38
39 - vdb repo/slot think about when it is freed (see cache\_pkg\_close)
40
41 diff --git a/libq/cache.c b/libq/cache.c
42 index c0ea85e..304cd34 100644
43 --- a/libq/cache.c
44 +++ b/libq/cache.c
45 @@ -66,7 +66,7 @@ cache_open(const char *sroot, const char *portdir)
46 }
47
48 snprintf(buf, sizeof(buf), "%s/%s", portdir, portcachedir_md5);
49 - ret = q_vdb_open2(sroot, buf, true);
50 + ret = vdb_open2(sroot, buf, true);
51 if (ret != NULL) {
52 ret->cachetype = CACHE_METADATA_MD5;
53 ret->repo = repo;
54 @@ -74,14 +74,14 @@ cache_open(const char *sroot, const char *portdir)
55 }
56
57 snprintf(buf, sizeof(buf), "%s/%s", portdir, portcachedir_pms);
58 - ret = q_vdb_open2(sroot, buf, true);
59 + ret = vdb_open2(sroot, buf, true);
60 if (ret != NULL) {
61 ret->cachetype = CACHE_METADATA_PMS;
62 ret->repo = repo;
63 return ret;
64 }
65
66 - ret = q_vdb_open2(sroot, portdir, true);
67 + ret = vdb_open2(sroot, portdir, true);
68 if (ret != NULL) {
69 ret->cachetype = CACHE_EBUILD;
70 ret->repo = repo;
71 @@ -101,31 +101,31 @@ cache_close(cache_ctx *ctx)
72 free(ctx->repo);
73 if (ctx->ebuilddir_ctx != NULL)
74 free(ctx->ebuilddir_ctx);
75 - q_vdb_close(ctx);
76 + vdb_close(ctx);
77 }
78
79 cache_cat_ctx *
80 cache_open_cat(cache_ctx *ctx, const char *name)
81 {
82 - return q_vdb_open_cat(ctx, name);
83 + return vdb_open_cat(ctx, name);
84 }
85
86 cache_cat_ctx *
87 cache_next_cat(cache_ctx *ctx)
88 {
89 - return q_vdb_next_cat(ctx);
90 + return vdb_next_cat(ctx);
91 }
92
93 void
94 cache_close_cat(cache_cat_ctx *cat_ctx)
95 {
96 - return q_vdb_close_cat(cat_ctx);
97 + return vdb_close_cat(cat_ctx);
98 }
99
100 cache_pkg_ctx *
101 cache_open_pkg(cache_cat_ctx *cat_ctx, const char *name)
102 {
103 - return q_vdb_open_pkg(cat_ctx, name);
104 + return vdb_open_pkg(cat_ctx, name);
105 }
106
107 cache_pkg_ctx *
108 @@ -141,13 +141,13 @@ cache_next_pkg(cache_cat_ctx *cat_ctx)
109 * to CAT/P like in VDB and metadata */
110 do {
111 if (ctx->ebuilddir_pkg_ctx == NULL) {
112 - q_vdb_ctx *pkgdir = ctx->ebuilddir_ctx;
113 + vdb_ctx *pkgdir = ctx->ebuilddir_ctx;
114
115 if (pkgdir == NULL)
116 - pkgdir = ctx->ebuilddir_ctx = xmalloc(sizeof(q_vdb_ctx));
117 + pkgdir = ctx->ebuilddir_ctx = xmalloc(sizeof(vdb_ctx));
118 memset(ctx->ebuilddir_ctx, '\0', sizeof(*ctx->ebuilddir_ctx));
119
120 - if ((ctx->ebuilddir_pkg_ctx = q_vdb_next_pkg(cat_ctx)) == NULL)
121 + if ((ctx->ebuilddir_pkg_ctx = vdb_next_pkg(cat_ctx)) == NULL)
122 return NULL;
123
124 pkgdir->portroot_fd = -1;
125 @@ -159,7 +159,7 @@ cache_next_pkg(cache_cat_ctx *cat_ctx)
126 pkgdir->cachetype = ctx->cachetype;
127
128 ctx->ebuilddir_cat_ctx =
129 - q_vdb_open_cat(pkgdir, ctx->ebuilddir_pkg_ctx->name);
130 + vdb_open_cat(pkgdir, ctx->ebuilddir_pkg_ctx->name);
131
132 /* opening might fail if what we found wasn't a
133 * directory or something */
134 @@ -172,9 +172,9 @@ cache_next_pkg(cache_cat_ctx *cat_ctx)
135 ctx->ebuilddir_cat_ctx->name = cat_ctx->name;
136 }
137
138 - ret = q_vdb_next_pkg(ctx->ebuilddir_cat_ctx);
139 + ret = vdb_next_pkg(ctx->ebuilddir_cat_ctx);
140 if (ret == NULL) {
141 - q_vdb_close_cat(ctx->ebuilddir_cat_ctx);
142 + vdb_close_cat(ctx->ebuilddir_cat_ctx);
143 ctx->ebuilddir_pkg_ctx = NULL;
144 } else {
145 if ((p = strstr(ret->name, ".ebuild")) == NULL) {
146 @@ -186,7 +186,7 @@ cache_next_pkg(cache_cat_ctx *cat_ctx)
147 }
148 } while (ret == NULL);
149 } else {
150 - ret = q_vdb_next_pkg(cat_ctx);
151 + ret = vdb_next_pkg(cat_ctx);
152 }
153
154 return ret;
155 @@ -627,16 +627,16 @@ cache_close_metadata(cache_metadata_xml *meta_ctx)
156 void
157 cache_close_pkg(cache_pkg_ctx *pkg_ctx)
158 {
159 - /* avoid free of cache_ctx' repo by q_vdb_close_pkg */
160 + /* avoid free of cache_ctx' repo by vdb_close_pkg */
161 if (pkg_ctx->cat_ctx->ctx->repo == pkg_ctx->repo)
162 pkg_ctx->repo = NULL;
163
164 - q_vdb_close_pkg(pkg_ctx);
165 + vdb_close_pkg(pkg_ctx);
166 }
167
168 static int
169 cache_foreach_pkg_int(const char *sroot, const char *portdir,
170 - q_vdb_pkg_cb callback, void *priv, q_vdb_cat_filter filter,
171 + vdb_pkg_cb callback, void *priv, vdb_cat_filter filter,
172 bool sort, void *catsortfunc, void *pkgsortfunc)
173 {
174 cache_ctx *ctx;
175 @@ -671,7 +671,7 @@ cache_foreach_pkg_int(const char *sroot, const char *portdir,
176
177 int
178 cache_foreach_pkg(const char *sroot, const char *portdir,
179 - q_vdb_pkg_cb callback, void *priv, q_vdb_cat_filter filter)
180 + vdb_pkg_cb callback, void *priv, vdb_cat_filter filter)
181 {
182 return cache_foreach_pkg_int(sroot, portdir, callback, priv,
183 filter, false, NULL, NULL);
184 @@ -679,7 +679,7 @@ cache_foreach_pkg(const char *sroot, const char *portdir,
185
186 int
187 cache_foreach_pkg_sorted(const char *sroot, const char *portdir,
188 - q_vdb_pkg_cb callback, void *priv,
189 + vdb_pkg_cb callback, void *priv,
190 void *catsortfunc, void *pkgsortfunc)
191 {
192 return cache_foreach_pkg_int(sroot, portdir, callback, priv,
193
194 diff --git a/libq/cache.h b/libq/cache.h
195 index 2ad2e78..e863daf 100644
196 --- a/libq/cache.h
197 +++ b/libq/cache.h
198 @@ -13,9 +13,9 @@
199 #include "atom.h"
200 #include "vdb.h"
201
202 -#define cache_ctx q_vdb_ctx
203 -#define cache_cat_ctx q_vdb_cat_ctx
204 -#define cache_pkg_ctx q_vdb_pkg_ctx
205 +#define cache_ctx vdb_ctx
206 +#define cache_cat_ctx vdb_cat_ctx
207 +#define cache_pkg_ctx vdb_pkg_ctx
208
209 typedef struct {
210 char *_data;
211
212 diff --git a/libq/vdb.c b/libq/vdb.c
213 index 034a28c..5dc5e79 100644
214 --- a/libq/vdb.c
215 +++ b/libq/vdb.c
216 @@ -18,10 +18,10 @@
217 #include <ctype.h>
218 #include <xalloc.h>
219
220 -q_vdb_ctx *
221 -q_vdb_open2(const char *sroot, const char *svdb, bool quiet)
222 +vdb_ctx *
223 +vdb_open2(const char *sroot, const char *svdb, bool quiet)
224 {
225 - q_vdb_ctx *ctx = xmalloc(sizeof(*ctx));
226 + vdb_ctx *ctx = xmalloc(sizeof(*ctx));
227
228 ctx->portroot_fd = open(sroot, O_RDONLY|O_CLOEXEC|O_PATH);
229 if (ctx->portroot_fd == -1) {
230 @@ -64,14 +64,14 @@ q_vdb_open2(const char *sroot, const char *svdb, bool quiet)
231 return NULL;
232 }
233
234 -q_vdb_ctx *
235 -q_vdb_open(const char *sroot, const char *svdb)
236 +vdb_ctx *
237 +vdb_open(const char *sroot, const char *svdb)
238 {
239 - return q_vdb_open2(sroot, svdb, false);
240 + return vdb_open2(sroot, svdb, false);
241 }
242
243 void
244 -q_vdb_close(q_vdb_ctx *ctx)
245 +vdb_close(vdb_ctx *ctx)
246 {
247 closedir(ctx->dir);
248 /* closedir() above does this for us: */
249 @@ -83,7 +83,7 @@ q_vdb_close(q_vdb_ctx *ctx)
250 }
251
252 int
253 -q_vdb_filter_cat(const struct dirent *de)
254 +vdb_filter_cat(const struct dirent *de)
255 {
256 int i;
257 bool founddash;
258 @@ -124,10 +124,10 @@ q_vdb_filter_cat(const struct dirent *de)
259 return i;
260 }
261
262 -q_vdb_cat_ctx *
263 -q_vdb_open_cat(q_vdb_ctx *ctx, const char *name)
264 +vdb_cat_ctx *
265 +vdb_open_cat(vdb_ctx *ctx, const char *name)
266 {
267 - q_vdb_cat_ctx *cat_ctx;
268 + vdb_cat_ctx *cat_ctx;
269 int fd;
270 DIR *dir;
271
272 @@ -151,21 +151,21 @@ q_vdb_open_cat(q_vdb_ctx *ctx, const char *name)
273 return cat_ctx;
274 }
275
276 -q_vdb_cat_ctx *
277 -q_vdb_next_cat(q_vdb_ctx *ctx)
278 +vdb_cat_ctx *
279 +vdb_next_cat(vdb_ctx *ctx)
280 {
281 /* search for a category directory */
282 - q_vdb_cat_ctx *cat_ctx = NULL;
283 + vdb_cat_ctx *cat_ctx = NULL;
284
285 if (ctx->do_sort) {
286 if (ctx->cat_de == NULL) {
287 ctx->cat_cnt = scandirat(ctx->vdb_fd,
288 - ".", &ctx->cat_de, q_vdb_filter_cat, ctx->catsortfunc);
289 + ".", &ctx->cat_de, vdb_filter_cat, ctx->catsortfunc);
290 ctx->cat_cur = 0;
291 }
292
293 while (ctx->cat_cur < ctx->cat_cnt) {
294 - cat_ctx = q_vdb_open_cat(ctx, ctx->cat_de[ctx->cat_cur++]->d_name);
295 + cat_ctx = vdb_open_cat(ctx, ctx->cat_de[ctx->cat_cur++]->d_name);
296 if (!cat_ctx)
297 continue;
298 break;
299 @@ -178,10 +178,10 @@ q_vdb_next_cat(q_vdb_ctx *ctx)
300 if (!de)
301 break;
302
303 - if (q_vdb_filter_cat(de) == 0)
304 + if (vdb_filter_cat(de) == 0)
305 continue;
306
307 - cat_ctx = q_vdb_open_cat(ctx, de->d_name);
308 + cat_ctx = vdb_open_cat(ctx, de->d_name);
309 if (!cat_ctx)
310 continue;
311
312 @@ -193,7 +193,7 @@ q_vdb_next_cat(q_vdb_ctx *ctx)
313 }
314
315 void
316 -q_vdb_close_cat(q_vdb_cat_ctx *cat_ctx)
317 +vdb_close_cat(vdb_cat_ctx *cat_ctx)
318 {
319 closedir(cat_ctx->dir);
320 /* closedir() above does this for us: */
321 @@ -204,7 +204,7 @@ q_vdb_close_cat(q_vdb_cat_ctx *cat_ctx)
322 }
323
324 int
325 -q_vdb_filter_pkg(const struct dirent *de)
326 +vdb_filter_pkg(const struct dirent *de)
327 {
328 int i;
329 bool founddash = false;
330 @@ -235,33 +235,34 @@ q_vdb_filter_pkg(const struct dirent *de)
331 return i;
332 }
333
334 -q_vdb_pkg_ctx *
335 -q_vdb_open_pkg(q_vdb_cat_ctx *cat_ctx, const char *name)
336 +vdb_pkg_ctx *
337 +vdb_open_pkg(vdb_cat_ctx *cat_ctx, const char *name)
338 {
339 - q_vdb_pkg_ctx *pkg_ctx = xmalloc(sizeof(*pkg_ctx));
340 + vdb_pkg_ctx *pkg_ctx = xmalloc(sizeof(*pkg_ctx));
341 pkg_ctx->name = name;
342 pkg_ctx->slot = NULL;
343 pkg_ctx->repo = cat_ctx->ctx->repo;
344 pkg_ctx->fd = -1;
345 pkg_ctx->cat_ctx = cat_ctx;
346 + pkg_ctx->atom = NULL;
347 return pkg_ctx;
348 }
349
350 -q_vdb_pkg_ctx *
351 -q_vdb_next_pkg(q_vdb_cat_ctx *cat_ctx)
352 +vdb_pkg_ctx *
353 +vdb_next_pkg(vdb_cat_ctx *cat_ctx)
354 {
355 - q_vdb_pkg_ctx *pkg_ctx = NULL;
356 + vdb_pkg_ctx *pkg_ctx = NULL;
357
358 if (cat_ctx->ctx->do_sort) {
359 if (cat_ctx->pkg_de == NULL) {
360 cat_ctx->pkg_cnt = scandirat(cat_ctx->fd, ".", &cat_ctx->pkg_de,
361 - q_vdb_filter_pkg, cat_ctx->ctx->pkgsortfunc);
362 + vdb_filter_pkg, cat_ctx->ctx->pkgsortfunc);
363 cat_ctx->pkg_cur = 0;
364 }
365
366 while (cat_ctx->pkg_cur < cat_ctx->pkg_cnt) {
367 pkg_ctx =
368 - q_vdb_open_pkg(cat_ctx,
369 + vdb_open_pkg(cat_ctx,
370 cat_ctx->pkg_de[cat_ctx->pkg_cur++]->d_name);
371 if (!pkg_ctx)
372 continue;
373 @@ -274,10 +275,10 @@ q_vdb_next_pkg(q_vdb_cat_ctx *cat_ctx)
374 if (!de)
375 break;
376
377 - if (q_vdb_filter_pkg(de) == 0)
378 + if (vdb_filter_pkg(de) == 0)
379 continue;
380
381 - pkg_ctx = q_vdb_open_pkg(cat_ctx, de->d_name);
382 + pkg_ctx = vdb_open_pkg(cat_ctx, de->d_name);
383 if (!pkg_ctx)
384 continue;
385
386 @@ -289,7 +290,7 @@ q_vdb_next_pkg(q_vdb_cat_ctx *cat_ctx)
387 }
388
389 int
390 -q_vdb_pkg_openat(q_vdb_pkg_ctx *pkg_ctx, const char *file, int flags, mode_t mode)
391 +vdb_pkg_openat(vdb_pkg_ctx *pkg_ctx, const char *file, int flags, mode_t mode)
392 {
393 if (pkg_ctx->fd == -1) {
394 pkg_ctx->fd = openat(pkg_ctx->cat_ctx->fd, pkg_ctx->name,
395 @@ -302,13 +303,13 @@ q_vdb_pkg_openat(q_vdb_pkg_ctx *pkg_ctx, const char *file, int flags, mode_t mod
396 }
397
398 FILE *
399 -q_vdb_pkg_fopenat(q_vdb_pkg_ctx *pkg_ctx, const char *file,
400 +vdb_pkg_fopenat(vdb_pkg_ctx *pkg_ctx, const char *file,
401 int flags, mode_t mode, const char *fmode)
402 {
403 FILE *fp;
404 int fd;
405
406 - fd = q_vdb_pkg_openat(pkg_ctx, file, flags, mode);
407 + fd = vdb_pkg_openat(pkg_ctx, file, flags, mode);
408 if (fd == -1)
409 return NULL;
410
411 @@ -320,9 +321,9 @@ q_vdb_pkg_fopenat(q_vdb_pkg_ctx *pkg_ctx, const char *file,
412 }
413
414 bool
415 -q_vdb_pkg_eat(q_vdb_pkg_ctx *pkg_ctx, const char *file, char **bufptr, size_t *buflen)
416 +vdb_pkg_eat(vdb_pkg_ctx *pkg_ctx, const char *file, char **bufptr, size_t *buflen)
417 {
418 - int fd = q_vdb_pkg_openat(pkg_ctx, file, O_RDONLY, 0);
419 + int fd = vdb_pkg_openat(pkg_ctx, file, O_RDONLY, 0);
420 bool ret = eat_file_fd(fd, bufptr, buflen);
421 rmspace(*bufptr);
422 if (fd != -1)
423 @@ -331,7 +332,7 @@ q_vdb_pkg_eat(q_vdb_pkg_ctx *pkg_ctx, const char *file, char **bufptr, size_t *b
424 }
425
426 void
427 -q_vdb_close_pkg(q_vdb_pkg_ctx *pkg_ctx)
428 +vdb_close_pkg(vdb_pkg_ctx *pkg_ctx)
429 {
430 if (pkg_ctx->fd != -1)
431 close(pkg_ctx->fd);
432 @@ -343,16 +344,16 @@ q_vdb_close_pkg(q_vdb_pkg_ctx *pkg_ctx)
433 }
434
435 static int
436 -q_vdb_foreach_pkg_int(const char *sroot, const char *svdb,
437 - q_vdb_pkg_cb callback, void *priv, q_vdb_cat_filter filter,
438 +vdb_foreach_pkg_int(const char *sroot, const char *svdb,
439 + vdb_pkg_cb callback, void *priv, vdb_cat_filter filter,
440 bool sort, void *catsortfunc, void *pkgsortfunc)
441 {
442 - q_vdb_ctx *ctx;
443 - q_vdb_cat_ctx *cat_ctx;
444 - q_vdb_pkg_ctx *pkg_ctx;
445 + vdb_ctx *ctx;
446 + vdb_cat_ctx *cat_ctx;
447 + vdb_pkg_ctx *pkg_ctx;
448 int ret;
449
450 - ctx = q_vdb_open(sroot, svdb);
451 + ctx = vdb_open(sroot, svdb);
452 if (!ctx)
453 return EXIT_FAILURE;
454
455 @@ -363,38 +364,38 @@ q_vdb_foreach_pkg_int(const char *sroot, const char *svdb,
456 ctx->pkgsortfunc = pkgsortfunc;
457
458 ret = 0;
459 - while ((cat_ctx = q_vdb_next_cat(ctx))) {
460 + while ((cat_ctx = vdb_next_cat(ctx))) {
461 if (filter && !filter(cat_ctx, priv))
462 continue;
463 - while ((pkg_ctx = q_vdb_next_pkg(cat_ctx))) {
464 + while ((pkg_ctx = vdb_next_pkg(cat_ctx))) {
465 ret |= callback(pkg_ctx, priv);
466 - q_vdb_close_pkg(pkg_ctx);
467 + vdb_close_pkg(pkg_ctx);
468 }
469 - q_vdb_close_cat(cat_ctx);
470 + vdb_close_cat(cat_ctx);
471 }
472 - q_vdb_close(ctx);
473 + vdb_close(ctx);
474
475 return ret;
476 }
477
478 int
479 -q_vdb_foreach_pkg(const char *sroot, const char *svdb,
480 - q_vdb_pkg_cb callback, void *priv, q_vdb_cat_filter filter)
481 +vdb_foreach_pkg(const char *sroot, const char *svdb,
482 + vdb_pkg_cb callback, void *priv, vdb_cat_filter filter)
483 {
484 - return q_vdb_foreach_pkg_int(sroot, svdb, callback, priv,
485 + return vdb_foreach_pkg_int(sroot, svdb, callback, priv,
486 filter, false, NULL, NULL);
487 }
488
489 int
490 -q_vdb_foreach_pkg_sorted(const char *sroot, const char *svdb,
491 - q_vdb_pkg_cb callback, void *priv)
492 +vdb_foreach_pkg_sorted(const char *sroot, const char *svdb,
493 + vdb_pkg_cb callback, void *priv)
494 {
495 - return q_vdb_foreach_pkg_int(sroot, svdb, callback, priv,
496 + return vdb_foreach_pkg_int(sroot, svdb, callback, priv,
497 NULL, true, NULL, NULL);
498 }
499
500 struct dirent *
501 -q_vdb_get_next_dir(DIR *dir)
502 +vdb_get_next_dir(DIR *dir)
503 {
504 /* search for a category directory */
505 struct dirent *ret;
506 @@ -406,23 +407,23 @@ next_entry:
507 return NULL;
508 }
509
510 - if (q_vdb_filter_cat(ret) == 0)
511 + if (vdb_filter_cat(ret) == 0)
512 goto next_entry;
513
514 return ret;
515 }
516
517 depend_atom *
518 -q_vdb_get_atom(q_vdb_pkg_ctx *pkg_ctx)
519 +vdb_get_atom(vdb_pkg_ctx *pkg_ctx)
520 {
521 pkg_ctx->atom = atom_explode(pkg_ctx->name);
522 if (pkg_ctx->atom == NULL)
523 return NULL;
524 pkg_ctx->atom->CATEGORY = (char *)pkg_ctx->cat_ctx->name;
525
526 - q_vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot, &pkg_ctx->slot_len);
527 + vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot, &pkg_ctx->slot_len);
528 pkg_ctx->atom->SLOT = pkg_ctx->slot;
529 - q_vdb_pkg_eat(pkg_ctx, "repository", &pkg_ctx->repo, &pkg_ctx->repo_len);
530 + vdb_pkg_eat(pkg_ctx, "repository", &pkg_ctx->repo, &pkg_ctx->repo_len);
531 pkg_ctx->atom->REPO = pkg_ctx->repo;
532
533 return pkg_ctx->atom;
534 @@ -431,7 +432,7 @@ q_vdb_get_atom(q_vdb_pkg_ctx *pkg_ctx)
535 set *
536 get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv)
537 {
538 - q_vdb_ctx *ctx;
539 + vdb_ctx *ctx;
540
541 int cfd, j;
542 int dfd, i;
543 @@ -447,18 +448,18 @@ get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv)
544 depend_atom *atom = NULL;
545 set *cpf = NULL;
546
547 - ctx = q_vdb_open(sroot, svdb);
548 + ctx = vdb_open(sroot, svdb);
549 if (!ctx)
550 return NULL;
551
552 /* scan the cat first */
553 - cfd = scandirat(ctx->vdb_fd, ".", &cat, q_vdb_filter_cat, alphasort);
554 + cfd = scandirat(ctx->vdb_fd, ".", &cat, vdb_filter_cat, alphasort);
555 if (cfd < 0)
556 goto fuckit;
557
558 for (j = 0; j < cfd; j++) {
559 dfd = scandirat(ctx->vdb_fd, cat[j]->d_name,
560 - &pf, q_vdb_filter_pkg, alphasort);
561 + &pf, vdb_filter_pkg, alphasort);
562 if (dfd < 0)
563 continue;
564 for (i = 0; i < dfd; i++) {
565 @@ -499,6 +500,6 @@ get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv)
566 scandir_free(cat, cfd);
567
568 fuckit:
569 - q_vdb_close(ctx);
570 + vdb_close(ctx);
571 return cpf;
572 }
573
574 diff --git a/libq/vdb.h b/libq/vdb.h
575 index 3cfa95b..2954bef 100644
576 --- a/libq/vdb.h
577 +++ b/libq/vdb.h
578 @@ -11,12 +11,12 @@
579
580 #include "set.h"
581
582 -typedef struct q_vdb_ctx q_vdb_ctx;
583 -typedef struct q_vdb_cat_ctx q_vdb_cat_ctx;
584 -typedef struct q_vdb_pkg_ctx q_vdb_pkg_ctx;
585 +typedef struct vdb_ctx vdb_ctx;
586 +typedef struct vdb_cat_ctx vdb_cat_ctx;
587 +typedef struct vdb_pkg_ctx vdb_pkg_ctx;
588
589 /* VDB context */
590 -struct q_vdb_ctx {
591 +struct vdb_ctx {
592 int portroot_fd;
593 int vdb_fd;
594 DIR *dir;
595 @@ -33,64 +33,64 @@ struct q_vdb_ctx {
596 CACHE_EBUILD,
597 CACHE_VDB,
598 } cachetype:3;
599 - q_vdb_pkg_ctx *ebuilddir_pkg_ctx;
600 - q_vdb_cat_ctx *ebuilddir_cat_ctx;
601 - q_vdb_ctx *ebuilddir_ctx;
602 + vdb_pkg_ctx *ebuilddir_pkg_ctx;
603 + vdb_cat_ctx *ebuilddir_cat_ctx;
604 + vdb_ctx *ebuilddir_ctx;
605 char *repo;
606 };
607
608 /* Category context */
609 -struct q_vdb_cat_ctx {
610 +struct vdb_cat_ctx {
611 const char *name;
612 int fd;
613 DIR *dir;
614 - const q_vdb_ctx *ctx;
615 + const vdb_ctx *ctx;
616 struct dirent **pkg_de;
617 size_t pkg_cnt;
618 size_t pkg_cur;
619 };
620
621 /* Package context */
622 -struct q_vdb_pkg_ctx {
623 +struct vdb_pkg_ctx {
624 const char *name;
625 char *slot;
626 char *repo;
627 size_t slot_len;
628 size_t repo_len;
629 int fd;
630 - q_vdb_cat_ctx *cat_ctx;
631 + vdb_cat_ctx *cat_ctx;
632 depend_atom *atom;
633 };
634
635 /* Global helpers */
636 -typedef int (q_vdb_pkg_cb)(q_vdb_pkg_ctx *, void *priv);
637 -typedef int (q_vdb_cat_filter)(q_vdb_cat_ctx *, void *priv);
638 +typedef int (vdb_pkg_cb)(vdb_pkg_ctx *, void *priv);
639 +typedef int (vdb_cat_filter)(vdb_cat_ctx *, void *priv);
640
641 -q_vdb_ctx *q_vdb_open(const char *sroot, const char *svdb);
642 -q_vdb_ctx *q_vdb_open2(const char *sroot, const char *svdb, bool quiet);
643 -void q_vdb_close(q_vdb_ctx *ctx);
644 -int q_vdb_filter_cat(const struct dirent *de);
645 -q_vdb_cat_ctx *q_vdb_open_cat(q_vdb_ctx *ctx, const char *name);
646 -q_vdb_cat_ctx *q_vdb_next_cat(q_vdb_ctx *ctx);
647 -void q_vdb_close_cat(q_vdb_cat_ctx *cat_ctx);
648 -int q_vdb_filter_pkg(const struct dirent *de);
649 -q_vdb_pkg_ctx *q_vdb_open_pkg(q_vdb_cat_ctx *cat_ctx, const char *name);
650 -q_vdb_pkg_ctx *q_vdb_next_pkg(q_vdb_cat_ctx *cat_ctx);
651 -int q_vdb_pkg_openat(q_vdb_pkg_ctx *pkg_ctx, const char *file, int flags, mode_t mode);
652 -FILE *q_vdb_pkg_fopenat(q_vdb_pkg_ctx *pkg_ctx, const char *file,
653 +vdb_ctx *vdb_open(const char *sroot, const char *svdb);
654 +vdb_ctx *vdb_open2(const char *sroot, const char *svdb, bool quiet);
655 +void vdb_close(vdb_ctx *ctx);
656 +int vdb_filter_cat(const struct dirent *de);
657 +vdb_cat_ctx *vdb_open_cat(vdb_ctx *ctx, const char *name);
658 +vdb_cat_ctx *vdb_next_cat(vdb_ctx *ctx);
659 +void vdb_close_cat(vdb_cat_ctx *cat_ctx);
660 +int vdb_filter_pkg(const struct dirent *de);
661 +vdb_pkg_ctx *vdb_open_pkg(vdb_cat_ctx *cat_ctx, const char *name);
662 +vdb_pkg_ctx *vdb_next_pkg(vdb_cat_ctx *cat_ctx);
663 +int vdb_pkg_openat(vdb_pkg_ctx *pkg_ctx, const char *file, int flags, mode_t mode);
664 +FILE *vdb_pkg_fopenat(vdb_pkg_ctx *pkg_ctx, const char *file,
665 int flags, mode_t mode, const char *fmode);
666 -#define q_vdb_pkg_fopenat_ro(pkg_ctx, file) \
667 - q_vdb_pkg_fopenat(pkg_ctx, file, O_RDONLY, 0, "r")
668 -#define q_vdb_pkg_fopenat_rw(pkg_ctx, file) \
669 - q_vdb_pkg_fopenat(pkg_ctx, file, O_RDWR|O_CREAT|O_TRUNC, 0644, "w")
670 -bool q_vdb_pkg_eat(q_vdb_pkg_ctx *pkg_ctx, const char *file, char **bufptr, size_t *buflen);
671 -void q_vdb_close_pkg(q_vdb_pkg_ctx *pkg_ctx);
672 -int q_vdb_foreach_pkg(const char *sroot, const char *svdb,
673 - q_vdb_pkg_cb callback, void *priv, q_vdb_cat_filter filter);
674 -int q_vdb_foreach_pkg_sorted(const char *sroot, const char *svdb,
675 - q_vdb_pkg_cb callback, void *priv);
676 -struct dirent *q_vdb_get_next_dir(DIR *dir);
677 +#define vdb_pkg_fopenat_ro(pkg_ctx, file) \
678 + vdb_pkg_fopenat(pkg_ctx, file, O_RDONLY, 0, "r")
679 +#define vdb_pkg_fopenat_rw(pkg_ctx, file) \
680 + vdb_pkg_fopenat(pkg_ctx, file, O_RDWR|O_CREAT|O_TRUNC, 0644, "w")
681 +bool vdb_pkg_eat(vdb_pkg_ctx *pkg_ctx, const char *file, char **bufptr, size_t *buflen);
682 +void vdb_close_pkg(vdb_pkg_ctx *pkg_ctx);
683 +int vdb_foreach_pkg(const char *sroot, const char *svdb,
684 + vdb_pkg_cb callback, void *priv, vdb_cat_filter filter);
685 +int vdb_foreach_pkg_sorted(const char *sroot, const char *svdb,
686 + vdb_pkg_cb callback, void *priv);
687 +struct dirent *vdb_get_next_dir(DIR *dir);
688 set *get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv);
689 -depend_atom *q_vdb_get_atom(q_vdb_pkg_ctx *pkg_ctx);
690 +depend_atom *vdb_get_atom(vdb_pkg_ctx *pkg_ctx);
691
692 #endif
693
694 diff --git a/qcheck.c b/qcheck.c
695 index 0585396..377a187 100644
696 --- a/qcheck.c
697 +++ b/qcheck.c
698 @@ -65,7 +65,7 @@ struct qcheck_opt_state {
699 };
700
701 static int
702 -qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
703 +qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
704 {
705 int fd_contents;
706 FILE *fp_contents, *fp_contents_update;
707 @@ -81,7 +81,7 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
708 fp_contents_update = NULL;
709
710 /* Open contents */
711 - fd_contents = q_vdb_pkg_openat(pkg_ctx, "CONTENTS", O_RDONLY|O_CLOEXEC, 0);
712 + fd_contents = vdb_pkg_openat(pkg_ctx, "CONTENTS", O_RDONLY|O_CLOEXEC, 0);
713 if (fd_contents == -1)
714 return EXIT_SUCCESS;
715 if (fstat(fd_contents, &cst)) {
716 @@ -99,7 +99,7 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
717 (state->qc_update ? "Updat" : "Check"),
718 GREEN, catname, pkgname, NORM);
719 if (state->qc_update) {
720 - fp_contents_update = q_vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~");
721 + fp_contents_update = vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~");
722 if (fp_contents_update == NULL) {
723 fclose(fp_contents);
724 warnp("unable to fopen(%s/%s, w)", pkgname, "CONTENTS~");
725 @@ -363,7 +363,7 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
726 }
727
728 static int
729 -qcheck_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
730 +qcheck_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
731 {
732 struct qcheck_opt_state *state = priv;
733 const char *catname = pkg_ctx->cat_ctx->name;
734 @@ -439,7 +439,7 @@ int qcheck_main(int argc, char **argv)
735 xarraypush_ptr(atoms, atom);
736 }
737
738 - ret = q_vdb_foreach_pkg_sorted(portroot, portvdb, qcheck_cb, &state);
739 + ret = vdb_foreach_pkg_sorted(portroot, portvdb, qcheck_cb, &state);
740 {
741 void *regex;
742 array_for_each(regex_arr, i, regex)
743
744 diff --git a/qdepends.c b/qdepends.c
745 index 7bb8818..e49e533 100644
746 --- a/qdepends.c
747 +++ b/qdepends.c
748 @@ -92,7 +92,7 @@ qdepends_print_depend(FILE *fp, const char *depend)
749 }
750
751 static int
752 -qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
753 +qdepends_results_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
754 {
755 struct qdepends_opt_state *state = priv;
756 depend_atom *atom;
757 @@ -116,7 +116,7 @@ qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
758 * *DEPEND alters the search somewhat and affects results printing.
759 */
760
761 - datom = q_vdb_get_atom(pkg_ctx);
762 + datom = vdb_get_atom(pkg_ctx);
763 if (datom == NULL)
764 return ret;
765
766 @@ -145,7 +145,7 @@ qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
767 for (i = QMODE_DEPEND; i <= QMODE_BDEPEND; i <<= 1, dfile++) {
768 if (!(state->qmode & i))
769 continue;
770 - if (!q_vdb_pkg_eat(pkg_ctx, *dfile,
771 + if (!vdb_pkg_eat(pkg_ctx, *dfile,
772 &state->depend, &state->depend_len))
773 continue;
774
775 @@ -302,7 +302,7 @@ int qdepends_main(int argc, char **argv)
776 xarraypush_ptr(atoms, atom);
777 }
778
779 - ret = q_vdb_foreach_pkg(portroot, portvdb,
780 + ret = vdb_foreach_pkg(portroot, portvdb,
781 qdepends_results_cb, &state, NULL);
782
783 if (state.depend != NULL)
784
785 diff --git a/qfile.c b/qfile.c
786 index 19b156e..3d1543e 100644
787 --- a/qfile.c
788 +++ b/qfile.c
789 @@ -74,7 +74,7 @@ struct qfile_opt_state {
790 * We assume the people calling us have chdir(/var/db/pkg) and so
791 * we use relative paths throughout here.
792 */
793 -static int qfile_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
794 +static int qfile_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
795 {
796 struct qfile_opt_state *state = priv;
797 const char *catname = pkg_ctx->cat_ctx->name;
798 @@ -115,14 +115,14 @@ static int qfile_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
799 }
800 if (state->exclude_slot == NULL)
801 goto qlist_done; /* "(CAT/)?(PN|PF)" matches, and no SLOT specified */
802 - q_vdb_pkg_eat(pkg_ctx, "SLOT", &state->buf, &state->buflen);
803 + vdb_pkg_eat(pkg_ctx, "SLOT", &state->buf, &state->buflen);
804 rmspace(state->buf);
805 if (strcmp(state->exclude_slot, state->buf) == 0)
806 goto qlist_done; /* "(CAT/)?(PN|PF):SLOT" matches */
807 }
808 dont_skip_pkg: /* End of the package exclusion tests. */
809
810 - fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
811 + fp = vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
812 if (fp == NULL)
813 goto qlist_done;
814
815 @@ -227,7 +227,7 @@ static int qfile_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
816 /* XXX: This assumes the buf is big enough. */
817 char *slot_hack = slot + 1;
818 size_t slot_len = sizeof(slot) - 1;
819 - q_vdb_pkg_eat(pkg_ctx, "SLOT", &slot_hack, &slot_len);
820 + vdb_pkg_eat(pkg_ctx, "SLOT", &slot_hack, &slot_len);
821 rmspace(slot_hack);
822 slot[0] = ':';
823 } else
824 @@ -479,7 +479,7 @@ int qfile_main(int argc, char **argv)
825 nb_of_queries = prepare_qfile_args(argc, (const char **) argv, &state);
826 /* Now do the actual `qfile` checking */
827 if (nb_of_queries > 0)
828 - found += q_vdb_foreach_pkg_sorted(portroot, portvdb, qfile_cb, &state);
829 + found += vdb_foreach_pkg_sorted(portroot, portvdb, qfile_cb, &state);
830
831 if (state.args.non_orphans) {
832 /* display orphan files */
833
834 diff --git a/qgrep.c b/qgrep.c
835 index 6cb5697..f38f461 100644
836 --- a/qgrep.c
837 +++ b/qgrep.c
838 @@ -441,7 +441,7 @@ qgrep_cache_cb(cache_pkg_ctx *pkg_ctx, void *priv)
839 }
840
841 static int
842 -qgrep_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
843 +qgrep_vdb_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
844 {
845 struct qgrep_grepargs *data = (struct qgrep_grepargs *)priv;
846 char buf[_Q_PATH_MAX];
847 @@ -687,7 +687,7 @@ int qgrep_main(int argc, char **argv)
848 }
849 closedir(eclass_dir);
850 } else if (do_installed) {
851 - status = q_vdb_foreach_pkg(portroot, portvdb,
852 + status = vdb_foreach_pkg(portroot, portvdb,
853 qgrep_vdb_cb, &args, NULL);
854 } else { /* do_ebuild */
855 status = cache_foreach_pkg(portroot, overlay,
856
857 diff --git a/qlist.c b/qlist.c
858 index 313ff56..9314385 100644
859 --- a/qlist.c
860 +++ b/qlist.c
861 @@ -96,7 +96,7 @@ cmpstringp(const void *p1, const void *p2)
862 */
863 static char _umapstr_buf[BUFSIZ];
864 static const char *
865 -umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
866 +umapstr(char display, vdb_pkg_ctx *pkg_ctx)
867 {
868 char *bufp = _umapstr_buf;
869 char *use = NULL;
870 @@ -115,10 +115,10 @@ umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
871 if (!display)
872 return bufp;
873
874 - q_vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len);
875 + vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len);
876 if (!use[0])
877 return bufp;
878 - q_vdb_pkg_eat(pkg_ctx, "IUSE", &iuse, &iuse_len);
879 + vdb_pkg_eat(pkg_ctx, "IUSE", &iuse, &iuse_len);
880 if (!iuse[0])
881 return bufp;
882
883 @@ -173,13 +173,13 @@ umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
884 /* forward declaration necessary for misuse from qmerge.c, see HACK there */
885 bool
886 qlist_match(
887 - q_vdb_pkg_ctx *pkg_ctx,
888 + vdb_pkg_ctx *pkg_ctx,
889 const char *name,
890 depend_atom **name_atom,
891 bool exact);
892 bool
893 qlist_match(
894 - q_vdb_pkg_ctx *pkg_ctx,
895 + vdb_pkg_ctx *pkg_ctx,
896 const char *name,
897 depend_atom **name_atom,
898 bool exact)
899 @@ -200,7 +200,7 @@ qlist_match(
900 uslot = NULL;
901 else {
902 if (!pkg_ctx->slot)
903 - q_vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot,
904 + vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot,
905 &pkg_ctx->slot_len);
906 uslot_len = strlen(uslot);
907 }
908 @@ -209,7 +209,7 @@ qlist_match(
909 urepo = strstr(name, "::");
910 if (urepo) {
911 if (!pkg_ctx->repo)
912 - q_vdb_pkg_eat(pkg_ctx, "repository", &pkg_ctx->repo,
913 + vdb_pkg_eat(pkg_ctx, "repository", &pkg_ctx->repo,
914 &pkg_ctx->repo_len);
915 urepo += 2;
916 urepo_len = strlen(urepo);
917 @@ -338,7 +338,7 @@ struct qlist_opt_state {
918 };
919
920 static int
921 -qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
922 +qlist_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
923 {
924 struct qlist_opt_state *state = priv;
925 int i;
926 @@ -359,7 +359,7 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
927 atom = (verbose ? NULL : atom_explode(pkgname));
928 if ((state->all + state->just_pkgname) < 2) {
929 if (state->show_slots && !pkg_ctx->slot) {
930 - q_vdb_pkg_eat(pkg_ctx, "SLOT",
931 + vdb_pkg_eat(pkg_ctx, "SLOT",
932 &pkg_ctx->slot, &pkg_ctx->slot_len);
933 /* chop off the subslot if desired */
934 if (state->show_slots == 1) {
935 @@ -369,7 +369,7 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
936 }
937 }
938 if (state->show_repo && !pkg_ctx->repo)
939 - q_vdb_pkg_eat(pkg_ctx, "repository",
940 + vdb_pkg_eat(pkg_ctx, "repository",
941 &pkg_ctx->repo, &pkg_ctx->repo_len);
942 /* display it */
943 printf("%s%s/%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
944 @@ -398,7 +398,7 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
945 printf("%s%s/%s%s%s %sCONTENTS%s:\n",
946 BOLD, catname, BLUE, pkgname, NORM, DKBLUE, NORM);
947
948 - fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
949 + fp = vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
950 if (fp == NULL)
951 return 1;
952
953 @@ -489,7 +489,7 @@ int qlist_main(int argc, char **argv)
954
955 state.buf = xmalloc(state.buflen);
956 state.atoms = xcalloc(argc - optind, sizeof(*state.atoms));
957 - ret = q_vdb_foreach_pkg_sorted(portroot, portvdb, qlist_cb, &state);
958 + ret = vdb_foreach_pkg_sorted(portroot, portvdb, qlist_cb, &state);
959 free(state.buf);
960 for (i = optind; i < state.argc; ++i)
961 if (state.atoms[i - optind])
962
963 diff --git a/qmerge.c b/qmerge.c
964 index 97726db..41488fa 100644
965 --- a/qmerge.c
966 +++ b/qmerge.c
967 @@ -118,7 +118,7 @@ typedef struct llist_char_t llist_char;
968
969 static void pkg_fetch(int, const depend_atom *, const struct pkg_t *);
970 static void pkg_merge(int, const depend_atom *, const struct pkg_t *);
971 -static int pkg_unmerge(q_vdb_pkg_ctx *, set *, int, char **, int, char **);
972 +static int pkg_unmerge(vdb_pkg_ctx *, set *, int, char **, int, char **);
973 static struct pkg_t *grab_binpkg_info(const char *);
974 static char *find_binpkg(const char *);
975
976 @@ -282,7 +282,7 @@ struct qmerge_bv_state {
977 };
978
979 static int
980 -qmerge_filter_cat(q_vdb_cat_ctx *cat_ctx, void *priv)
981 +qmerge_filter_cat(vdb_cat_ctx *cat_ctx, void *priv)
982 {
983 struct qmerge_bv_state *state = priv;
984 return !state->catname || strcmp(cat_ctx->name, state->catname) == 0;
985 @@ -292,13 +292,13 @@ qmerge_filter_cat(q_vdb_cat_ctx *cat_ctx, void *priv)
986 * should however figure out how to do what match does here from e.g.
987 * atom */
988 extern bool qlist_match(
989 - q_vdb_pkg_ctx *pkg_ctx,
990 + vdb_pkg_ctx *pkg_ctx,
991 const char *name,
992 depend_atom **name_atom,
993 bool exact);
994
995 static int
996 -qmerge_best_version_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
997 +qmerge_best_version_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
998 {
999 struct qmerge_bv_state *state = priv;
1000 if (qlist_match(pkg_ctx, state->buf, NULL, true))
1001 @@ -338,7 +338,7 @@ best_version(const char *catname, const char *pkgname, const char *slot)
1002 retbuf[0] = '\0';
1003 snprintf(state.buf, sizeof(state.buf), "%s%s%s:%s",
1004 catname ? : "", catname ? "/" : "", pkgname, slot);
1005 - q_vdb_foreach_pkg(portroot, portvdb,
1006 + vdb_foreach_pkg(portroot, portvdb,
1007 qmerge_best_version_cb, &state, qmerge_filter_cat);
1008
1009 done:
1010 @@ -999,8 +999,8 @@ static void
1011 pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
1012 {
1013 set *objs;
1014 - q_vdb_ctx *vdb_ctx;
1015 - q_vdb_cat_ctx *cat_ctx;
1016 + vdb_ctx *vdb;
1017 + vdb_cat_ctx *cat_ctx;
1018 FILE *fp, *contents;
1019 static char *phases;
1020 static size_t phases_len;
1021 @@ -1122,19 +1122,19 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
1022 }
1023
1024 /* Get a handle on the main vdb repo */
1025 - vdb_ctx = q_vdb_open(portroot, portvdb);
1026 - if (!vdb_ctx)
1027 + vdb = vdb_open(portroot, portvdb);
1028 + if (!vdb)
1029 return;
1030 - cat_ctx = q_vdb_open_cat(vdb_ctx, pkg->CATEGORY);
1031 + cat_ctx = vdb_open_cat(vdb, pkg->CATEGORY);
1032 if (!cat_ctx) {
1033 if (errno != ENOENT) {
1034 - q_vdb_close(vdb_ctx);
1035 + vdb_close(vdb);
1036 return;
1037 }
1038 - mkdirat(vdb_ctx->vdb_fd, pkg->CATEGORY, 0755);
1039 - cat_ctx = q_vdb_open_cat(vdb_ctx, pkg->CATEGORY);
1040 + mkdirat(vdb->vdb_fd, pkg->CATEGORY, 0755);
1041 + cat_ctx = vdb_open_cat(vdb, pkg->CATEGORY);
1042 if (!cat_ctx) {
1043 - q_vdb_close(vdb_ctx);
1044 + vdb_close(vdb);
1045 return;
1046 }
1047 }
1048 @@ -1345,10 +1345,10 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
1049 /* TODO: Should see about merging with unmerge_packages() */
1050 while (1) {
1051 int ret;
1052 - q_vdb_pkg_ctx *pkg_ctx;
1053 + vdb_pkg_ctx *pkg_ctx;
1054 depend_atom *old_atom;
1055
1056 - pkg_ctx = q_vdb_next_pkg(cat_ctx);
1057 + pkg_ctx = vdb_next_pkg(cat_ctx);
1058 if (!pkg_ctx)
1059 break;
1060
1061 @@ -1377,7 +1377,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
1062
1063 pkg_unmerge(pkg_ctx, objs, cp_argc, cp_argv, cpm_argc, cpm_argv);
1064 next_pkg:
1065 - q_vdb_close_pkg(pkg_ctx);
1066 + vdb_close_pkg(pkg_ctx);
1067 }
1068
1069 freeargv(cp_argc, cp_argv);
1070 @@ -1416,14 +1416,14 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
1071 printf("%s>>>%s %s%s%s/%s%s%s\n",
1072 YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, atom->PN, NORM);
1073
1074 - q_vdb_close(vdb_ctx);
1075 + vdb_close(vdb);
1076 }
1077
1078 static int
1079 -pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, set *keep,
1080 +pkg_unmerge(vdb_pkg_ctx *pkg_ctx, set *keep,
1081 int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
1082 {
1083 - q_vdb_cat_ctx *cat_ctx = pkg_ctx->cat_ctx;
1084 + vdb_cat_ctx *cat_ctx = pkg_ctx->cat_ctx;
1085 const char *cat = cat_ctx->name;
1086 const char *pkgname = pkg_ctx->name;
1087 size_t buflen;
1088 @@ -1447,7 +1447,7 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, set *keep,
1089 return 0;
1090
1091 /* First get a handle on the things to clean up */
1092 - fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
1093 + fp = vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
1094 if (fp == NULL)
1095 return ret;
1096
1097 @@ -1455,7 +1455,7 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, set *keep,
1098
1099 /* Then execute the pkg_prerm step */
1100 if (!pretend) {
1101 - q_vdb_pkg_eat(pkg_ctx, "DEFINED_PHASES", &phases, &phases_len);
1102 + vdb_pkg_eat(pkg_ctx, "DEFINED_PHASES", &phases, &phases_len);
1103 mkdirat(pkg_ctx->fd, "temp", 0755);
1104 pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_prerm", T, T);
1105 }
1106 @@ -1776,7 +1776,7 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
1107 }
1108
1109 static int
1110 -qmerge_unmerge_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
1111 +qmerge_unmerge_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
1112 {
1113 int cp_argc;
1114 int cpm_argc;
1115 @@ -1804,7 +1804,7 @@ qmerge_unmerge_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
1116 static int
1117 unmerge_packages(set *todo)
1118 {
1119 - return q_vdb_foreach_pkg(portroot, portvdb, qmerge_unmerge_cb, todo, NULL);
1120 + return vdb_foreach_pkg(portroot, portvdb, qmerge_unmerge_cb, todo, NULL);
1121 }
1122
1123 static FILE *
1124
1125 diff --git a/qpkg.c b/qpkg.c
1126 index af8df37..b93823b 100644
1127 --- a/qpkg.c
1128 +++ b/qpkg.c
1129 @@ -334,9 +334,9 @@ qpkg_make(depend_atom *atom)
1130
1131 int qpkg_main(int argc, char **argv)
1132 {
1133 - q_vdb_ctx *ctx;
1134 - q_vdb_cat_ctx *cat_ctx;
1135 - q_vdb_pkg_ctx *pkg_ctx;
1136 + vdb_ctx *ctx;
1137 + vdb_cat_ctx *cat_ctx;
1138 + vdb_pkg_ctx *pkg_ctx;
1139 size_t s, pkgs_made;
1140 int i;
1141 struct stat st;
1142 @@ -417,15 +417,15 @@ retry_mkdir:
1143 }
1144
1145 /* now try to run through vdb and locate matches for user inputs */
1146 - ctx = q_vdb_open(portroot, portvdb);
1147 + ctx = vdb_open(portroot, portvdb);
1148 if (!ctx)
1149 return EXIT_FAILURE;
1150
1151 /* scan all the categories */
1152 - while ((cat_ctx = q_vdb_next_cat(ctx))) {
1153 + while ((cat_ctx = vdb_next_cat(ctx))) {
1154 /* scan all the packages in this category */
1155 const char *catname = cat_ctx->name;
1156 - while ((pkg_ctx = q_vdb_next_pkg(cat_ctx))) {
1157 + while ((pkg_ctx = vdb_next_pkg(cat_ctx))) {
1158 const char *pkgname = pkg_ctx->name;
1159
1160 /* see if user wants any of these packages */
1161 @@ -449,7 +449,7 @@ retry_mkdir:
1162 atom_implode(atom);
1163
1164 next_pkg:
1165 - q_vdb_close_pkg(pkg_ctx);
1166 + vdb_close_pkg(pkg_ctx);
1167 }
1168 }
1169
1170
1171 diff --git a/qsize.c b/qsize.c
1172 index 80d496c..4fbbe47 100644
1173 --- a/qsize.c
1174 +++ b/qsize.c
1175 @@ -97,7 +97,7 @@ struct qsize_opt_state {
1176 };
1177
1178 static int
1179 -qsize_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
1180 +qsize_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
1181 {
1182 struct qsize_opt_state *state = priv;
1183 const char *catname = pkg_ctx->cat_ctx->name;
1184 @@ -126,7 +126,7 @@ qsize_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
1185 if (!showit)
1186 return EXIT_SUCCESS;
1187
1188 - if ((fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
1189 + if ((fp = vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
1190 return EXIT_SUCCESS;
1191
1192 num_ignored = num_files = num_nonfiles = num_bytes = 0;
1193 @@ -230,7 +230,7 @@ int qsize_main(int argc, char **argv)
1194 state.buflen = _Q_PATH_MAX;
1195 state.buf = xmalloc(state.buflen);
1196
1197 - ret = q_vdb_foreach_pkg(portroot, portvdb, qsize_cb, &state, NULL);
1198 + ret = vdb_foreach_pkg(portroot, portvdb, qsize_cb, &state, NULL);
1199
1200 if (state.summary) {
1201 printf(" %sTotals%s: %'zu files, %'zu non-files, ", BOLD, NORM,