mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-07 06:08:26 +00:00
Switch user-supplied functions in C API to return int
This commit is contained in:
parent
b0f054e600
commit
66f1fd2ad9
@ -12,11 +12,11 @@
|
||||
// something with QPDFJob. See qpdfjob-c-save-attachment.c for an
|
||||
// implementation that uses the C API.
|
||||
|
||||
static void
|
||||
static int
|
||||
save_to_file(char const* data, size_t len, void* udata)
|
||||
{
|
||||
FILE* f = (FILE*)udata;
|
||||
fwrite(data, 1, len, f);
|
||||
return fwrite(data, 1, len, f) != len;
|
||||
}
|
||||
|
||||
static FILE*
|
||||
|
@ -59,7 +59,8 @@ extern "C" {
|
||||
qpdf_log_dest_custom = 4,
|
||||
};
|
||||
|
||||
typedef void (*qpdf_log_fn_t)(char const* data, size_t len, void* udata);
|
||||
/* Function should return 0 on success. */
|
||||
typedef int (*qpdf_log_fn_t)(char const* data, size_t len, void* udata);
|
||||
|
||||
QPDF_DLL
|
||||
void qpdflogger_set_info(
|
||||
|
@ -56,12 +56,7 @@ set_log_dest(
|
||||
method(l->discard());
|
||||
break;
|
||||
case qpdf_log_dest_custom:
|
||||
method(std::make_shared<Pl_Function>(
|
||||
identifier,
|
||||
nullptr,
|
||||
[fn, udata](unsigned char const* data, size_t len) {
|
||||
fn(reinterpret_cast<char const*>(data), len, udata);
|
||||
}));
|
||||
method(std::make_shared<Pl_Function>(identifier, nullptr, fn, udata));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void
|
||||
static int
|
||||
fn(char const* data, size_t len, void* udata)
|
||||
{
|
||||
FILE* f = (FILE*)udata;
|
||||
fwrite(data, 1, len, f);
|
||||
return fwrite(data, 1, len, f) != len;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user