Skip to content

Commit

Permalink
Update libraries to 1.24.9
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2brain committed Sep 27, 2024
1 parent 1d242ef commit 2e4e552
Show file tree
Hide file tree
Showing 60 changed files with 1,547 additions and 138 deletions.
2 changes: 2 additions & 0 deletions include/mupdf/fitz.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ extern "C" {
#include "mupdf/fitz/compressed-buffer.h"
#include "mupdf/fitz/filter.h"
#include "mupdf/fitz/archive.h"
#include "mupdf/fitz/heap.h"


/* Resources */
#include "mupdf/fitz/store.h"
Expand Down
83 changes: 77 additions & 6 deletions include/mupdf/fitz/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ fz_archive *fz_open_directory(fz_context *ctx, const char *path);

/**
Determine if a given path is a directory.
In the case of the path not existing, or having no access
we will return 0.
*/
int fz_is_directory(fz_context *ctx, const char *path);

Expand Down Expand Up @@ -194,16 +197,30 @@ fz_buffer *fz_try_read_archive_entry(fz_context *ctx, fz_archive *arch, const ch
*/

/**
Detect if stream object is a tar achieve.
Detect if stream object is a tar archive.
Assumes that the stream object is seekable.
*/
int fz_is_tar_archive(fz_context *ctx, fz_stream *file);

/**
Detect if stream object is an archive supported by libarchive.
Assumes that the stream object is seekable.
*/
int fz_is_libarchive_archive(fz_context *ctx, fz_stream *file);

/**
Detect if stream object is a cfb archive.
Assumes that the stream object is seekable.
*/
int fz_is_cfb_archive(fz_context *ctx, fz_stream *file);

/**
Open a tar archive file.
An exception is throw if the file is not a tar archive as
An exception is thrown if the file is not a tar archive as
indicated by the presence of a tar signature.
filename: a path to a tar archive file as it would be given to
Expand All @@ -217,12 +234,52 @@ fz_archive *fz_open_tar_archive(fz_context *ctx, const char *filename);
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is throw if the stream is not a tar archive as
An exception is thrown if the stream is not a tar archive as
indicated by the presence of a tar signature.
*/
fz_archive *fz_open_tar_archive_with_stream(fz_context *ctx, fz_stream *file);

/**
Open an archive using libarchive.
An exception is thrown if the file is not supported by libarchive.
filename: a path to an archive file as it would be given to
open(2).
*/
fz_archive *fz_open_libarchive_archive(fz_context *ctx, const char *filename);

/**
Open an archive using libarchive.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is thrown if the stream is not supported by libarchive.
*/
fz_archive *fz_open_libarchive_archive_with_stream(fz_context *ctx, fz_stream *file);

/**
Open a cfb file as an archive.
An exception is thrown if the file is not recognised as a cfb.
filename: a path to an archive file as it would be given to
open(2).
*/
fz_archive *fz_open_cfb_archive(fz_context *ctx, const char *filename);

/**
Open a cfb file as an archive.
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is thrown if the file is not recognised as a chm.
*/
fz_archive *fz_open_cfb_archive_with_stream(fz_context *ctx, fz_stream *file);

/**
fz_archive: zip implementation
*/
Expand All @@ -237,7 +294,7 @@ int fz_is_zip_archive(fz_context *ctx, fz_stream *file);
/**
Open a zip archive file.
An exception is throw if the file is not a zip archive as
An exception is thrown if the file is not a zip archive as
indicated by the presence of a zip signature.
filename: a path to a zip archive file as it would be given to
Expand All @@ -251,7 +308,7 @@ fz_archive *fz_open_zip_archive(fz_context *ctx, const char *path);
Open an archive using a seekable stream object rather than
opening a file or directory on disk.
An exception is throw if the stream is not a zip archive as
An exception is thrown if the stream is not a zip archive as
indicated by the presence of a zip signature.
*/
Expand Down Expand Up @@ -344,15 +401,29 @@ fz_archive *fz_new_multi_archive(fz_context *ctx);
*/
void fz_mount_multi_archive(fz_context *ctx, fz_archive *arch_, fz_archive *sub, const char *path);

typedef int (fz_recognize_archive_fn)(fz_context *, fz_stream *);
typedef fz_archive *(fz_open_archive_fn)(fz_context *, fz_stream *);

typedef struct
{
fz_recognize_archive_fn *recognize;
fz_open_archive_fn *open;
}
fz_archive_handler;

FZ_DATA extern const fz_archive_handler fz_libarchive_archive_handler;

void fz_register_archive_handler(fz_context *ctx, const fz_archive_handler *handler);

/**
Implementation details: Subject to change.
*/

struct fz_archive
{
int refs;

fz_stream *file;

const char *format;

void (*drop_archive)(fz_context *ctx, fz_archive *arch);
Expand Down
7 changes: 7 additions & 0 deletions include/mupdf/fitz/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit);
*/
void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit);

/**
Invert bitmap.
Never throws exceptions.
*/
void fz_invert_bitmap(fz_context *ctx, fz_bitmap *bmp);

/**
A halftone is a set of threshold tiles, one per component. Each
threshold tile is a pixmap, possibly of varying sizes and
Expand Down
5 changes: 3 additions & 2 deletions include/mupdf/fitz/compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "mupdf/fitz/system.h"
#include "mupdf/fitz/buffer.h"
#include "mupdf/fitz/pixmap.h"

typedef enum
{
Expand Down Expand Up @@ -75,13 +76,13 @@ unsigned char *fz_new_deflated_data_from_buffer(fz_context *ctx, size_t *compres
Creates a stream assuming the default PDF parameters,
except the number of columns.
*/
fz_buffer *fz_compress_ccitt_fax_g3(fz_context *ctx, const unsigned char *data, int columns, int rows);
fz_buffer *fz_compress_ccitt_fax_g3(fz_context *ctx, const unsigned char *data, int columns, int rows, ptrdiff_t stride);

/**
Compress bitmap data as CCITT Group 4 2D fax image.
Creates a stream assuming the default PDF parameters, except
K=-1 and the number of columns.
*/
fz_buffer *fz_compress_ccitt_fax_g4(fz_context *ctx, const unsigned char *data, int columns, int rows);
fz_buffer *fz_compress_ccitt_fax_g4(fz_context *ctx, const unsigned char *data, int columns, int rows, ptrdiff_t stride);

#endif
12 changes: 12 additions & 0 deletions include/mupdf/fitz/compressed-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct
union {
struct {
int color_transform; /* Use -1 for unset */
int invert_cmyk; /* Use 1 for standalone JPEG files */
} jpeg;
struct {
int smask_in_data;
Expand Down Expand Up @@ -82,10 +83,16 @@ typedef struct
*/
typedef struct
{
int refs;
fz_compression_params params;
fz_buffer *buffer;
} fz_compressed_buffer;

/**
Take a reference to an fz_compressed_buffer.
*/
fz_compressed_buffer *fz_keep_compressed_buffer(fz_context *ctx, fz_compressed_buffer *cbuf);

/**
Return the storage size used for a buffer and its data.
Used in implementing store handling.
Expand Down Expand Up @@ -170,4 +177,9 @@ enum
*/
void fz_drop_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf);

/**
Create a new, UNKNOWN format, compressed_buffer.
*/
fz_compressed_buffer *fz_new_compressed_buffer(fz_context *ctx);

#endif
4 changes: 2 additions & 2 deletions include/mupdf/fitz/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@
unwanted fonts.
*/
/* To avoid all noto fonts except CJK, enable: */
#define TOFU
#define TOFU

/* To skip the CJK font, enable: (this implicitly enables TOFU_CJK_EXT
* and TOFU_CJK_LANG) */
#define TOFU_CJK
#define TOFU_CJK

/* To skip CJK Extension A, enable: (this implicitly enables
* TOFU_CJK_LANG) */
Expand Down
86 changes: 75 additions & 11 deletions include/mupdf/fitz/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct fz_tuning_context fz_tuning_context;
typedef struct fz_store fz_store;
typedef struct fz_glyph_cache fz_glyph_cache;
typedef struct fz_document_handler_context fz_document_handler_context;
typedef struct fz_archive_handler_context fz_archive_handler_context;
typedef struct fz_output fz_output;
typedef struct fz_context fz_context;

Expand Down Expand Up @@ -137,13 +138,22 @@ const char *fz_caught_message(fz_context *ctx);
*/
int fz_caught(fz_context *ctx);

/*
Within an fz_catch() block, retrieve the errno code for
the current SYSTEM exception.
Is undefined for non-SYSTEM errors.
*/
int fz_caught_errno(fz_context *ctx);

/**
Within an fz_catch() block, rethrow the current exception
if the errcode of the current exception matches.
This assumes no intervening use of fz_try/fz_catch.
*/
void fz_rethrow_if(fz_context *ctx, int errcode);
void fz_rethrow_unless(fz_context *ctx, int errcode);

/**
Format an error message, and log it to the registered
Expand Down Expand Up @@ -174,32 +184,56 @@ void fz_end_throw_on_repair(fz_context *ctx);
#define fz_vwarn(CTX, FMT, VA) fz_vwarnFL(CTX, __FILE__, __LINE__, FMT, VA)
#define fz_warn(CTX, ...) fz_warnFL(CTX, __FILE__, __LINE__, __VA_ARGS__)
#define fz_rethrow_if(CTX, ERRCODE) fz_rethrow_ifFL(CTX, __FILE__, __LINE__, ERRCODE)
#define fz_rethrow_unless(CTX, ERRCODE) fz_rethrow_unlessFL(CTX, __FILE__, __LINE__, ERRCODE)
#define fz_log_error_printf(CTX, ...) fz_log_error_printfFL(CTX, __FILE__, __LINE__, __VA_ARGS__)
#define fz_vlog_error_printf(CTX, FMT, VA) fz_log_error_printfFL(CTX, __FILE__, __LINE__, FMT, VA)
#define fz_log_error(CTX, STR) fz_log_error_printfFL(CTX, __FILE__, __LINE__, STR)
#define fz_do_catch(CTX) fz_do_catchFL(CTX, __FILE__, __LINE__)
FZ_NORETURN void fz_vthrowFL(fz_context *ctx, const char *file, int line, int errcode, const char *fmt, va_list ap);
FZ_NORETURN void fz_throwFL(fz_context *ctx, const char *file, int line, int errcode, const char *fmt, ...) FZ_PRINTFLIKE(5,6);
FZ_NORETURN void fz_rethrowFL(fz_context *ctx, const char *file, int line);
void fz_morph_errorFL(fz_context *ctx, const char *file, int line, int fromcode, int tocode);
void fz_vwarnFL(fz_context *ctx, const char *file, int line, const char *fmt, va_list ap);
void fz_warnFL(fz_context *ctx, const char *file, int line, const char *fmt, ...) FZ_PRINTFLIKE(4,5);
void fz_rethrow_ifFL(fz_context *ctx, const char *file, int line, int errcode);
void fz_rethrow_unlessFL(fz_context *ctx, const char *file, int line, int errcode);
void fz_log_error_printfFL(fz_context *ctx, const char *file, int line, const char *fmt, ...) FZ_PRINTFLIKE(4,5);
void fz_vlog_error_printfFL(fz_context *ctx, const char *file, int line, const char *fmt, va_list ap);
void fz_log_errorFL(fz_context *ctx, const char *file, int line, const char *str);
int fz_do_catchFL(fz_context *ctx, const char *file, int line);
#endif

enum
/* Report an error to the registered error callback. */
void fz_report_error(fz_context *ctx);

/*
* Swallow an error and ignore it completely.
* This should only be called to signal that you've handled a TRYLATER or ABORT error,
*/
void fz_ignore_error(fz_context *ctx);

/* Convert an error into another runtime exception.
* For use when converting an exception from Fitz to a language binding exception.
*/
const char *fz_convert_error(fz_context *ctx, int *code);

enum fz_error_type
{
FZ_ERROR_NONE = 0,
FZ_ERROR_MEMORY = 1,
FZ_ERROR_GENERIC = 2,
FZ_ERROR_SYNTAX = 3,
FZ_ERROR_MINOR = 4,
FZ_ERROR_TRYLATER = 5,
FZ_ERROR_ABORT = 6,
FZ_ERROR_REPAIRED = 7,
FZ_ERROR_COUNT
FZ_ERROR_NONE,
FZ_ERROR_GENERIC,

FZ_ERROR_SYSTEM, // fatal out of memory or syscall error
FZ_ERROR_LIBRARY, // unclassified error from third-party library
FZ_ERROR_ARGUMENT, // invalid or out-of-range arguments to functions
FZ_ERROR_LIMIT, // failed because of resource or other hard limits
FZ_ERROR_UNSUPPORTED, // tried to use an unsupported feature
FZ_ERROR_FORMAT, // syntax or format errors that are unrecoverable
FZ_ERROR_SYNTAX, // syntax errors that should be diagnosed and ignored

// for internal use only
FZ_ERROR_TRYLATER, // try-later progressive loading signal
FZ_ERROR_ABORT, // user requested abort signal
FZ_ERROR_REPAIRED, // internal flag used when repairing a PDF to avoid cycles
};

/**
Expand Down Expand Up @@ -690,6 +724,34 @@ char *fz_strdup(fz_context *ctx, const char *s);
*/
void fz_memrnd(fz_context *ctx, uint8_t *block, int len);

/*
Reference counted malloced C strings.
*/
typedef struct
{
int refs;
char str[1];
} fz_string;

/*
Allocate a new string to hold a copy of str.
Returns with a refcount of 1.
*/
fz_string *fz_new_string(fz_context *ctx, const char *str);

/*
Take another reference to a string.
*/
fz_string *fz_keep_string(fz_context *ctx, fz_string *str);

/*
Drop a reference to a string, freeing if the refcount
reaches 0.
*/
void fz_drop_string(fz_context *ctx, fz_string *str);

#define fz_cstring_from_string(A) ((A) == NULL ? NULL : (A)->str)

/* Implementation details: subject to change. */

Expand All @@ -699,7 +761,7 @@ void fz_var_imp(void *);
fz_jmp_buf *fz_push_try(fz_context *ctx);
int fz_do_try(fz_context *ctx);
int fz_do_always(fz_context *ctx);
int fz_do_catch(fz_context *ctx);
int (fz_do_catch)(fz_context *ctx);

#ifndef FZ_JMPBUF_ALIGN
#define FZ_JMPBUF_ALIGN 32
Expand All @@ -719,6 +781,7 @@ typedef struct
fz_error_stack_slot padding;
fz_error_stack_slot *stack_base;
int errcode;
int errnum; /* errno for SYSTEM class errors */
void *print_user;
void (*print)(void *user, const char *message);
char message[256];
Expand Down Expand Up @@ -760,6 +823,7 @@ struct fz_context

/* TODO: should these be unshared? */
fz_document_handler_context *handler;
fz_archive_handler_context *archive;
fz_style_context *style;
fz_tuning_context *tuning;

Expand Down
Loading

0 comments on commit 2e4e552

Please sign in to comment.