summaryrefslogtreecommitdiff
path: root/src/apk_blob.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-01-12 14:33:29 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-01-12 14:33:29 +0200
commit1f9a36de6828b87ba9d7dedcae2de6092eed4f41 (patch)
treef928b3e94711951f603624a19924c290da362b8a /src/apk_blob.h
parent30965aa86735f7d2dcd544bae0b788195c51f336 (diff)
downloadapk-tools-1f9a36de6828b87ba9d7dedcae2de6092eed4f41.tar.gz
apk-tools-1f9a36de6828b87ba9d7dedcae2de6092eed4f41.tar.bz2
apk-tools-1f9a36de6828b87ba9d7dedcae2de6092eed4f41.tar.xz
apk-tools-1f9a36de6828b87ba9d7dedcae2de6092eed4f41.zip
db: support line feed as 'world' dependency separator
* default writing the world with spaces if a space is found (for backwards compatibility) for now
Diffstat (limited to 'src/apk_blob.h')
-rw-r--r--src/apk_blob.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/apk_blob.h b/src/apk_blob.h
index 55c21b7..55838ad 100644
--- a/src/apk_blob.h
+++ b/src/apk_blob.h
@@ -12,6 +12,7 @@
#ifndef APK_BLOB_H
#define APK_BLOB_H
+#include <ctype.h>
#include <string.h>
#include <openssl/evp.h>
@@ -73,6 +74,14 @@ static inline apk_blob_t APK_BLOB_STR(const char *str)
return ((apk_blob_t){strlen(str), (void *)(str)});
}
+static inline apk_blob_t apk_blob_trim(apk_blob_t blob)
+{
+ apk_blob_t b = blob;
+ while (b.len > 0 && isspace(b.ptr[b.len-1]))
+ b.len--;
+ return b;
+}
+
char *apk_blob_cstr(apk_blob_t str);
int apk_blob_spn(apk_blob_t blob, const char *accept, apk_blob_t *l, apk_blob_t *r);
int apk_blob_cspn(apk_blob_t blob, const char *reject, apk_blob_t *l, apk_blob_t *r);
@@ -90,6 +99,11 @@ static inline void apk_blob_checksum(apk_blob_t b, const EVP_MD *md, struct apk_
csum->type = EVP_MD_size(md);
EVP_Digest(b.ptr, b.len, csum->data, NULL, md, NULL);
}
+static inline char *apk_blob_chr(apk_blob_t b, unsigned char ch)
+{
+ return memchr(b.ptr, ch, b.len);
+}
+
static inline const int apk_checksum_compare(const struct apk_checksum *a,
const struct apk_checksum *b)
{