summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-04-02 23:20:00 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-04-02 23:20:00 +0000
commit80bae750cd8ec44aa879b22fb1fdcc41036cbff6 (patch)
tree7d56a90647b760d90f8bd5976c049dd47648c495 /lib
parenta94c24c4067945e02f0afdd7f91cf74218b0142a (diff)
downloadpacman-80bae750cd8ec44aa879b22fb1fdcc41036cbff6.tar.xz
- added 'lastupdate' field to pmdb_t
- added a new public function alpm_db_getinfo - added a public parameter PM_PKG_DB for PM_PKG struct
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.c25
-rw-r--r--lib/libalpm/alpm.h14
-rw-r--r--lib/libalpm/db.c5
-rw-r--r--lib/libalpm/db.h2
4 files changed, 33 insertions, 13 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 96ca1be5..16e103ea 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -206,18 +206,22 @@ int alpm_db_unregister(PM_DB *db)
return(0);
}
-int alpm_db_getlastupdate(PM_DB *db, char *ts)
+void *alpm_db_getinfo(PM_DB *db, unsigned char parm)
{
+ void *data = NULL;
+
/* Sanity checks */
- ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
- ASSERT(db != NULL && db != handle->db_local, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- ASSERT(ts != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(db != NULL, return(NULL));
- if(!pm_list_is_ptrin(handle->dbs_sync, db)) {
- RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
+ switch(parm) {
+ case PM_DB_TREENAME: data = db->treename; break;
+ case PM_DB_LASTUPDATE: data = db->lastupdate; break;
+ default:
+ data = NULL;
}
- return(db_getlastupdate(db, ts));
+ return(data);
}
int alpm_db_update(PM_DB *db, char *archive, char *ts)
@@ -322,7 +326,7 @@ PM_LIST *alpm_db_getgrpcache(PM_DB *db)
void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm)
{
- void *data;
+ void *data = NULL;
/* Sanity checks */
ASSERT(handle != NULL, return(NULL));
@@ -337,7 +341,7 @@ void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm)
char target[PKG_NAME_LEN+PKG_VERSION_LEN];
snprintf(target, PKG_NAME_LEN+PKG_VERSION_LEN, "%s-%s", pkg->name, pkg->version);
- db_read(pkg->data, target, INFRQ_FILES, pkg);
+ db_read(pkg->data, pkg->name, INFRQ_FILES, pkg);
}
break;
@@ -374,6 +378,7 @@ void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm)
case PM_PKG_FILES: data = pkg->files; break;
case PM_PKG_BACKUP: data = pkg->backup; break;
case PM_PKG_SCRIPLET: data = (void *)(int)pkg->scriptlet; break;
+ case PM_PKG_DB: data = pkg->data; break;
default:
data = NULL;
break;
@@ -418,7 +423,7 @@ int alpm_pkg_vercmp(const char *ver1, const char *ver2)
void *alpm_grp_getinfo(PM_GRP *grp, unsigned char parm)
{
- void *data;
+ void *data = NULL;
/* Sanity checks */
ASSERT(grp != NULL, return(NULL));
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 30e07578..6962d380 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -93,11 +93,17 @@ int alpm_get_option(unsigned char parm, long *data);
* Databases
*/
+/* Info parameters */
+enum {
+ PM_DB_TREENAME = 1,
+ PM_DB_LASTUPDATE
+};
+
PM_DB *alpm_db_register(char *treename);
int alpm_db_unregister(PM_DB *db);
-/* Sync databases */
-int alpm_db_getlastupdate(PM_DB *db, char *ts);
+void *alpm_db_getinfo(PM_DB *db, unsigned char parm);
+
int alpm_db_update(PM_DB *db, char *archive, char *ts);
PM_PKG *alpm_db_readpkg(PM_DB *db, char *name);
@@ -136,7 +142,9 @@ enum {
PM_PKG_FILES,
PM_PKG_BACKUP,
/* Sciplet */
- PM_PKG_SCRIPLET
+ PM_PKG_SCRIPLET,
+ /* Misc */
+ PM_PKG_DB
};
/* reasons -- ie, why the package was installed */
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 88126f4d..29547e20 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -60,6 +60,8 @@ pmdb_t *db_open(char *root, char *dbpath, char *treename)
db->pkgcache = NULL;
db->grpcache = NULL;
+ db_getlastupdate(db, db->lastupdate);
+
return(db);
}
@@ -152,6 +154,9 @@ int db_setlastupdate(pmdb_t *db, char *ts)
return(-1);
}
fclose(fp);
+
+ STRNCPY(db->lastupdate, ts, DB_UPDATE_LEN);
+
return(0);
}
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index c3efdc29..9f7509c6 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -35,6 +35,7 @@
#define INFRQ_ALL 0xFF
#define DB_TREENAME_LEN 128
+#define DB_UPDATE_LEN 16
/* Database */
typedef struct __pmdb_t {
@@ -43,6 +44,7 @@ typedef struct __pmdb_t {
DIR *dir;
PMList *pkgcache;
PMList *grpcache;
+ char lastupdate[DB_UPDATE_LEN];
} pmdb_t;
pmdb_t *db_open(char *root, char *dbpath, char *treename);