From a63823e26ae8a382678132ced3687749d10bb51a Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 20 Nov 2010 12:25:45 -0300 Subject: [PATCH] qpkg: turn pkg->installed into pkg->flags, allowing for future expansion - qpkg.h (enum flags, struct pkg): replaced "installed" with "flags", one of them being QPKG_INSTALLED - gobble.c (compact_pkg, gobble_buf), prereq.c (push, resolve): adapted for above change --- qpkg/gobble.c | 6 +++--- qpkg/prereq.c | 6 +++--- qpkg/qpkg.h | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/qpkg/gobble.c b/qpkg/gobble.c index ff9ab24..68297a7 100644 --- a/qpkg/gobble.c +++ b/qpkg/gobble.c @@ -103,7 +103,7 @@ static void compact_pkg(struct pkg *new) compact: new->id->jrb->val = new->more; - old->installed = old->installed || new->installed; + old->flags |= new->flags; /* @@@ we may leak a little */ free(new); } @@ -290,7 +290,7 @@ package: pkg->version = NULL; pkg->conflicts = pkg->depends = NULL; pkg->filename = NULL; - pkg->installed = 0; + pkg->flags = 0; pkg->mark = 0; goto eol; @@ -306,7 +306,7 @@ provides: goto skip_data; status: - pkg->installed = 1; + pkg->flags |= QPKG_INSTALLED; /* @@@ later */ goto skip_data; diff --git a/qpkg/prereq.c b/qpkg/prereq.c index c1c600c..05a7bdc 100644 --- a/qpkg/prereq.c +++ b/qpkg/prereq.c @@ -125,7 +125,7 @@ static void push(struct pkg *pkg) } stack[n_stack++] = pkg; - assert(!pkg->mark && !pkg->installed); + assert(!pkg->mark && !(pkg->flags & QPKG_INSTALLED)); pkg->mark = 1; } @@ -197,12 +197,12 @@ fprintf(stderr, "%.*s %p", ID2S(pkg->id), pkg); if (pkg->version) fprintf(stderr, " %.*s", ID2S(pkg->version)); if (pkg->mark) fprintf(stderr, " +"); -if (pkg->installed) fprintf(stderr, " ***"); +if (pkg->flags & QPKG_INSTALLED) fprintf(stderr, " ***"); fprintf(stderr, "\n"); #endif if (!satisfies(pkg, dep)) continue; - if (pkg->installed || pkg->mark) { + if ((pkg->flags & QPKG_INSTALLED) || pkg->mark) { assert(!conflicts(pkg, conf)); resolve(next_dep, dep->next, conf); continue; diff --git a/qpkg/qpkg.h b/qpkg/qpkg.h index e0fc4a1..97d3b5b 100644 --- a/qpkg/qpkg.h +++ b/qpkg/qpkg.h @@ -13,6 +13,10 @@ #ifndef QPKG_H #define QPKG_H +enum flags { + QPKG_INSTALLED = 1 << 0, /* installed on target */ +}; + enum relop { rel_eq, rel_ge, @@ -34,7 +38,7 @@ struct pkg { struct ref *conflicts; struct ref *depends; const char *filename; - int installed; + int flags; /* see enum flags */ struct pkg *more; int mark; };