mirror of
https://github.com/simon987/libscan.git
synced 2025-04-21 03:06:44 +00:00
Compare commits
No commits in common. "8212dd4b23576772894b30bce0956be58d0d7773" and "0a9742b6865da7b60b77790b8288ca6d8b17471c" have entirely different histories.
8212dd4b23
...
0a9742b686
@ -47,25 +47,19 @@ int arc_read(struct vfile *f, void *buf, size_t size) {
|
||||
return read;
|
||||
}
|
||||
|
||||
int arc_open(scan_arc_ctx_t *ctx, vfile_t *f, struct archive **a, arc_data_t *arc_data, int allow_recurse) {
|
||||
int arc_open(vfile_t *f, struct archive **a, arc_data_t *arc_data, int allow_recurse) {
|
||||
arc_data->f = f;
|
||||
|
||||
if (f->is_fs_file) {
|
||||
*a = archive_read_new();
|
||||
archive_read_support_filter_all(*a);
|
||||
archive_read_support_format_all(*a);
|
||||
if (ctx->passphrase[0] != 0) {
|
||||
archive_read_add_passphrase(*a, ctx->passphrase);
|
||||
}
|
||||
|
||||
return archive_read_open_filename(*a, f->filepath, ARC_BUF_SIZE);
|
||||
} else if (allow_recurse) {
|
||||
*a = archive_read_new();
|
||||
archive_read_support_filter_all(*a);
|
||||
archive_read_support_format_all(*a);
|
||||
if (ctx->passphrase[0] != 0) {
|
||||
archive_read_add_passphrase(*a, ctx->passphrase);
|
||||
}
|
||||
|
||||
return archive_read_open(
|
||||
*a, arc_data,
|
||||
@ -86,7 +80,7 @@ scan_code_t parse_archive(scan_arc_ctx_t *ctx, vfile_t *f, document_t *doc) {
|
||||
arc_data_t arc_data;
|
||||
arc_data.f = f;
|
||||
|
||||
int ret = arc_open(ctx, f, &a, &arc_data, ctx->mode == ARC_MODE_RECURSE);
|
||||
int ret = arc_open(f, &a, &arc_data, ctx->mode == ARC_MODE_RECURSE);
|
||||
if (ret == ARC_SKIPPED) {
|
||||
return SCAN_OK;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ typedef struct {
|
||||
log_callback_t log;
|
||||
logf_callback_t logf;
|
||||
store_callback_t store;
|
||||
char passphrase[1024];
|
||||
} scan_arc_ctx_t;
|
||||
|
||||
#define ARC_BUF_SIZE 8192
|
||||
@ -57,7 +56,7 @@ static int vfile_close_callback(struct archive *a, void *user_data) {
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
int arc_open(scan_arc_ctx_t *ctx, vfile_t *f, struct archive **a, arc_data_t *arc_data, int allow_recurse);
|
||||
int arc_open(vfile_t *f, struct archive **a, arc_data_t *arc_data, int allow_recurse);
|
||||
|
||||
int should_parse_filtered_file(const char *filepath, int ext);
|
||||
|
||||
|
@ -5,14 +5,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <archive.h>
|
||||
|
||||
static scan_arc_ctx_t arc_ctx = (scan_arc_ctx_t) {.passphrase = {0,}};
|
||||
|
||||
void parse_comic(scan_comic_ctx_t *ctx, vfile_t *f, document_t *doc) {
|
||||
struct archive *a = NULL;
|
||||
struct archive_entry *entry = NULL;
|
||||
arc_data_t arc_data;
|
||||
|
||||
int ret = arc_open(&arc_ctx, f, &a, &arc_data, TRUE);
|
||||
int ret = arc_open(f, &a, &arc_data, TRUE);
|
||||
if (ret != ARCHIVE_OK) {
|
||||
CTX_LOG_ERRORF(f->filepath, "(cbr.c) [%d] %s", ret, archive_error_string(a))
|
||||
archive_read_free(a);
|
||||
|
@ -88,7 +88,7 @@ void parse_msdoc_pdf(scan_msdoc_ctx_t *ctx, document_t *doc, FILE *file, void* b
|
||||
opts->bHideHiddenText = 1;
|
||||
opts->bRemoveRemovedText = 1;
|
||||
opts->bUseLandscape = 0;
|
||||
opts->eEncoding = encoding_latin_1;
|
||||
opts->eEncoding = encoding_latin_2;
|
||||
opts->iPageHeight = 842; // A4
|
||||
opts->iPageWidth = 595;
|
||||
opts->eImageLevel = level_ps_3;
|
||||
|
@ -595,20 +595,6 @@ TEST(Arc, Utf8) {
|
||||
cleanup(&doc, &f);
|
||||
}
|
||||
|
||||
TEST(Arc, EncryptedZip) {
|
||||
vfile_t f;
|
||||
document_t doc;
|
||||
load_doc_file("libscan-test-files/test_files/arc/encrypted.zip", &f, &doc);
|
||||
|
||||
size_t size_before = store_size;
|
||||
|
||||
parse_archive(&arc_recurse_media_ctx, &f, &doc);
|
||||
|
||||
ASSERT_NE(size_before, store_size);
|
||||
|
||||
cleanup(&doc, &f);
|
||||
}
|
||||
|
||||
/* RAW */
|
||||
TEST(RAW, Panasonic) {
|
||||
vfile_t f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user