1 /*
    2  * << Haru Free PDF Library >> -- hpdf_error.h
    3  *
    4  * URL: http://libharu.org
    5  *
    6  * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
    7  * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
    8  *
    9  * Permission to use, copy, modify, distribute and sell this software
   10  * and its documentation for any purpose is hereby granted without fee,
   11  * provided that the above copyright notice appear in all copies and
   12  * that both that copyright notice and this permission notice appear
   13  * in supporting documentation.
   14  * It is provided "as is" without express or implied warranty.
   15  *
   16  */
   17 
   18 #ifndef _HPDF_ERROR_H
   19 #define _HPDF_ERROR_H
   20 
   21 #include "hpdf_types.h"
   22 
   23 #ifdef __cplusplus
   24 extern "C" {
   25 #endif
   26 
   27 /* error-code */
   28 #define HPDF_ARRAY_COUNT_ERR                      0x1001
   29 #define HPDF_ARRAY_ITEM_NOT_FOUND                 0x1002
   30 #define HPDF_ARRAY_ITEM_UNEXPECTED_TYPE           0x1003
   31 #define HPDF_BINARY_LENGTH_ERR                    0x1004
   32 #define HPDF_CANNOT_GET_PALLET                    0x1005
   33 #define HPDF_DICT_COUNT_ERR                       0x1007
   34 #define HPDF_DICT_ITEM_NOT_FOUND                  0x1008
   35 #define HPDF_DICT_ITEM_UNEXPECTED_TYPE            0x1009
   36 #define HPDF_DICT_STREAM_LENGTH_NOT_FOUND         0x100A
   37 #define HPDF_DOC_ENCRYPTDICT_NOT_FOUND            0x100B
   38 #define HPDF_DOC_INVALID_OBJECT                   0x100C
   39 /*                                                0x100D */
   40 #define HPDF_DUPLICATE_REGISTRATION               0x100E
   41 #define HPDF_EXCEED_JWW_CODE_NUM_LIMIT            0x100F
   42 /*                                                0x1010 */
   43 #define HPDF_ENCRYPT_INVALID_PASSWORD             0x1011
   44 /*                                                0x1012 */
   45 #define HPDF_ERR_UNKNOWN_CLASS                    0x1013
   46 #define HPDF_EXCEED_GSTATE_LIMIT                  0x1014
   47 #define HPDF_FAILD_TO_ALLOC_MEM                   0x1015
   48 #define HPDF_FILE_IO_ERROR                        0x1016
   49 #define HPDF_FILE_OPEN_ERROR                      0x1017
   50 /*                                                0x1018 */
   51 #define HPDF_FONT_EXISTS                          0x1019
   52 #define HPDF_FONT_INVALID_WIDTHS_TABLE            0x101A
   53 #define HPDF_INVALID_AFM_HEADER                   0x101B
   54 #define HPDF_INVALID_ANNOTATION                   0x101C
   55 /*                                                0x101D */
   56 #define HPDF_INVALID_BIT_PER_COMPONENT            0x101E
   57 #define HPDF_INVALID_CHAR_MATRICS_DATA            0x101F
   58 #define HPDF_INVALID_COLOR_SPACE                  0x1020
   59 #define HPDF_INVALID_COMPRESSION_MODE             0x1021
   60 #define HPDF_INVALID_DATE_TIME                    0x1022
   61 #define HPDF_INVALID_DESTINATION                  0x1023
   62 /*                                                0x1024 */
   63 #define HPDF_INVALID_DOCUMENT                     0x1025
   64 #define HPDF_INVALID_DOCUMENT_STATE               0x1026
   65 #define HPDF_INVALID_ENCODER                      0x1027
   66 #define HPDF_INVALID_ENCODER_TYPE                 0x1028
   67 /*                                                0x1029 */
   68 /*                                                0x102A */
   69 #define HPDF_INVALID_ENCODING_NAME                0x102B
   70 #define HPDF_INVALID_ENCRYPT_KEY_LEN              0x102C
   71 #define HPDF_INVALID_FONTDEF_DATA                 0x102D
   72 #define HPDF_INVALID_FONTDEF_TYPE                 0x102E
   73 #define HPDF_INVALID_FONT_NAME                    0x102F
   74 #define HPDF_INVALID_IMAGE                        0x1030
   75 #define HPDF_INVALID_JPEG_DATA                    0x1031
   76 #define HPDF_INVALID_N_DATA                       0x1032
   77 #define HPDF_INVALID_OBJECT                       0x1033
   78 #define HPDF_INVALID_OBJ_ID                       0x1034
   79 #define HPDF_INVALID_OPERATION                    0x1035
   80 #define HPDF_INVALID_OUTLINE                      0x1036
   81 #define HPDF_INVALID_PAGE                         0x1037
   82 #define HPDF_INVALID_PAGES                        0x1038
   83 #define HPDF_INVALID_PARAMETER                    0x1039
   84 /*                                                0x103A */
   85 #define HPDF_INVALID_PNG_IMAGE                    0x103B
   86 #define HPDF_INVALID_STREAM                       0x103C
   87 #define HPDF_MISSING_FILE_NAME_ENTRY              0x103D
   88 /*                                                0x103E */
   89 #define HPDF_INVALID_TTC_FILE                     0x103F
   90 #define HPDF_INVALID_TTC_INDEX                    0x1040
   91 #define HPDF_INVALID_WX_DATA                      0x1041
   92 #define HPDF_ITEM_NOT_FOUND                       0x1042
   93 #define HPDF_LIBPNG_ERROR                         0x1043
   94 #define HPDF_NAME_INVALID_VALUE                   0x1044
   95 #define HPDF_NAME_OUT_OF_RANGE                    0x1045
   96 /*                                                0x1046 */
   97 /*                                                0x1047 */
   98 #define HPDF_PAGE_INVALID_PARAM_COUNT             0x1048
   99 #define HPDF_PAGES_MISSING_KIDS_ENTRY             0x1049
  100 #define HPDF_PAGE_CANNOT_FIND_OBJECT              0x104A
  101 #define HPDF_PAGE_CANNOT_GET_ROOT_PAGES           0x104B
  102 #define HPDF_PAGE_CANNOT_RESTORE_GSTATE           0x104C
  103 #define HPDF_PAGE_CANNOT_SET_PARENT               0x104D
  104 #define HPDF_PAGE_FONT_NOT_FOUND                  0x104E
  105 #define HPDF_PAGE_INVALID_FONT                    0x104F
  106 #define HPDF_PAGE_INVALID_FONT_SIZE               0x1050
  107 #define HPDF_PAGE_INVALID_GMODE                   0x1051
  108 #define HPDF_PAGE_INVALID_INDEX                   0x1052
  109 #define HPDF_PAGE_INVALID_ROTATE_VALUE            0x1053
  110 #define HPDF_PAGE_INVALID_SIZE                    0x1054
  111 #define HPDF_PAGE_INVALID_XOBJECT                 0x1055
  112 #define HPDF_PAGE_OUT_OF_RANGE                    0x1056
  113 #define HPDF_REAL_OUT_OF_RANGE                    0x1057
  114 #define HPDF_STREAM_EOF                           0x1058
  115 #define HPDF_STREAM_READLN_CONTINUE               0x1059
  116 /*                                                0x105A */
  117 #define HPDF_STRING_OUT_OF_RANGE                  0x105B
  118 #define HPDF_THIS_FUNC_WAS_SKIPPED                0x105C
  119 #define HPDF_TTF_CANNOT_EMBEDDING_FONT            0x105D
  120 #define HPDF_TTF_INVALID_CMAP                     0x105E
  121 #define HPDF_TTF_INVALID_FOMAT                    0x105F
  122 #define HPDF_TTF_MISSING_TABLE                    0x1060
  123 #define HPDF_UNSUPPORTED_FONT_TYPE                0x1061
  124 #define HPDF_UNSUPPORTED_FUNC                     0x1062
  125 #define HPDF_UNSUPPORTED_JPEG_FORMAT              0x1063
  126 #define HPDF_UNSUPPORTED_TYPE1_FONT               0x1064
  127 #define HPDF_XREF_COUNT_ERR                       0x1065
  128 #define HPDF_ZLIB_ERROR                           0x1066
  129 #define HPDF_INVALID_PAGE_INDEX                   0x1067
  130 #define HPDF_INVALID_URI                          0x1068
  131 #define HPDF_PAGE_LAYOUT_OUT_OF_RANGE             0x1069
  132 #define HPDF_PAGE_MODE_OUT_OF_RANGE               0x1070
  133 #define HPDF_PAGE_NUM_STYLE_OUT_OF_RANGE          0x1071
  134 #define HPDF_ANNOT_INVALID_ICON                   0x1072
  135 #define HPDF_ANNOT_INVALID_BORDER_STYLE           0x1073
  136 #define HPDF_PAGE_INVALID_DIRECTION               0x1074
  137 #define HPDF_INVALID_FONT                         0x1075
  138 #define HPDF_PAGE_INSUFFICIENT_SPACE              0x1076
  139 #define HPDF_PAGE_INVALID_DISPLAY_TIME            0x1077
  140 #define HPDF_PAGE_INVALID_TRANSITION_TIME         0x1078
  141 #define HPDF_INVALID_PAGE_SLIDESHOW_TYPE          0x1079
  142 #define HPDF_EXT_GSTATE_OUT_OF_RANGE              0x1080
  143 #define HPDF_INVALID_EXT_GSTATE                   0x1081
  144 #define HPDF_EXT_GSTATE_READ_ONLY                 0x1082
  145 #define HPDF_INVALID_U3D_DATA                     0x1083
  146 #define HPDF_NAME_CANNOT_GET_NAMES                0x1084
  147 #define HPDF_INVALID_ICC_COMPONENT_NUM            0x1085
  148 
  149 /*---------------------------------------------------------------------------*/
  150 
  151 /*---------------------------------------------------------------------------*/
  152 /*----- HPDF_Error ----------------------------------------------------------*/
  153 
  154 typedef struct  _HPDF_Error_Rec  *HPDF_Error;
  155 
  156 typedef struct  _HPDF_Error_Rec {
  157     HPDF_STATUS             error_no;
  158     HPDF_STATUS             detail_no;
  159     HPDF_Error_Handler      error_fn;
  160     void                    *user_data;
  161 } HPDF_Error_Rec;
  162 
  163 
  164 /*  HPDF_Error_init
  165  *
  166  *  if error_fn is NULL, the default-handlers are set as error-handler.
  167  *  user_data is used to identify the object which threw an error.
  168  *
  169  */
  170 void
  171 HPDF_Error_Init  (HPDF_Error    error,
  172                   void         *user_data);
  173 
  174 
  175 void
  176 HPDF_Error_Reset  (HPDF_Error  error);
  177 
  178 
  179 HPDF_STATUS
  180 HPDF_Error_GetCode  (HPDF_Error  error);
  181 
  182 
  183 HPDF_STATUS
  184 HPDF_Error_GetDetailCode  (HPDF_Error  error);
  185 
  186 
  187 HPDF_STATUS
  188 HPDF_SetError  (HPDF_Error   error,
  189                 HPDF_STATUS  error_no,
  190                 HPDF_STATUS  detail_no);
  191 
  192 
  193 HPDF_STATUS
  194 HPDF_RaiseError  (HPDF_Error   error,
  195                   HPDF_STATUS  error_no,
  196                   HPDF_STATUS  detail_no);
  197 
  198 #ifdef __cplusplus
  199 }
  200 #endif /* __cplusplus */
  201 
  202 #endif /* _HPDF_ERROR_H */
  203