* @brief Reads and parses an include file into a buffer * * @param IncludeFile the path to the include file * @param Buffer pointer to receive the allocated file content buffer * @return BOOLEAN TRUE if the file was parsed successfully, FALSE otherwise */
| 170 | * @return BOOLEAN TRUE if the file was parsed successfully, FALSE otherwise |
| 171 | */ |
| 172 | BOOLEAN |
| 173 | ParseIncludeFile(char * IncludeFile, char ** Buffer) |
| 174 | { |
| 175 | FILE * Fp = fopen(IncludeFile, "r"); |
| 176 | fseek(Fp, 0, SEEK_END); |
| 177 | LONG Size = ftell(Fp); |
| 178 | rewind(Fp); |
| 179 | *Buffer = calloc(Size + 1, 1); |
| 180 | fread(*Buffer, 1, Size, Fp); |
| 181 | (*Buffer)[Size] = '\0'; |
| 182 | Trim(*Buffer); |
| 183 | SIZE_T Len = strlen(*Buffer); |
| 184 | if ((*Buffer)[0] == '?' && |
| 185 | (*Buffer)[1] == ' ' && |
| 186 | (*Buffer)[2] == '{' && |
| 187 | (*Buffer)[Len - 1] == '}') |
| 188 | { |
| 189 | memmove( |
| 190 | *Buffer, |
| 191 | *Buffer + 3, |
| 192 | Len - 3 + 1); |
| 193 | |
| 194 | (*Buffer)[strlen(*Buffer) - 1] = '\0'; |
| 195 | |
| 196 | return TRUE; |
| 197 | } |
| 198 | return FALSE; |
| 199 | } |