summaryrefslogtreecommitdiff
path: root/src/blob.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-04-14 18:46:35 +0300
committerTimo Teras <timo.teras@iki.fi>2009-04-14 18:46:35 +0300
commit7cef96c30d2f2d585aa2edd7b6ab22e9e007cddc (patch)
tree1f3d552a5cb9396c7408b021e1acc739a90289a3 /src/blob.c
parent024480aca02a5a81113cdf7a47aafa4c1c30de3d (diff)
downloadapk-tools-7cef96c30d2f2d585aa2edd7b6ab22e9e007cddc.tar.gz
apk-tools-7cef96c30d2f2d585aa2edd7b6ab22e9e007cddc.tar.bz2
apk-tools-7cef96c30d2f2d585aa2edd7b6ab22e9e007cddc.tar.xz
apk-tools-7cef96c30d2f2d585aa2edd7b6ab22e9e007cddc.zip
blob: add strspn helpers
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/blob.c b/src/blob.c
index ab514f8..3aa61c7 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -31,6 +31,34 @@ char *apk_blob_cstr(apk_blob_t blob)
return cstr;
}
+int apk_blob_spn(apk_blob_t blob, const char *accept, apk_blob_t *l, apk_blob_t *r)
+{
+ int i;
+
+ for (i = 0; i < blob.len; i++) {
+ if (strchr(accept, blob.ptr[i]) == NULL) {
+ *l = APK_BLOB_PTR_LEN(blob.ptr, i);
+ *r = APK_BLOB_PTR_LEN(blob.ptr+i, blob.len-i);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int apk_blob_cspn(apk_blob_t blob, const char *reject, apk_blob_t *l, apk_blob_t *r)
+{
+ int i;
+
+ for (i = 0; i < blob.len; i++) {
+ if (strchr(reject, blob.ptr[i]) != NULL) {
+ *l = APK_BLOB_PTR_LEN(blob.ptr, i);
+ *r = APK_BLOB_PTR_LEN(blob.ptr+i, blob.len-i);
+ return 1;
+ }
+ }
+ return 0;
+}
+
int apk_blob_rsplit(apk_blob_t blob, char split, apk_blob_t *l, apk_blob_t *r)
{
char *sep;