diff --git a/src/ctx.h b/src/ctx.h index b8296fe..07ca3c2 100644 --- a/src/ctx.h +++ b/src/ctx.h @@ -40,6 +40,8 @@ typedef struct { pcre_extra *exclude_extra; int fast; + GHashTable *dbg_current_files; + scan_arc_ctx_t arc_ctx; scan_comic_ctx_t comic_ctx; scan_ebook_ctx_t ebook_ctx; diff --git a/src/io/serialize.c b/src/io/serialize.c index 424b132..a7981b7 100644 --- a/src/io/serialize.c +++ b/src/io/serialize.c @@ -15,9 +15,13 @@ typedef struct { char has_parent; } line_t; +#define META_NEXT 0xFFFF + void skip_meta(FILE *file) { - enum metakey key = getc(file); - while (key != '\n') { + enum metakey key; + fread(&key, sizeof(uint16_t), 1, file); + + while (key != META_NEXT) { if (IS_META_INT(key)) { fseek(file, sizeof(int), SEEK_CUR); } else if (IS_META_LONG(key)) { @@ -26,7 +30,7 @@ void skip_meta(FILE *file) { while ((getc(file))) {} } - key = getc(file); + fread(&key, sizeof(uint16_t), 1, file); } } @@ -66,7 +70,7 @@ index_descriptor_t read_index_descriptor(char *path) { } char *buf = malloc(info.st_size + 1); - int ret = read(fd, buf, info.st_size); + size_t ret = read(fd, buf, info.st_size); if (ret == -1) { LOG_FATALF("serialize.c", "Could not read index descriptor: %s", strerror(errno)); } @@ -152,8 +156,20 @@ char *get_meta_key_text(enum metakey meta_key) { return "thumbnail"; case MetaPages: return "pages"; + case MetaExifGpsLongitudeRef: + return "exif_gps_longitude_ref"; + case MetaExifGpsLongitudeDMS: + return "exif_gps_longitude_dms"; + case MetaExifGpsLongitudeDec: + return "exif_gps_longitude_dec"; + case MetaExifGpsLatitudeRef: + return "exif_gps_latitude_ref"; + case MetaExifGpsLatitudeDMS: + return "exif_gps_latitude_dms"; + case MetaExifGpsLatitudeDec: + return "exif_gps_latitude_dec"; default: - return NULL; + LOG_FATALF("serialize.c", "FIXME: Unknown meta key: %d", meta_key) } } @@ -183,7 +199,7 @@ void write_document(document_t *doc) { meta_line_t *meta = doc->meta_head; while (meta != NULL) { - dyn_buffer_write_char(&buf, meta->key); + dyn_buffer_write_short(&buf, (uint16_t) meta->key); if (IS_META_INT(meta->key)) { dyn_buffer_write_int(&buf, meta->int_val); @@ -197,7 +213,7 @@ void write_document(document_t *doc) { meta = meta->next; free(tmp); } - dyn_buffer_write_char(&buf, '\n'); + dyn_buffer_write_short(&buf, META_NEXT); int res = write(index_fd, buf.buf, buf.cur); if (res == -1) { @@ -268,9 +284,10 @@ void read_index_bin(const char *path, const char *index_id, index_func func) { cJSON_AddStringToObject(document, "path", ""); } - enum metakey key = getc(file); - size_t ret = 0; - while (key != '\n') { + enum metakey key; + fread(&key, sizeof(short), 1, file); + size_t ret; + while (key != META_NEXT) { switch (key) { case MetaPages: case MetaWidth: @@ -308,6 +325,12 @@ void read_index_bin(const char *path, const char *index_id, index_func func) { case MetaAuthor: case MetaModifiedBy: case MetaThumbnail: + case MetaExifGpsLongitudeDMS: + case MetaExifGpsLongitudeDec: + case MetaExifGpsLongitudeRef: + case MetaExifGpsLatitudeDMS: + case MetaExifGpsLatitudeDec: + case MetaExifGpsLatitudeRef: case MetaTitle: { buf.cur = 0; while ((c = getc(file)) != 0) { @@ -323,7 +346,7 @@ void read_index_bin(const char *path, const char *index_id, index_func func) { LOG_FATALF("serialize.c", "Invalid meta key (corrupt index): %x", key) } - key = getc(file); + fread(&key, sizeof(uint16_t), 1, file); } cJSON *meta_obj = NULL; @@ -510,9 +533,9 @@ void incremental_copy(store_t *store, store_t *dst_store, const char *filepath, enum metakey key; while (1) { - key = getc(file); - fwrite(&key, sizeof(char), 1, dst_file); - if (key == '\n') { + fread(&key, sizeof(uint16_t), 1, file); + fwrite(&key, sizeof(uint16_t), 1, dst_file); + if (key == META_NEXT) { break; } diff --git a/src/main.c b/src/main.c index 09d7e94..e1fd9ca 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ #define EPILOG "Made by simon987 . Released under GPL-3.0" -static const char *const Version = "2.9.1"; +static const char *const Version = "2.10.1"; static const char *const usage[] = { "sist2 scan [OPTION]... PATH", "sist2 index [OPTION]... INDEX", diff --git a/src/static/search.html b/src/static/search.html index 772c53e..f2ef165 100644 --- a/src/static/search.html +++ b/src/static/search.html @@ -12,7 +12,7 @@