From 28cc3692e37b9f231d58c0c24e5e90674988ef64 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 18 Jun 2022 11:36:11 -0400 Subject: Expose exit code values to C API via Constants.h --- include/qpdf/Constants.h | 12 ++++++++++++ include/qpdf/QPDFJob.hh | 8 ++++---- include/qpdf/qpdfjob-c.h | 7 +++++-- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/qpdf/Constants.h b/include/qpdf/Constants.h index 8cc67210..5d2113bd 100644 --- a/include/qpdf/Constants.h +++ b/include/qpdf/Constants.h @@ -27,6 +27,18 @@ * interfaces. */ +/* Exit Codes from QPDFJob and the qpdf CLI */ + +enum qpdf_exit_code_e { + qpdf_exit_success = 0, + /* Normal exit codes */ + qpdf_exit_error = 2, + qpdf_exit_warning = 3, + /* For --is-encrypted and --requires-password */ + qpdf_exit_is_not_encrypted = 2, + qpdf_exit_correct_password = 3, +}; + /* Error Codes */ enum qpdf_error_code_e { diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index 5c6d6856..39c7a612 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -47,11 +47,11 @@ class QPDFJob { public: // Exit codes -- returned by getExitCode() after calling run() - static int constexpr EXIT_ERROR = 2; - static int constexpr EXIT_WARNING = 3; + static int constexpr EXIT_ERROR = qpdf_exit_error; + static int constexpr EXIT_WARNING = qpdf_exit_warning; // For is-encrypted and requires-password - static int constexpr EXIT_IS_NOT_ENCRYPTED = 2; - static int constexpr EXIT_CORRECT_PASSWORD = 3; + static int constexpr EXIT_IS_NOT_ENCRYPTED = qpdf_exit_is_not_encrypted; + static int constexpr EXIT_CORRECT_PASSWORD = qpdf_exit_correct_password; // QPDFUsage is thrown if there are any usage-like errors when // calling Config methods. diff --git a/include/qpdf/qpdfjob-c.h b/include/qpdf/qpdfjob-c.h index 93ab3e28..b9fe8ccb 100644 --- a/include/qpdf/qpdfjob-c.h +++ b/include/qpdf/qpdfjob-c.h @@ -49,7 +49,9 @@ extern "C" { * command-line with the given arguments and returns the exit code * that qpdf would use. argv must be a null-terminated array of * null-terminated UTF8-encoded strings. If calling this from - * wmain on Windows, use qpdfjob_run_from_wide_argv instead. + * wmain on Windows, use qpdfjob_run_from_wide_argv instead. Exit + * code values are defined in Constants.h in the qpdf_exit_code_e + * type. */ QPDF_DLL int qpdfjob_run_from_argv(char const* const argv[]); @@ -66,7 +68,8 @@ extern "C" { /* This function runs QPDFJob from a job JSON file. See the "QPDF * Job" section of the manual for details. The JSON string must be * UTF8-encoded. It returns the error code that qpdf would return - * with the equivalent command-line invocation. + * 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_from_json(char const* json); -- cgit v1.2.3-54-g00ecf