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

commit f8d6c4f0ca9282c6bc599832173dd4a8e3ff364d
Author: Michel Hermier <[email protected]>
Date:   Thu Oct 31 12:41:03 2013 +0100

libpacman: Extract _pacman_localdb_test and _pacman_syncdb_test of 
_pacman_db_test.

diff --git a/lib/libpacman/be_files.c b/lib/libpacman/be_files.c
index 90215fc..337a028 100644
--- a/lib/libpacman/be_files.c
+++ b/lib/libpacman/be_files.c
@@ -56,16 +56,13 @@ static inline int islocal(pmdb_t *db)
return strcmp(db->treename, "local") == 0;
}

-pmlist_t *_pacman_db_test(pmdb_t *db)
+static
+pmlist_t *_pacman_localdb_test(pmdb_t *db)
{
struct dirent *ent;
char path[PATH_MAX];
struct stat buf;
-       pmlist_t *ret = NULL;
-
-       /* testing sync dbs is not supported */
-       if (!islocal(db))
-               return ret;
+       pmlist_t *ret = _pacman_list_new();

while ((ent = readdir(db->handle)) != NULL) {
snprintf(path, PATH_MAX, "%s/%s", db->path, ent->d_name);
@@ -92,9 +89,27 @@ pmlist_t *_pacman_db_test(pmdb_t *db)
ret = _pacman_list_add(ret, strdup(path));
}
}
+
return(ret);
}

+static
+pmlist_t *_pacman_syncdb_test(pmdb_t *db)
+{
+       /* testing sync dbs is not supported */
+       return _pacman_list_new();
+}
+
+pmlist_t *_pacman_db_test(pmdb_t *db)
+{
+       ASSERT(db == NULL, RET_ERR(PM_ERR_DB_NULL, -1));
+
+       if (islocal(db))
+               return _pacman_localdb_test(db);
+       else
+               return _pacman_syncdb_test(db);
+}
+
int _pacman_db_open(pmdb_t *db)
{
if(db == NULL) {
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to