diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-04-14 18:46:35 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-04-14 18:46:35 +0300 |
commit | 7cef96c30d2f2d585aa2edd7b6ab22e9e007cddc (patch) | |
tree | 1f3d552a5cb9396c7408b021e1acc739a90289a3 /src/blob.c | |
parent | 024480aca02a5a81113cdf7a47aafa4c1c30de3d (diff) | |
download | apk-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.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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; |