summaryrefslogtreecommitdiff
path: root/src/blob.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-06 16:58:58 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-06 16:58:58 +0200
commit57154db85d459a869bbfb7a3bd2bcb16699a0a7a (patch)
tree64394df9d0e0775c334ff6d69c67a4a4322d625b /src/blob.c
parentb380d4f8e08aefdf5f685bb3e6731e670d278277 (diff)
downloadapk-tools-57154db85d459a869bbfb7a3bd2bcb16699a0a7a.tar.gz
apk-tools-57154db85d459a869bbfb7a3bd2bcb16699a0a7a.tar.bz2
apk-tools-57154db85d459a869bbfb7a3bd2bcb16699a0a7a.tar.xz
apk-tools-57154db85d459a869bbfb7a3bd2bcb16699a0a7a.zip
db: parse new style .PKGINFO
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/blob.c b/src/blob.c
index f7c14b5..f166a7a 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -47,7 +47,7 @@ int apk_blob_rsplit(apk_blob_t blob, char split, apk_blob_t *l, apk_blob_t *r)
return 1;
}
-int apk_blob_splitstr(apk_blob_t blob, char *split, apk_blob_t *l, apk_blob_t *r)
+int apk_blob_splitstr(apk_blob_t blob, const char *split, apk_blob_t *l, apk_blob_t *r)
{
int splitlen = strlen(split);
char *pos = blob.ptr, *end = blob.ptr + blob.len - splitlen + 1;
@@ -71,6 +71,23 @@ int apk_blob_splitstr(apk_blob_t blob, char *split, apk_blob_t *l, apk_blob_t *r
}
}
+int apk_blob_for_each_segment(apk_blob_t blob, const char *split,
+ int (*cb)(void *ctx, apk_blob_t blob), void *ctx)
+{
+ apk_blob_t l, r;
+ int rc;
+
+ r = blob;
+ while (apk_blob_splitstr(r, split, &l, &r)) {
+ rc = cb(ctx, l);
+ if (rc != 0)
+ return rc;
+ }
+ if (r.len > 0)
+ return cb(ctx, r);
+ return 0;
+}
+
static int dx(int c)
{
if (c >= '0' && c <= '9')