1 /* 2 * << Haru Free PDF Library >> -- fpdf_utils.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_UTILS_H 19 #define _HPDF_UTILS_H 20 21 #include "hpdf_config.h" 22 #include "hpdf_types.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif /* __cplusplus */ 27 28 HPDF_INT 29 HPDF_AToI (const char* s); 30 31 32 HPDF_DOUBLE 33 HPDF_AToF (const char* s); 34 35 36 char* 37 HPDF_IToA (char* s, 38 HPDF_INT32 val, 39 char* eptr); 40 41 42 char* 43 HPDF_IToA2 (char *s, 44 HPDF_UINT32 val, 45 HPDF_UINT len); 46 47 48 char* 49 HPDF_FToA (char *s, 50 HPDF_REAL val, 51 char *eptr); 52 53 54 HPDF_BYTE* 55 HPDF_MemCpy (HPDF_BYTE* out, 56 const HPDF_BYTE* in, 57 HPDF_UINT n); 58 59 60 HPDF_BYTE* 61 HPDF_StrCpy (char* out, 62 const char* in, 63 char* eptr); 64 65 66 HPDF_INT 67 HPDF_MemCmp (const HPDF_BYTE* s1, 68 const HPDF_BYTE* s2, 69 HPDF_UINT n); 70 71 72 HPDF_INT 73 HPDF_StrCmp (const char* s1, 74 const char* s2); 75 76 77 const char* 78 HPDF_StrStr (const char *s1, 79 const char *s2, 80 HPDF_UINT maxlen); 81 82 83 void* 84 HPDF_MemSet (void* s, 85 HPDF_BYTE c, 86 HPDF_UINT n); 87 88 89 HPDF_UINT 90 HPDF_StrLen (const char* s, 91 HPDF_INT maxlen); 92 93 94 HPDF_Box 95 HPDF_ToBox (HPDF_INT16 left, 96 HPDF_INT16 bottom, 97 HPDF_INT16 right, 98 HPDF_INT16 top); 99 100 101 HPDF_Point 102 HPDF_ToPoint (HPDF_INT16 x, 103 HPDF_INT16 y); 104 105 106 HPDF_Rect 107 HPDF_ToRect (HPDF_REAL left, 108 HPDF_REAL bottom, 109 HPDF_REAL right, 110 HPDF_REAL top); 111 112 113 void 114 HPDF_UInt16Swap (HPDF_UINT16 *value); 115 116 117 #ifdef __cplusplus 118 } 119 #endif /* __cplusplus */ 120 121 #define HPDF_NEEDS_ESCAPE(c) (c < 0x20 || \ 122 c > 0x7e || \ 123 c == '\\' || \ 124 c == '%' || \ 125 c == '#' || \ 126 c == '/' || \ 127 c == '(' || \ 128 c == ')' || \ 129 c == '<' || \ 130 c == '>' || \ 131 c == '[' || \ 132 c == ']' || \ 133 c == '{' || \ 134 c == '}' ) \ 135 136 #define HPDF_IS_WHITE_SPACE(c) (c == 0x00 || \ 137 c == 0x09 || \ 138 c == 0x0A || \ 139 c == 0x0C || \ 140 c == 0x0D || \ 141 c == 0x20 ) \ 142 143 /*----------------------------------------------------------------------------*/ 144 /*----- macros for debug -----------------------------------------------------*/ 145 146 #ifdef LIBHPDF_DEBUG_TRACE 147 #ifndef HPDF_PTRACE_ON 148 #define HPDF_PTRACE_ON 149 #endif /* HPDF_PTRACE_ON */ 150 #endif /* LIBHPDF_DEBUG_TRACE */ 151 152 #ifdef HPDF_PTRACE_ON 153 #define HPDF_PTRACE(ARGS) HPDF_PRINTF ARGS 154 #else 155 #define HPDF_PTRACE(ARGS) /* do nothing */ 156 #endif /* HPDF_PTRACE */ 157 158 #ifdef LIBHPDF_DEBUG 159 #define HPDF_PRINT_BINARY(BUF, LEN, CAPTION) HPDF_PrintBinary(BUF, LEN, CAPTION) 160 #else 161 #define HPDF_PRINT_BINARY(BUF, LEN, CAPTION) /* do nothing */ 162 #endif 163 164 #endif /* _HPDF_UTILS_H */ 165