PageRenderTime 22ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/include/freetype/internal/ftrfork.h

https://bitbucket.org/codefirex/external_freetype
C Header | 258 lines | 81 code | 33 blank | 144 comment | 0 complexity | 927cbce5738815a283ae52837e538252 MD5 | raw file
  1. /***************************************************************************/
  2. /* */
  3. /* ftrfork.h */
  4. /* */
  5. /* Embedded resource forks accessor (specification). */
  6. /* */
  7. /* Copyright 2004, 2006, 2007, 2012 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, \
  71. FT_RFork_Rule_ ## type_suffix },
  72. #define CONST_FT_RFORK_RULE_ARRAY_END };
  73. #else /* FT_CONFIG_OPTION_PIC */
  74. /* this array is a function in PIC mode, so no ; is needed in END */
  75. #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \
  76. void \
  77. FT_Init_ ## name( type* storage ) \
  78. { \
  79. type* local = storage; \
  80. \
  81. \
  82. int i = 0;
  83. #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \
  84. local[i].func = raccess_guess_ ## func_suffix; \
  85. local[i].type = FT_RFork_Rule_ ## type_suffix; \
  86. i++;
  87. #define CONST_FT_RFORK_RULE_ARRAY_END }
  88. #endif /* FT_CONFIG_OPTION_PIC */
  89. #endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
  90. /*************************************************************************/
  91. /* */
  92. /* <Function> */
  93. /* FT_Raccess_Guess */
  94. /* */
  95. /* <Description> */
  96. /* Guess a file name and offset where the actual resource fork is */
  97. /* stored. The macro FT_RACCESS_N_RULES holds the number of */
  98. /* guessing rules; the guessed result for the Nth rule is */
  99. /* represented as a triplet: a new file name (new_names[N]), a file */
  100. /* offset (offsets[N]), and an error code (errors[N]). */
  101. /* */
  102. /* <Input> */
  103. /* library :: */
  104. /* A FreeType library instance. */
  105. /* */
  106. /* stream :: */
  107. /* A file stream containing the resource fork. */
  108. /* */
  109. /* base_name :: */
  110. /* The (base) file name of the resource fork used for some */
  111. /* guessing rules. */
  112. /* */
  113. /* <Output> */
  114. /* new_names :: */
  115. /* An array of guessed file names in which the resource forks may */
  116. /* exist. If `new_names[N]' is NULL, the guessed file name is */
  117. /* equal to `base_name'. */
  118. /* */
  119. /* offsets :: */
  120. /* An array of guessed file offsets. `offsets[N]' holds the file */
  121. /* offset of the possible start of the resource fork in file */
  122. /* `new_names[N]'. */
  123. /* */
  124. /* errors :: */
  125. /* An array of FreeType error codes. `errors[N]' is the error */
  126. /* code of Nth guessing rule function. If `errors[N]' is not */
  127. /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */
  128. /* */
  129. FT_BASE( void )
  130. FT_Raccess_Guess( FT_Library library,
  131. FT_Stream stream,
  132. char* base_name,
  133. char** new_names,
  134. FT_Long* offsets,
  135. FT_Error* errors );
  136. /*************************************************************************/
  137. /* */
  138. /* <Function> */
  139. /* FT_Raccess_Get_HeaderInfo */
  140. /* */
  141. /* <Description> */
  142. /* Get the information from the header of resource fork. The */
  143. /* information includes the file offset where the resource map */
  144. /* starts, and the file offset where the resource data starts. */
  145. /* `FT_Raccess_Get_DataOffsets' requires these two data. */
  146. /* */
  147. /* <Input> */
  148. /* library :: */
  149. /* A FreeType library instance. */
  150. /* */
  151. /* stream :: */
  152. /* A file stream containing the resource fork. */
  153. /* */
  154. /* rfork_offset :: */
  155. /* The file offset where the resource fork starts. */
  156. /* */
  157. /* <Output> */
  158. /* map_offset :: */
  159. /* The file offset where the resource map starts. */
  160. /* */
  161. /* rdata_pos :: */
  162. /* The file offset where the resource data starts. */
  163. /* */
  164. /* <Return> */
  165. /* FreeType error code. FT_Err_Ok means success. */
  166. /* */
  167. FT_BASE( FT_Error )
  168. FT_Raccess_Get_HeaderInfo( FT_Library library,
  169. FT_Stream stream,
  170. FT_Long rfork_offset,
  171. FT_Long *map_offset,
  172. FT_Long *rdata_pos );
  173. /*************************************************************************/
  174. /* */
  175. /* <Function> */
  176. /* FT_Raccess_Get_DataOffsets */
  177. /* */
  178. /* <Description> */
  179. /* Get the data offsets for a tag in a resource fork. Offsets are */
  180. /* stored in an array because, in some cases, resources in a resource */
  181. /* fork have the same tag. */
  182. /* */
  183. /* <Input> */
  184. /* library :: */
  185. /* A FreeType library instance. */
  186. /* */
  187. /* stream :: */
  188. /* A file stream containing the resource fork. */
  189. /* */
  190. /* map_offset :: */
  191. /* The file offset where the resource map starts. */
  192. /* */
  193. /* rdata_pos :: */
  194. /* The file offset where the resource data starts. */
  195. /* */
  196. /* tag :: */
  197. /* The resource tag. */
  198. /* */
  199. /* <Output> */
  200. /* offsets :: */
  201. /* The stream offsets for the resource data specified by `tag'. */
  202. /* This array is allocated by the function, so you have to call */
  203. /* @ft_mem_free after use. */
  204. /* */
  205. /* count :: */
  206. /* The length of offsets array. */
  207. /* */
  208. /* <Return> */
  209. /* FreeType error code. FT_Err_Ok means success. */
  210. /* */
  211. /* <Note> */
  212. /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */
  213. /* value for `map_offset' and `rdata_pos'. */
  214. /* */
  215. FT_BASE( FT_Error )
  216. FT_Raccess_Get_DataOffsets( FT_Library library,
  217. FT_Stream stream,
  218. FT_Long map_offset,
  219. FT_Long rdata_pos,
  220. FT_Long tag,
  221. FT_Long **offsets,
  222. FT_Long *count );
  223. FT_END_HEADER
  224. #endif /* __FTRFORK_H__ */
  225. /* END */