Sfoglia il codice sorgente

Move duplicate pkgadminfile functions to lib/dbmodify.c

Ian Jackson 18 anni fa
parent
commit
175aa99c46
6 ha cambiato i file con 22 aggiunte e 25 eliminazioni
  1. 8 0
      ChangeLog
  2. 12 0
      lib/dbmodify.c
  3. 2 0
      lib/dpkg-db.h
  4. 0 12
      src/help.c
  5. 0 1
      src/main.h
  6. 0 12
      src/query.c

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>
+
+	* src/main.h (pkgadminfile): Move prototype to ...
+	* lib/dpkg-db.h: ... here.
+	* src/help.c (pkgadminfile): Move function definition to ...
+	* lib/dbmodify.c: ... here.
+	* src/query.c (pkgadminfile): Remove duplicated functions.
+
 2008-03-20  Ian Jackson  <ian@davenant.greenend.org.uk>,
             Guillem Jover  <guillem@debian.org>
 

+ 12 - 0
lib/dbmodify.c

@@ -288,6 +288,18 @@ void modstatdb_note(struct pkginfo *pkg) {
   onerr_abort--;
 }
 
+const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
+  static struct varbuf vb;
+  varbufreset(&vb);
+  varbufaddstr(&vb,admindir);
+  varbufaddstr(&vb,"/" INFODIR);
+  varbufaddstr(&vb,pkg->name);
+  varbufaddc(&vb,'.');
+  varbufaddstr(&vb,whichfile);
+  varbufaddc(&vb,0);
+  return vb.buf;
+}
+
 const char *log_file= NULL;
 
 void log_message(const char *fmt, ...) {

+ 2 - 0
lib/dpkg-db.h

@@ -175,6 +175,8 @@ void modstatdb_shutdown(void);
 
 extern char *statusfile, *availablefile; /* initialised by modstatdb_init */
 
+const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile);
+
 extern const char *log_file;
 void log_message(const char *fmt, ...) PRINTFFORMAT(1, 2);
 

+ 0 - 12
src/help.c

@@ -144,18 +144,6 @@ int force_conflicts(struct deppossi *possi) {
   return fc_conflicts;
 }
 
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
-  static struct varbuf vb;
-  varbufreset(&vb);
-  varbufaddstr(&vb,admindir);
-  varbufaddstr(&vb,"/" INFODIR);
-  varbufaddstr(&vb,pkg->name);
-  varbufaddc(&vb,'.');
-  varbufaddstr(&vb,whichfile);
-  varbufaddc(&vb,0);
-  return vb.buf;
-}
-
 static const char* preexecscript(const char *path, char *const *argv) {
   /* returns the path to the script inside the chroot
    * none of the stuff here will work if admindir isn't inside instdir

+ 0 - 1
src/main.h

@@ -182,7 +182,6 @@ int force_conff_new(struct deppossi *possi);
 int force_conff_miss(struct deppossi *possi);
 int force_conflicts(struct deppossi *possi);
 void ensure_package_clientdata(struct pkginfo *pkg);
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile);
 void oldconffsetflags(const struct conffile *searchconff);
 void ensure_pathname_nonexisting(const char *pathname);
 int chmodsafe_unlink(const char *pathname, const char **failed);

+ 0 - 12
src/query.c

@@ -54,18 +54,6 @@ void ensure_package_clientdata(struct pkginfo *pkg) {
   pkg->clientdata->files= 0;
 }
 
-const char *pkgadminfile(struct pkginfo *pkg, const char *whichfile) {
-  static struct varbuf vb;
-  varbufreset(&vb);
-  varbufaddstr(&vb,admindir);
-  varbufaddstr(&vb,"/" INFODIR);
-  varbufaddstr(&vb,pkg->name);
-  varbufaddc(&vb,'.');
-  varbufaddstr(&vb,whichfile);
-  varbufaddc(&vb,0);
-  return vb.buf;
-}
-
 int pkglistqsortcmp(const void *a, const void *b) {
   const struct pkginfo *pa= *(const struct pkginfo**)a;
   const struct pkginfo *pb= *(const struct pkginfo**)b;