00001 /***************************************************************************/ 00002 /* */ 00003 /* ftrfork.h */ 00004 /* */ 00005 /* Embedded resource forks accessor (specification). */ 00006 /* */ 00007 /* Copyright 2004, 2006, 2007 by */ 00008 /* Masatake YAMATO and Redhat K.K. */ 00009 /* */ 00010 /* This file is part of the FreeType project, and may only be used, */ 00011 /* modified, and distributed under the terms of the FreeType project */ 00012 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00013 /* this file you indicate that you have read the license and */ 00014 /* understand and accept it fully. */ 00015 /* */ 00016 /***************************************************************************/ 00017 00018 /***************************************************************************/ 00019 /* Development of the code in this file is support of */ 00020 /* Information-technology Promotion Agency, Japan. */ 00021 /***************************************************************************/ 00022 00023 00024 #ifndef __FTRFORK_H__ 00025 #define __FTRFORK_H__ 00026 00027 00028 #include <ft2build.h> 00029 #include FT_INTERNAL_OBJECTS_H 00030 00031 00032 FT_BEGIN_HEADER 00033 00034 00035 /* Number of guessing rules supported in `FT_Raccess_Guess'. */ 00036 /* Don't forget to increment the number if you add a new guessing rule. */ 00037 #define FT_RACCESS_N_RULES 9 00038 00039 00040 /* A structure to describe a reference in a resource by its resource ID */ 00041 /* and internal offset. The `POST' resource expects to be concatenated */ 00042 /* by the order of resource IDs instead of its appearance in the file. */ 00043 00044 typedef struct FT_RFork_Ref_ 00045 { 00046 FT_UShort res_id; 00047 FT_ULong offset; 00048 00049 } FT_RFork_Ref; 00050 00051 00052 /*************************************************************************/ 00053 /* */ 00054 /* <Function> */ 00055 /* FT_Raccess_Guess */ 00056 /* */ 00057 /* <Description> */ 00058 /* Guess a file name and offset where the actual resource fork is */ 00059 /* stored. The macro FT_RACCESS_N_RULES holds the number of */ 00060 /* guessing rules; the guessed result for the Nth rule is */ 00061 /* represented as a triplet: a new file name (new_names[N]), a file */ 00062 /* offset (offsets[N]), and an error code (errors[N]). */ 00063 /* */ 00064 /* <Input> */ 00065 /* library :: */ 00066 /* A FreeType library instance. */ 00067 /* */ 00068 /* stream :: */ 00069 /* A file stream containing the resource fork. */ 00070 /* */ 00071 /* base_name :: */ 00072 /* The (base) file name of the resource fork used for some */ 00073 /* guessing rules. */ 00074 /* */ 00075 /* <Output> */ 00076 /* new_names :: */ 00077 /* An array of guessed file names in which the resource forks may */ 00078 /* exist. If `new_names[N]' is NULL, the guessed file name is */ 00079 /* equal to `base_name'. */ 00080 /* */ 00081 /* offsets :: */ 00082 /* An array of guessed file offsets. `offsets[N]' holds the file */ 00083 /* offset of the possible start of the resource fork in file */ 00084 /* `new_names[N]'. */ 00085 /* */ 00086 /* errors :: */ 00087 /* An array of FreeType error codes. `errors[N]' is the error */ 00088 /* code of Nth guessing rule function. If `errors[N]' is not */ 00089 /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */ 00090 /* */ 00091 FT_BASE( void ) 00092 FT_Raccess_Guess( FT_Library library, 00093 FT_Stream stream, 00094 char* base_name, 00095 char** new_names, 00096 FT_Long* offsets, 00097 FT_Error* errors ); 00098 00099 00100 /*************************************************************************/ 00101 /* */ 00102 /* <Function> */ 00103 /* FT_Raccess_Get_HeaderInfo */ 00104 /* */ 00105 /* <Description> */ 00106 /* Get the information from the header of resource fork. The */ 00107 /* information includes the file offset where the resource map */ 00108 /* starts, and the file offset where the resource data starts. */ 00109 /* `FT_Raccess_Get_DataOffsets' requires these two data. */ 00110 /* */ 00111 /* <Input> */ 00112 /* library :: */ 00113 /* A FreeType library instance. */ 00114 /* */ 00115 /* stream :: */ 00116 /* A file stream containing the resource fork. */ 00117 /* */ 00118 /* rfork_offset :: */ 00119 /* The file offset where the resource fork starts. */ 00120 /* */ 00121 /* <Output> */ 00122 /* map_offset :: */ 00123 /* The file offset where the resource map starts. */ 00124 /* */ 00125 /* rdata_pos :: */ 00126 /* The file offset where the resource data starts. */ 00127 /* */ 00128 /* <Return> */ 00129 /* FreeType error code. FT_Err_Ok means success. */ 00130 /* */ 00131 FT_BASE( FT_Error ) 00132 FT_Raccess_Get_HeaderInfo( FT_Library library, 00133 FT_Stream stream, 00134 FT_Long rfork_offset, 00135 FT_Long *map_offset, 00136 FT_Long *rdata_pos ); 00137 00138 00139 /*************************************************************************/ 00140 /* */ 00141 /* <Function> */ 00142 /* FT_Raccess_Get_DataOffsets */ 00143 /* */ 00144 /* <Description> */ 00145 /* Get the data offsets for a tag in a resource fork. Offsets are */ 00146 /* stored in an array because, in some cases, resources in a resource */ 00147 /* fork have the same tag. */ 00148 /* */ 00149 /* <Input> */ 00150 /* library :: */ 00151 /* A FreeType library instance. */ 00152 /* */ 00153 /* stream :: */ 00154 /* A file stream containing the resource fork. */ 00155 /* */ 00156 /* map_offset :: */ 00157 /* The file offset where the resource map starts. */ 00158 /* */ 00159 /* rdata_pos :: */ 00160 /* The file offset where the resource data starts. */ 00161 /* */ 00162 /* tag :: */ 00163 /* The resource tag. */ 00164 /* */ 00165 /* <Output> */ 00166 /* offsets :: */ 00167 /* The stream offsets for the resource data specified by `tag'. */ 00168 /* This array is allocated by the function, so you have to call */ 00169 /* @ft_mem_free after use. */ 00170 /* */ 00171 /* count :: */ 00172 /* The length of offsets array. */ 00173 /* */ 00174 /* <Return> */ 00175 /* FreeType error code. FT_Err_Ok means success. */ 00176 /* */ 00177 /* <Note> */ 00178 /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */ 00179 /* value for `map_offset' and `rdata_pos'. */ 00180 /* */ 00181 FT_BASE( FT_Error ) 00182 FT_Raccess_Get_DataOffsets( FT_Library library, 00183 FT_Stream stream, 00184 FT_Long map_offset, 00185 FT_Long rdata_pos, 00186 FT_Long tag, 00187 FT_Long **offsets, 00188 FT_Long *count ); 00189 00190 00191 FT_END_HEADER 00192 00193 #endif /* __FTRFORK_H__ */ 00194 00195 00196 /* END */