Commit 28cc3692e37b9f231d58c0c24e5e90674988ef64
1 parent
d2e68b57
Expose exit code values to C API via Constants.h
Showing
6 changed files
with
30 additions
and
8 deletions
ChangeLog
| 1 | 1 | 2022-06-18 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | |
| 3 | + * Add qpdf_exit_code_e to Constants.h so that exit codes from | |
| 4 | + QPDFJob are accessible to the C API. | |
| 5 | + | |
| 3 | 6 | * When --progress or --verbose is combined with writing to |
| 4 | 7 | standard output, progress reporting and verbose messages go to |
| 5 | 8 | standard error. Previously it was disabled in this case. | ... | ... |
TODO
include/qpdf/Constants.h
| ... | ... | @@ -27,6 +27,18 @@ |
| 27 | 27 | * interfaces. |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | +/* Exit Codes from QPDFJob and the qpdf CLI */ | |
| 31 | + | |
| 32 | +enum qpdf_exit_code_e { | |
| 33 | + qpdf_exit_success = 0, | |
| 34 | + /* Normal exit codes */ | |
| 35 | + qpdf_exit_error = 2, | |
| 36 | + qpdf_exit_warning = 3, | |
| 37 | + /* For --is-encrypted and --requires-password */ | |
| 38 | + qpdf_exit_is_not_encrypted = 2, | |
| 39 | + qpdf_exit_correct_password = 3, | |
| 40 | +}; | |
| 41 | + | |
| 30 | 42 | /* Error Codes */ |
| 31 | 43 | |
| 32 | 44 | enum qpdf_error_code_e { | ... | ... |
include/qpdf/QPDFJob.hh
| ... | ... | @@ -47,11 +47,11 @@ class QPDFJob |
| 47 | 47 | { |
| 48 | 48 | public: |
| 49 | 49 | // Exit codes -- returned by getExitCode() after calling run() |
| 50 | - static int constexpr EXIT_ERROR = 2; | |
| 51 | - static int constexpr EXIT_WARNING = 3; | |
| 50 | + static int constexpr EXIT_ERROR = qpdf_exit_error; | |
| 51 | + static int constexpr EXIT_WARNING = qpdf_exit_warning; | |
| 52 | 52 | // For is-encrypted and requires-password |
| 53 | - static int constexpr EXIT_IS_NOT_ENCRYPTED = 2; | |
| 54 | - static int constexpr EXIT_CORRECT_PASSWORD = 3; | |
| 53 | + static int constexpr EXIT_IS_NOT_ENCRYPTED = qpdf_exit_is_not_encrypted; | |
| 54 | + static int constexpr EXIT_CORRECT_PASSWORD = qpdf_exit_correct_password; | |
| 55 | 55 | |
| 56 | 56 | // QPDFUsage is thrown if there are any usage-like errors when |
| 57 | 57 | // calling Config methods. | ... | ... |
include/qpdf/qpdfjob-c.h
| ... | ... | @@ -49,7 +49,9 @@ extern "C" { |
| 49 | 49 | * command-line with the given arguments and returns the exit code |
| 50 | 50 | * that qpdf would use. argv must be a null-terminated array of |
| 51 | 51 | * null-terminated UTF8-encoded strings. If calling this from |
| 52 | - * wmain on Windows, use qpdfjob_run_from_wide_argv instead. | |
| 52 | + * wmain on Windows, use qpdfjob_run_from_wide_argv instead. Exit | |
| 53 | + * code values are defined in Constants.h in the qpdf_exit_code_e | |
| 54 | + * type. | |
| 53 | 55 | */ |
| 54 | 56 | QPDF_DLL |
| 55 | 57 | int qpdfjob_run_from_argv(char const* const argv[]); |
| ... | ... | @@ -66,7 +68,8 @@ extern "C" { |
| 66 | 68 | /* This function runs QPDFJob from a job JSON file. See the "QPDF |
| 67 | 69 | * Job" section of the manual for details. The JSON string must be |
| 68 | 70 | * UTF8-encoded. It returns the error code that qpdf would return |
| 69 | - * with the equivalent command-line invocation. | |
| 71 | + * with the equivalent command-line invocation. Exit code values | |
| 72 | + * are defined in Constants.h in the qpdf_exit_code_e type. | |
| 70 | 73 | */ |
| 71 | 74 | QPDF_DLL |
| 72 | 75 | int qpdfjob_run_from_json(char const* json); | ... | ... |
manual/release-notes.rst
| ... | ... | @@ -1717,6 +1717,12 @@ For a detailed list of changes, please see the file |
| 1717 | 1717 | and may optionally compensate for rotation or scaling of the |
| 1718 | 1718 | destination page. |
| 1719 | 1719 | |
| 1720 | + - Exit codes returned by ``QPDFJob::run()`` and the C API wrappers | |
| 1721 | + are now defined in :file:`qpdf/Constants.h` in the | |
| 1722 | + ``qpdf_exit_code_e`` type so that they are accessible from the C | |
| 1723 | + API. They were previously only defined as constants in | |
| 1724 | + :file:`qpdf/QPDFJob.hh`. | |
| 1725 | + | |
| 1720 | 1726 | - Build Improvements |
| 1721 | 1727 | |
| 1722 | 1728 | - Add new configure option | ... | ... |