diff options
author | Guillem Jover <guillem@debian.org> | 2012-04-02 03:30:58 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2012-04-03 05:32:20 +0200 |
commit | 58d868951d927cc27128134b7ede34a30fa78cfd (patch) | |
tree | e60554236c86a2f80f467a1468337bd4b18a5161 | |
parent | 8e0c0d33d4cc2a91f1b8214ac1db894129f1d10a (diff) | |
download | dpkg-58d868951d927cc27128134b7ede34a30fa78cfd.tar.gz |
Move pkg_infodb_get_dir() and pkg_infodb_get_file() to infodb-format.c
These functions have never belonged in the filesdb module, but were put
there temporarily for convenience.
-rw-r--r-- | src/filesdb.c | 41 | ||||
-rw-r--r-- | src/filesdb.h | 4 | ||||
-rw-r--r-- | src/help.c | 1 | ||||
-rw-r--r-- | src/infodb-format.c | 32 | ||||
-rw-r--r-- | src/infodb.h | 3 | ||||
-rw-r--r-- | src/trigproc.c | 1 |
6 files changed, 37 insertions, 45 deletions
diff --git a/src/filesdb.c b/src/filesdb.c index 8994e14e6..9c2cf8bc5 100644 --- a/src/filesdb.c +++ b/src/filesdb.c @@ -53,47 +53,6 @@ #include "infodb.h" #include "main.h" -/*** Package control information database directory routines. ***/ - -/* - * XXX: Strictly speaking these functions do not exactly belong here, and - * they should be eventually moved back to a unified on-disk database - * handling module in libdpkg. For now this is good enough, as it avoids - * pulling unneeded code into the resulting binaries, because all its - * users require filesdb anyway. - */ - -static char *infodir; - -const char * -pkg_infodb_get_dir(void) -{ - if (infodir == NULL) - infodir = dpkg_db_get_path(INFODIR); - - return infodir; -} - -const char * -pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin, - const char *filetype) -{ - static struct varbuf vb; - - varbuf_reset(&vb); - varbuf_add_str(&vb, pkgadmindir()); - varbuf_add_char(&vb, '/'); - varbuf_add_str(&vb, pkg->set->name); - if (pkgbin->multiarch == multiarch_same && - pkg_infodb_get_format() == pkg_infodb_format_multiarch) - varbuf_add_archqual(&vb, pkgbin->arch); - varbuf_add_char(&vb, '.'); - varbuf_add_str(&vb, filetype); - varbuf_end_str(&vb); - - return vb.buf; -} - /*** filepackages support for tracking packages owning a file. ***/ #define PERFILEPACKAGESLUMP 10 diff --git a/src/filesdb.h b/src/filesdb.h index 286dccb48..b1f0f721c 100644 --- a/src/filesdb.h +++ b/src/filesdb.h @@ -137,10 +137,6 @@ struct diversion { struct diversion *next; }; -const char *pkg_infodb_get_dir(void); -const char *pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin, - const char *filetype); - struct filepackages_iterator; struct filepackages_iterator *filepackages_iter_new(struct filenamenode *fnn); struct pkginfo *filepackages_iter_next(struct filepackages_iterator *iter); diff --git a/src/help.c b/src/help.c index 844baf9e5..cd2690ccc 100644 --- a/src/help.c +++ b/src/help.c @@ -44,6 +44,7 @@ #include <dpkg/triglib.h> #include "filesdb.h" +#include "infodb.h" #include "main.h" const char *const statusstrings[]= { diff --git a/src/infodb-format.c b/src/infodb-format.c index 488767fbb..07912480f 100644 --- a/src/infodb-format.c +++ b/src/infodb-format.c @@ -31,6 +31,7 @@ #include <dpkg/i18n.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> +#include <dpkg/varbuf.h> #include "infodb.h" @@ -109,3 +110,34 @@ pkg_infodb_is_upgrading(void) return db_upgrading; } + +const char * +pkg_infodb_get_dir(void) +{ + static char *infodir; + + if (infodir == NULL) + infodir = dpkg_db_get_path(INFODIR); + + return infodir; +} + +const char * +pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin, + const char *filetype) +{ + static struct varbuf vb; + + varbuf_reset(&vb); + varbuf_add_str(&vb, pkg_infodb_get_dir()); + varbuf_add_char(&vb, '/'); + varbuf_add_str(&vb, pkg->set->name); + if (pkgbin->multiarch == multiarch_same && + pkg_infodb_get_format() == pkg_infodb_format_multiarch) + varbuf_add_archqual(&vb, pkgbin->arch); + varbuf_add_char(&vb, '.'); + varbuf_add_str(&vb, filetype); + varbuf_end_str(&vb); + + return vb.buf; +} diff --git a/src/infodb.h b/src/infodb.h index 99935046d..64579b5ba 100644 --- a/src/infodb.h +++ b/src/infodb.h @@ -36,6 +36,9 @@ void pkg_infodb_set_format(enum pkg_infodb_format format); bool pkg_infodb_is_upgrading(void); void pkg_infodb_upgrade(void); +const char *pkg_infodb_get_dir(void); +const char *pkg_infodb_get_file(struct pkginfo *pkg, struct pkgbin *pkgbin, + const char *filetype); bool pkg_infodb_has_file(struct pkginfo *pkg, struct pkgbin *pkgbin, const char *name); diff --git a/src/trigproc.c b/src/trigproc.c index 7a4fbe997..da0d4a096 100644 --- a/src/trigproc.c +++ b/src/trigproc.c @@ -38,6 +38,7 @@ #include "main.h" #include "filesdb.h" +#include "infodb.h" /* * Trigger processing algorithms: |