/src/freetype/include/freetype/internal/ftrfork.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 247 lines · 76 code · 27 blank · 144 comment · 0 complexity · fec5bd46e290a02a1da4df6709960769 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftrfork.h */
  4. /* */
  5. /* Embedded resource forks accessor (specification). */
  6. /* */
  7. /* Copyright 2004, 2006, 2007 by */
  8. /* Masatake YAMATO and Redhat K.K. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. /***************************************************************************/
  18. /* Development of the code in this file is support of */
  19. /* Information-technology Promotion Agency, Japan. */
  20. /***************************************************************************/
  21. #ifndef __FTRFORK_H__
  22. #define __FTRFORK_H__
  23. #include <ft2build.h>
  24. #include FT_INTERNAL_OBJECTS_H
  25. FT_BEGIN_HEADER
  26. /* Number of guessing rules supported in `FT_Raccess_Guess'. */
  27. /* Don't forget to increment the number if you add a new guessing rule. */
  28. #define FT_RACCESS_N_RULES 9
  29. /* A structure to describe a reference in a resource by its resource ID */
  30. /* and internal offset. The `POST' resource expects to be concatenated */
  31. /* by the order of resource IDs instead of its appearance in the file. */
  32. typedef struct FT_RFork_Ref_
  33. {
  34. FT_UShort res_id;
  35. FT_ULong offset;
  36. } FT_RFork_Ref;
  37. #ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
  38. typedef FT_Error
  39. (*ft_raccess_guess_func)( FT_Library library,
  40. FT_Stream stream,
  41. char *base_file_name,
  42. char **result_file_name,
  43. FT_Long *result_offset );
  44. typedef enum FT_RFork_Rule_ {
  45. FT_RFork_Rule_invalid = -2,
  46. FT_RFork_Rule_uknown, /* -1 */
  47. FT_RFork_Rule_apple_double,
  48. FT_RFork_Rule_apple_single,
  49. FT_RFork_Rule_darwin_ufs_export,
  50. FT_RFork_Rule_darwin_newvfs,
  51. FT_RFork_Rule_darwin_hfsplus,
  52. FT_RFork_Rule_vfat,
  53. FT_RFork_Rule_linux_cap,
  54. FT_RFork_Rule_linux_double,
  55. FT_RFork_Rule_linux_netatalk
  56. } FT_RFork_Rule;
  57. /* For fast translation between rule index and rule type,
  58. * the macros FT_RFORK_xxx should be kept consistent with
  59. * the raccess_guess_funcs table
  60. */
  61. typedef struct ft_raccess_guess_rec_ {
  62. ft_raccess_guess_func func;
  63. FT_RFork_Rule type;
  64. } ft_raccess_guess_rec;
  65. #ifndef FT_CONFIG_OPTION_PIC
  66. /* this array is a storage in non-PIC mode, so ; is needed in END */
  67. #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
  68. const type name[] = {
  69. #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
  70. { raccess_guess_##func_suffix, FT_RFork_Rule_##type_suffix },
  71. #define CONST_FT_RFORK_RULE_ARRAY_END };
  72. #else /* FT_CONFIG_OPTION_PIC */
  73. /* this array is a function in PIC mode, so no ; is needed in END */
  74. #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
  75. void FT_Init_##name ( type* storage ) { \
  76. type *local = storage; \
  77. int i = 0;
  78. #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
  79. local[i].func = raccess_guess_##func_suffix; \
  80. local[i].type = FT_RFork_Rule_##type_suffix; \
  81. i++;
  82. #define CONST_FT_RFORK_RULE_ARRAY_END }
  83. #endif /* FT_CONFIG_OPTION_PIC */
  84. #endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
  85. /*************************************************************************/
  86. /* */
  87. /* <Function> */
  88. /* FT_Raccess_Guess */
  89. /* */
  90. /* <Description> */
  91. /* Guess a file name and offset where the actual resource fork is */
  92. /* stored. The macro FT_RACCESS_N_RULES holds the number of */
  93. /* guessing rules; the guessed result for the Nth rule is */
  94. /* represented as a triplet: a new file name (new_names[N]), a file */
  95. /* offset (offsets[N]), and an error code (errors[N]). */
  96. /* */
  97. /* <Input> */
  98. /* library :: */
  99. /* A FreeType library instance. */
  100. /* */
  101. /* stream :: */
  102. /* A file stream containing the resource fork. */
  103. /* */
  104. /* base_name :: */
  105. /* The (base) file name of the resource fork used for some */
  106. /* guessing rules. */
  107. /* */
  108. /* <Output> */
  109. /* new_names :: */
  110. /* An array of guessed file names in which the resource forks may */
  111. /* exist. If `new_names[N]' is NULL, the guessed file name is */
  112. /* equal to `base_name'. */
  113. /* */
  114. /* offsets :: */
  115. /* An array of guessed file offsets. `offsets[N]' holds the file */
  116. /* offset of the possible start of the resource fork in file */
  117. /* `new_names[N]'. */
  118. /* */
  119. /* errors :: */
  120. /* An array of FreeType error codes. `errors[N]' is the error */
  121. /* code of Nth guessing rule function. If `errors[N]' is not */
  122. /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */
  123. /* */
  124. FT_BASE( void )
  125. FT_Raccess_Guess( FT_Library library,
  126. FT_Stream stream,
  127. char* base_name,
  128. char** new_names,
  129. FT_Long* offsets,
  130. FT_Error* errors );
  131. /*************************************************************************/
  132. /* */
  133. /* <Function> */
  134. /* FT_Raccess_Get_HeaderInfo */
  135. /* */
  136. /* <Description> */
  137. /* Get the information from the header of resource fork. The */
  138. /* information includes the file offset where the resource map */
  139. /* starts, and the file offset where the resource data starts. */
  140. /* `FT_Raccess_Get_DataOffsets' requires these two data. */
  141. /* */
  142. /* <Input> */
  143. /* library :: */
  144. /* A FreeType library instance. */
  145. /* */
  146. /* stream :: */
  147. /* A file stream containing the resource fork. */
  148. /* */
  149. /* rfork_offset :: */
  150. /* The file offset where the resource fork starts. */
  151. /* */
  152. /* <Output> */
  153. /* map_offset :: */
  154. /* The file offset where the resource map starts. */
  155. /* */
  156. /* rdata_pos :: */
  157. /* The file offset where the resource data starts. */
  158. /* */
  159. /* <Return> */
  160. /* FreeType error code. FT_Err_Ok means success. */
  161. /* */
  162. FT_BASE( FT_Error )
  163. FT_Raccess_Get_HeaderInfo( FT_Library library,
  164. FT_Stream stream,
  165. FT_Long rfork_offset,
  166. FT_Long *map_offset,
  167. FT_Long *rdata_pos );
  168. /*************************************************************************/
  169. /* */
  170. /* <Function> */
  171. /* FT_Raccess_Get_DataOffsets */
  172. /* */
  173. /* <Description> */
  174. /* Get the data offsets for a tag in a resource fork. Offsets are */
  175. /* stored in an array because, in some cases, resources in a resource */
  176. /* fork have the same tag. */
  177. /* */
  178. /* <Input> */
  179. /* library :: */
  180. /* A FreeType library instance. */
  181. /* */
  182. /* stream :: */
  183. /* A file stream containing the resource fork. */
  184. /* */
  185. /* map_offset :: */
  186. /* The file offset where the resource map starts. */
  187. /* */
  188. /* rdata_pos :: */
  189. /* The file offset where the resource data starts. */
  190. /* */
  191. /* tag :: */
  192. /* The resource tag. */
  193. /* */
  194. /* <Output> */
  195. /* offsets :: */
  196. /* The stream offsets for the resource data specified by `tag'. */
  197. /* This array is allocated by the function, so you have to call */
  198. /* @ft_mem_free after use. */
  199. /* */
  200. /* count :: */
  201. /* The length of offsets array. */
  202. /* */
  203. /* <Return> */
  204. /* FreeType error code. FT_Err_Ok means success. */
  205. /* */
  206. /* <Note> */
  207. /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */
  208. /* value for `map_offset' and `rdata_pos'. */
  209. /* */
  210. FT_BASE( FT_Error )
  211. FT_Raccess_Get_DataOffsets( FT_Library library,
  212. FT_Stream stream,
  213. FT_Long map_offset,
  214. FT_Long rdata_pos,
  215. FT_Long tag,
  216. FT_Long **offsets,
  217. FT_Long *count );
  218. FT_END_HEADER
  219. #endif /* __FTRFORK_H__ */
  220. /* END */