hpdf_utils.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * << Haru Free PDF Library >> -- fpdf_utils.h
  3. *
  4. * URL: http://libharu.org
  5. *
  6. * Copyright (c) 1999-2006 Takeshi Kanno <[email protected]>
  7. * Copyright (c) 2007-2009 Antony Dovgal <[email protected]>
  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. #ifndef _HPDF_UTILS_H
  18. #define _HPDF_UTILS_H
  19. #include "hpdf_config.h"
  20. #include "hpdf_types.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif /* __cplusplus */
  24. HPDF_INT
  25. HPDF_AToI (const char* s);
  26. HPDF_DOUBLE
  27. HPDF_AToF (const char* s);
  28. char*
  29. HPDF_IToA (char* s,
  30. HPDF_INT32 val,
  31. char* eptr);
  32. char*
  33. HPDF_IToA2 (char *s,
  34. HPDF_UINT32 val,
  35. HPDF_UINT len);
  36. char*
  37. HPDF_FToA (char *s,
  38. HPDF_REAL val,
  39. char *eptr);
  40. HPDF_BYTE*
  41. HPDF_MemCpy (HPDF_BYTE* out,
  42. const HPDF_BYTE* in,
  43. HPDF_UINT n);
  44. HPDF_BYTE*
  45. HPDF_StrCpy (char* out,
  46. const char* in,
  47. char* eptr);
  48. HPDF_INT
  49. HPDF_MemCmp (const HPDF_BYTE* s1,
  50. const HPDF_BYTE* s2,
  51. HPDF_UINT n);
  52. HPDF_INT
  53. HPDF_StrCmp (const char* s1,
  54. const char* s2);
  55. const char*
  56. HPDF_StrStr (const char *s1,
  57. const char *s2,
  58. HPDF_UINT maxlen);
  59. void*
  60. HPDF_MemSet (void* s,
  61. HPDF_BYTE c,
  62. HPDF_UINT n);
  63. HPDF_UINT
  64. HPDF_StrLen (const char* s,
  65. HPDF_INT maxlen);
  66. HPDF_Box
  67. HPDF_ToBox (HPDF_INT16 left,
  68. HPDF_INT16 bottom,
  69. HPDF_INT16 right,
  70. HPDF_INT16 top);
  71. HPDF_Point
  72. HPDF_ToPoint (HPDF_INT16 x,
  73. HPDF_INT16 y);
  74. HPDF_Rect
  75. HPDF_ToRect (HPDF_REAL left,
  76. HPDF_REAL bottom,
  77. HPDF_REAL right,
  78. HPDF_REAL top);
  79. void
  80. HPDF_UInt16Swap (HPDF_UINT16 *value);
  81. #ifdef __cplusplus
  82. }
  83. #endif /* __cplusplus */
  84. #define HPDF_NEEDS_ESCAPE(c) (c < 0x20 || \
  85. c > 0x7e || \
  86. c == '\\' || \
  87. c == '%' || \
  88. c == '#' || \
  89. c == '/' || \
  90. c == '(' || \
  91. c == ')' || \
  92. c == '<' || \
  93. c == '>' || \
  94. c == '[' || \
  95. c == ']' || \
  96. c == '{' || \
  97. c == '}' ) \
  98. #define HPDF_IS_WHITE_SPACE(c) (c == 0x00 || \
  99. c == 0x09 || \
  100. c == 0x0A || \
  101. c == 0x0C || \
  102. c == 0x0D || \
  103. c == 0x20 ) \
  104. /*----------------------------------------------------------------------------*/
  105. /*----- macros for debug -----------------------------------------------------*/
  106. #ifdef LIBHPDF_DEBUG_TRACE
  107. #ifndef HPDF_PTRACE_ON
  108. #define HPDF_PTRACE_ON
  109. #endif /* HPDF_PTRACE_ON */
  110. #endif /* LIBHPDF_DEBUG_TRACE */
  111. #ifdef HPDF_PTRACE_ON
  112. #define HPDF_PTRACE(ARGS) HPDF_PRINTF ARGS
  113. #else
  114. #define HPDF_PTRACE(ARGS) /* do nothing */
  115. #endif /* HPDF_PTRACE */
  116. #ifdef LIBHPDF_DEBUG
  117. #define HPDF_PRINT_BINARY(BUF, LEN, CAPTION) HPDF_PrintBinary(BUF, LEN, CAPTION)
  118. #else
  119. #define HPDF_PRINT_BINARY(BUF, LEN, CAPTION) /* do nothing */
  120. #endif
  121. #endif /* _HPDF_UTILS_H */