summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-16 22:57:12 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-03-16 22:57:12 +0000
commit7a01ed50b903f24ba44ce9bb9a591460b6a2be64 (patch)
treea8e9ddf63fead14cd5b26707c7bdee9171045d5a /lib
parentd10955065632a67fcad70e32d36eeb80b1045299 (diff)
downloadpacman-7a01ed50b903f24ba44ce9bb9a591460b6a2be64.tar.xz
Removed hardcoded reference to fields of packages
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.c8
-rw-r--r--lib/libalpm/package.h36
2 files changed, 28 insertions, 16 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index e564d31c..8dc8f0b1 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -291,18 +291,18 @@ void *alpm_pkg_getinfo(PM_PKG *pkg, unsigned char parm)
case PM_PKG_FILES:
case PM_PKG_BACKUP:
if(!(pkg->infolevel & INFRQ_FILES)) {
- char target[321]; /* 256+1+64 */
+ char target[PKG_NAME_LEN+1+PKG_VERSION_LEN];
- snprintf(target, 321, "%s-%s", pkg->name, pkg->version);
+ snprintf(target, PKG_NAME_LEN+1+PKG_VERSION_LEN, "%s-%s", pkg->name, pkg->version);
db_read(pkg->data, target, INFRQ_FILES, pkg);
}
break;
case PM_PKG_SCRIPLET:
if(!(pkg->infolevel & INFRQ_SCRIPLET)) {
- char target[321];
+ char target[PKG_NAME_LEN+1+PKG_VERSION_LEN];
- snprintf(target, 321, "%s-%s", pkg->name, pkg->version);
+ snprintf(target, PKG_NAME_LEN+1+PKG_VERSION_LEN, "%s-%s", pkg->name, pkg->version);
db_read(pkg->data, target, INFRQ_SCRIPLET, pkg);
}
break;
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 890bbccc..8c28a06a 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -23,20 +23,32 @@
#include "list.h"
-#define PKG_FROM_CACHE 1
-#define PKG_FROM_FILE 2
+enum {
+ PKG_FROM_CACHE = 1,
+ PKG_FROM_FILE
+};
+
+#define PKG_NAME_LEN 256
+#define PKG_VERSION_LEN 64
+#define PKG_DESC_LEN 512
+#define PKG_URL_LEN 256
+#define PKG_LICENSE_LEN 256
+#define PKG_DATE_LEN 32
+#define PKG_PACKAGER_LEN 64
+#define PKG_MD5SUM_LEN 33
+#define PKG_ARCH_LEN 32
typedef struct __pmpkg_t {
- char name[256];
- char version[64];
- char desc[512];
- char url[256];
- char license[128];
- char builddate[32];
- char installdate[32];
- char packager[64];
- char md5sum[33];
- char arch[32];
+ char name[PKG_NAME_LEN];
+ char version[PKG_VERSION_LEN];
+ char desc[PKG_DESC_LEN];
+ char url[PKG_URL_LEN];
+ char license[PKG_LICENSE_LEN];
+ char builddate[PKG_DATE_LEN];
+ char installdate[PKG_DATE_LEN];
+ char packager[PKG_PACKAGER_LEN];
+ char md5sum[PKG_MD5SUM_LEN];
+ char arch[PKG_ARCH_LEN];
unsigned long size;
unsigned char scriptlet;
unsigned char force;