diff options
author | Timo Teräs <timo.teras@iki.fi> | 2021-07-17 15:43:08 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-07-22 15:30:08 +0300 |
commit | b559a81694d8a95ac786104516aebf98d04b84bc (patch) | |
tree | 2bd4601015e0d7202c3eb685bf79756022d11b06 /src/app_convdb.c | |
parent | 94c5e01038a819e8abd062ed81aec321cdff4aa3 (diff) | |
download | apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.tar.gz apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.tar.bz2 apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.tar.xz apk-tools-b559a81694d8a95ac786104516aebf98d04b84bc.zip |
io: rework apk_istream_get_* to not return erros in blob value
The interface was slightly cumbersome, so replace these functions
to return explicit error, and make the return blob a pointer arg.
Diffstat (limited to 'src/app_convdb.c')
-rw-r--r-- | src/app_convdb.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/app_convdb.c b/src/app_convdb.c index 7c457a5..f30d0f7 100644 --- a/src/app_convdb.c +++ b/src/app_convdb.c @@ -86,19 +86,17 @@ static int read_triggers(struct conv_ctx *ctx, struct apk_istream *is) if (IS_ERR(is)) return PTR_ERR(is); - while (!APK_BLOB_IS_NULL(l = apk_istream_get_delim(is, nl))) { + while (apk_istream_get_delim(is, nl, &l) == 0) { if (!apk_blob_split(l, spc, &l, &r)) continue; s = find_pkg(ctx, l, ADBI_SCRPT_TRIGGER); if (!s) continue; s->triggers = apk_atomize_dup(&ctx->atoms, r); } - - apk_istream_close(is); - return 0; + return apk_istream_close(is); } -static void convert_idb(struct conv_ctx *ctx, struct apk_istream *is) +static int convert_idb(struct conv_ctx *ctx, struct apk_istream *is) { struct apk_id_cache *idc = apk_ctx_get_id_cache(ctx->ac); struct apk_checksum csum; @@ -117,7 +115,7 @@ static void convert_idb(struct conv_ctx *ctx, struct apk_istream *is) adb_wo_alloca(&pkg, &schema_package, &ctx->dbp); adb_wo_alloca(&acl, &schema_acl, &ctx->dbp); - while (!APK_BLOB_IS_NULL(l = apk_istream_get_delim(is, nl))) { + while (apk_istream_get_delim(is, nl, &l) == 0) { if (l.len < 2) { adb_wa_append_obj(&files, &file); adb_wo_obj(&path, ADBI_DI_FILES, &files); @@ -191,6 +189,7 @@ static void convert_idb(struct conv_ctx *ctx, struct apk_istream *is) break; } } + return apk_istream_close(is); } static int conv_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *args) |