diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-06-19 14:20:43 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-06-19 14:46:58 +0200 |
commit | daef4e8fb856e84e2a9151cd7715a941a0ae9c6c (patch) | |
tree | 87882b3455a61c867300e5a157c078f2f7addc21 /include/qpdf/qpdfjob-c.h | |
parent | 28cc3692e37b9f231d58c0c24e5e90674988ef64 (diff) | |
download | qpdf-daef4e8fb856e84e2a9151cd7715a941a0ae9c6c.tar.zst |
Add more flexible funtions to qpdfjob C API
Diffstat (limited to 'include/qpdf/qpdfjob-c.h')
-rw-r--r-- | include/qpdf/qpdfjob-c.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/qpdf/qpdfjob-c.h b/include/qpdf/qpdfjob-c.h index b9fe8ccb..e15c8fa5 100644 --- a/include/qpdf/qpdfjob-c.h +++ b/include/qpdf/qpdfjob-c.h @@ -45,6 +45,11 @@ #ifdef __cplusplus extern "C" { #endif + /* SHORT INTERFACE -- These functions are single calls that take + * care of the whole life cycle of QPDFJob. They can be used for + * one-shot ooperations where no additional configuration is + * needed. See FULL INTERFACE below. */ + /* This function does the equivalent of running the qpdf * command-line with the given arguments and returns the exit code * that qpdf would use. argv must be a null-terminated array of @@ -74,6 +79,52 @@ extern "C" { QPDF_DLL int qpdfjob_run_from_json(char const* json); + /* FULL INTERFACE -- new in qpdf11. Similar to the qpdf-c.h API, + * you must call qpdfjob_init to get a qpdfjob_handle and, when + * done, call qpdfjob_cleanup to free resources. Remaining methods + * take qpdfjob_handle as an argument. This interface requires + * more calls but also offers greater flexibility. + */ + typedef struct _qpdfjob_handle* qpdfjob_handle; + QPDF_DLL + qpdfjob_handle qpdfjob_init(); + + QPDF_DLL + void qpdfjob_cleanup(qpdfjob_handle* j); + + /* This function wraps QPDFJob::initializeFromArgv. The return + * value is the same as qpdfjob_run. If this returns an error, it + * is invalid to call any other functions this job handle. + */ + QPDF_DLL + int + qpdfjob_initialize_from_argv(qpdfjob_handle j, char const* const argv[]); + +#ifndef QPDF_NO_WCHAR_T + /* This function is the same as qpdfjob_initialize_from_argv + * except argv is encoded with wide characters. This would be + * suitable for calling from a Windows wmain function. + */ + QPDF_DLL + int qpdfjob_initialize_from_wide_argv( + qpdfjob_handle j, wchar_t const* const argv[]); +#endif /* QPDF_NO_WCHAR_T */ + + /* This function wraps QPDFJob::initializeFromJson. The return + * value is the same as qpdfjob_run. If this returns an error, it + * is invalid to call any other functions this job handle. + */ + QPDF_DLL + int qpdfjob_initialize_from_json(qpdfjob_handle j, char const* json); + + /* This function wraps QPDFJob::run. It returns the error code + * that qpdf would return with the equivalent command-line + * invocation. Exit code values are defined in Constants.h in the + * qpdf_exit_code_e type. + */ + QPDF_DLL + int qpdfjob_run(qpdfjob_handle j); + #ifdef __cplusplus } #endif |