diff options
author | Jay Berkenbilt <ejb@ql.org> | 2009-10-20 02:24:44 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2009-10-20 02:24:44 +0200 |
commit | 398354b6f0c5e8311496481c2b80c1eb4bec4424 (patch) | |
tree | 538fe208893671fd7c10e24c7b79549b972ab18f /include | |
parent | 3f8c4c273649c857f5a607dcbb422729fce3a166 (diff) | |
download | qpdf-398354b6f0c5e8311496481c2b80c1eb4bec4424.tar.zst |
update C API for error retrieval
git-svn-id: svn+q:///qpdf/trunk@830 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDF.hh | 4 | ||||
-rw-r--r-- | include/qpdf/QPDFExc.hh | 6 | ||||
-rw-r--r-- | include/qpdf/qpdf-c.h | 37 |
3 files changed, 35 insertions, 12 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 178d71c7..3f66a5f9 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -70,7 +70,7 @@ class DLL_EXPORT QPDF // throws an exception. Note that if setSuppressWarnings was not // called or was called with a false value, any warnings retrieved // here will have already been issued to stderr. - std::vector<std::string> getWarnings(); + std::vector<QPDFExc> getWarnings(); std::string getFilename() const; std::string getPDFVersion() const; @@ -761,7 +761,7 @@ class DLL_EXPORT QPDF std::map<ObjGen, ObjCache> obj_cache; QPDFObjectHandle trailer; std::vector<QPDFObjectHandle> all_pages; - std::vector<std::string> warnings; + std::vector<QPDFExc> warnings; // Linearization data int first_xref_item_offset; // actual value from file diff --git a/include/qpdf/QPDFExc.hh b/include/qpdf/QPDFExc.hh index 6b9a11e4..7d6d8968 100644 --- a/include/qpdf/QPDFExc.hh +++ b/include/qpdf/QPDFExc.hh @@ -11,7 +11,7 @@ #include <qpdf/DLL.h> #include <qpdf/Constants.h> #include <stdexcept> -#include <stddef.h> +#include <fcntl.h> class DLL_EXPORT QPDFExc: public std::runtime_error { @@ -36,8 +36,8 @@ class DLL_EXPORT QPDFExc: public std::runtime_error qpdf_error_code_e getErrorCode() const; std::string const& getFilename() const; std::string const& getObject() const; - off_t getOffset() const; - std::string const& getMessage() const; + off_t getFilePosition() const; + std::string const& getMessageDetail() const; private: static std::string createWhat(std::string const& filename, diff --git a/include/qpdf/qpdf-c.h b/include/qpdf/qpdf-c.h index 90b3e5f9..ef4c4c6b 100644 --- a/include/qpdf/qpdf-c.h +++ b/include/qpdf/qpdf-c.h @@ -63,12 +63,14 @@ #include <qpdf/DLL.h> #include <qpdf/Constants.h> +#include <fcntl.h> #ifdef __cplusplus extern "C" { #endif typedef struct _qpdf_data* qpdf_data; + typedef struct _qpdf_error* qpdf_error; /* Many functions return an integer error code. Codes are defined * below. See comments at the top of the file for details. Note @@ -97,21 +99,42 @@ extern "C" { /* ERROR REPORTING */ - /* Returns 1 if there are any errors or warnings, and zero - * otherwise. + /* Returns the error condition, if any. The return value is a + * pointer to data that will become invalid the next time an error + * occurs or after this function is called gain. */ DLL_EXPORT - QPDF_BOOL qpdf_more_errors(qpdf_data qpdf); + qpdf_error qpdf_get_error(qpdf_data qpdf); + + /* Returns 1 if there are any unretrieved warnings, and zero + * otherwise. + */ DLL_EXPORT QPDF_BOOL qpdf_more_warnings(qpdf_data qpdf); - /* If there are any errors/warnings, returns a pointer to the next - * error or warning. Otherwise returns a null pointer. + /* If there are any warnings, returns a pointer to the next + * warning. Otherwise returns a null pointer. */ DLL_EXPORT - char const* qpdf_next_error(qpdf_data qpdf); + qpdf_error qpdf_next_warning(qpdf_data qpdf); + + /* Extract fields of the error. */ + + /* Use this function to get a full error message suitable for + * showing to the user. */ + DLL_EXPORT + char const* qpdf_get_error_full_text(qpdf_data q, qpdf_error e); + + /* Use these functions to extract individual fields from the + * error; see QPDFExc.hh for details. */ + DLL_EXPORT + enum qpdf_error_code_e qpdf_get_error_code(qpdf_data q, qpdf_error e); + DLL_EXPORT + char const* qpdf_get_error_filename(qpdf_data q, qpdf_error e); + DLL_EXPORT + off_t qpdf_get_error_file_position(qpdf_data q, qpdf_error e); DLL_EXPORT - char const* qpdf_next_warning(qpdf_data qpdf); + char const* qpdf_get_error_message_detail(qpdf_data q, qpdf_error e); /* By default, warnings are written to stderr. Passing true to * this function will prevent warnings from being written to |