Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=42ad313ffda3f0318efb26d90729906b74a237b8

commit 42ad313ffda3f0318efb26d90729906b74a237b8
Author: Michel Hermier <[email protected]>
Date:   Wed May 7 11:02:39 2014 +0200

libpacman: s/_pacman_pkg_getowners/LocalDatabase::getowners/

diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp
index eb3923d..8cdce02 100644
--- a/lib/libpacman/db.cpp
+++ b/lib/libpacman/db.cpp
@@ -184,6 +184,11 @@ int Database::remove(Package *info)
RET_ERR(PM_ERR_WRONG_ARGS, -1); // Not supported
}

+pmlist_t *Database::getowners(const char *filename)
+{
+       return NULL;
+}
+
/* Reads dbpath/treename.lastupdate and populates *ts with the contents.
* *ts should be malloc'ed and should be at least 15 bytes.
*
diff --git a/lib/libpacman/db.h b/lib/libpacman/db.h
index 571277c..0040e46 100644
--- a/lib/libpacman/db.h
+++ b/lib/libpacman/db.h
@@ -72,6 +72,8 @@ public:
// Cache operations
pmlist_t *search(pmlist_t *needles);

+       virtual pmlist_t *getowners(const char *filename); /* Make pure virtual 
*/
+
char *path;
char treename[PATH_MAX];
void *handle;
diff --git a/lib/libpacman/db/localdb.cpp b/lib/libpacman/db/localdb.cpp
index 74de205..50877ec 100644
--- a/lib/libpacman/db/localdb.cpp
+++ b/lib/libpacman/db/localdb.cpp
@@ -25,14 +25,15 @@
/* pacman-g2 */
#include "db/localdb.h"

+#include "db/localdb_files.h"
#include "util.h"
+#include "cache.h"
#include "db.h"
#include "package.h"
#include "pacman.h"
#include "error.h"
#include "handle.h"

-#include "db/localdb_files.h"
#include "util/log.h"
#include "util/stringlist.h"
#include "fstring.h"
@@ -468,6 +469,52 @@ int LocalDatabase::remove(Package *info)
return(0);
}

+pmlist_t *LocalDatabase::getowners(const char *filename)
+{
+       struct stat buf;
+       int gotcha = 0;
+       char rpath[PATH_MAX];
+       pmlist_t *lp, *ret = NULL;
+
+       if(stat(filename, &buf) == -1 || realpath(filename, rpath) == NULL) {
+               RET_ERR(PM_ERR_PKG_OPEN, NULL);
+       }
+
+       if(S_ISDIR(buf.st_mode)) {
+               /* this is a directory and the db has a / suffix for dirs - add 
it here so
+                * that we'll find dirs, too */
+               rpath[strlen(rpath)+1] = '\0';
+               rpath[strlen(rpath)] = '/';
+       }
+
+       for(lp = _pacman_db_get_pkgcache(this); lp; lp = lp->next) {
+               Package *info;
+               pmlist_t *i;
+
+               info = lp->data;
+
+               for(i = info->files(); i; i = i->next) {
+                       char path[PATH_MAX];
+
+                       snprintf(path, PATH_MAX, "%s%s", ::handle->root, (char 
*)i->data);
+                       if(!strcmp(path, rpath)) {
+                               ret = _pacman_list_add(ret, info);
+                               if(rpath[strlen(rpath)-1] != '/') {
+                                       /* we are searching for a file and 
multiple packages won't contain
+                                        * the same file */
+                                       return(ret);
+                               }
+                               gotcha = 1;
+                       }
+               }
+       }
+       if(!gotcha) {
+               RET_ERR(PM_ERR_NO_OWNER, NULL);
+       }
+
+       return(ret);
+}
+
const pmdb_ops_t _pacman_localdb_ops = {
.read = _pacman_localdb_read,
};
diff --git a/lib/libpacman/db/localdb.h b/lib/libpacman/db/localdb.h
index b632072..51c2221 100644
--- a/lib/libpacman/db/localdb.h
+++ b/lib/libpacman/db/localdb.h
@@ -58,6 +58,8 @@ public:
virtual int write(libpacman::Package *info, unsigned int inforeq);
virtual int remove(libpacman::Package *info);

+       virtual pmlist_t *getowners(const char *filename);
+
protected:
virtual int open(int flags, time_t *timestamp);
};
diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp
index 9271e84..c7f4ae3 100644
--- a/lib/libpacman/package.cpp
+++ b/lib/libpacman/package.cpp
@@ -288,52 +288,6 @@ int Package::remove()
return database->remove(this);
}

-pmlist_t *_pacman_pkg_getowners(const char *filename)
-{
-       struct stat buf;
-       int gotcha = 0;
-       char rpath[PATH_MAX];
-       pmlist_t *lp, *ret = NULL;
-
-       if(stat(filename, &buf) == -1 || realpath(filename, rpath) == NULL) {
-               RET_ERR(PM_ERR_PKG_OPEN, NULL);
-       }
-
-       if(S_ISDIR(buf.st_mode)) {
-               /* this is a directory and the db has a / suffix for dirs - add 
it here so
-                * that we'll find dirs, too */
-               rpath[strlen(rpath)+1] = '\0';
-               rpath[strlen(rpath)] = '/';
-       }
-
-       for(lp = _pacman_db_get_pkgcache(handle->db_local); lp; lp = lp->next) {
-               Package *info;
-               pmlist_t *i;
-
-               info = lp->data;
-
-               for(i = info->files(); i; i = i->next) {
-                       char path[PATH_MAX];
-
-                       snprintf(path, PATH_MAX, "%s%s", handle->root, (char 
*)i->data);
-                       if(!strcmp(path, rpath)) {
-                               ret = _pacman_list_add(ret, info);
-                               if(rpath[strlen(rpath)-1] != '/') {
-                                       /* we are searching for a file and 
multiple packages won't contain
-                                        * the same file */
-                                       return(ret);
-                               }
-                               gotcha = 1;
-                       }
-               }
-       }
-       if(!gotcha) {
-               RET_ERR(PM_ERR_NO_OWNER, NULL);
-       }
-
-       return(ret);
-}
-
int Package::filename(char *str, size_t size) const
{
return snprintf(str, size, "%s-%s-%s%s",
diff --git a/lib/libpacman/package.h b/lib/libpacman/package.h
index 95531c8..21badb4 100644
--- a/lib/libpacman/package.h
+++ b/lib/libpacman/package.h
@@ -167,8 +167,6 @@ int _pacman_pkg_cmp(const void *p1, const void *p2);
int _pacman_pkg_is_valid(const libpacman::Package *pkg, const pmtrans_t *trans, 
const char *pkgfile);
libpacman::Package *_pacman_pkg_isin(const char *needle, pmlist_t *haystack);

-pmlist_t *_pacman_pkg_getowners(const char *filename);
-
int _pacman_packagestrmatcher_init(FMatcher *matcher, const FStrMatcher 
*strmatcher, int flags);
int _pacman_packagestrmatcher_fini(FMatcher *matcher);

diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp
index 89f198c..23f23f1 100644
--- a/lib/libpacman/pacman.cpp
+++ b/lib/libpacman/pacman.cpp
@@ -899,7 +899,7 @@ pmlist_t *pacman_pkg_getowners(const char *filename)
ASSERT(handle->db_local != NULL, RET_ERR(PM_ERR_DB_NULL, NULL));
ASSERT(!_pacman_strempty(filename), RET_ERR(PM_ERR_WRONG_ARGS, NULL));

-       return(_pacman_pkg_getowners(filename));
+       return handle->db_local->getowners(filename);
}

/** Create a package from a file.
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to