pkgtools

morpheus pkg tools
git clone git://git.2f30.org/pkgtools
Log | Files | Refs | README | LICENSE

commit 0b2b6579cf650b84bedac5a9728c9203bb2617d0
parent 9f4b9924116d6dff200081eb3920e3ea2f2db5fb
Author: sin <sin@2f30.org>
Date:   Thu, 19 Jun 2014 18:08:23 +0100

Parse version numbers out of /var/pkg/*

Diffstat:
Mdb.c | 15+++++++++++++++
Mdb.h | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/db.c b/db.c @@ -541,9 +541,24 @@ struct pkg * pkgnew(char *name) { struct pkg *pkg; + char version[PATH_MAX], *p, *q; pkg = emalloc(sizeof(*pkg)); pkg->name = estrdup(name); + estrlcpy(version, name, sizeof(version)); + q = strrchr(version, '.'); + if (!q) + eprintf("invalid package name %s\n", name); + *q = '\0'; + q = strrchr(version, '.'); + if (!q) + eprintf("invalid package name %s\n", name); + *q = '\0'; + p = strchr(version, '#'); + if (p) + pkg->version = estrdup(p + 1); + else + pkg->version = NULL; pkg->head = NULL; return pkg; } diff --git a/db.h b/db.h @@ -6,6 +6,7 @@ struct pkgentry { struct pkg { char *name; + char *version; struct pkgentry *head; };