[SHELLBTRFS] Add a PCH.
[reactos.git] / win32ss / drivers / font / ftfd / rosglue.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: FreeType implementation for ReactOS
4 * PURPOSE: Glue functions between FreeType
5 * FILE: win32ss/drivers/font/ftfd/rosglue.c
6 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
7 * NOTES:
8 */
9
10 #include "ftfd.h"
11
12 #define NDEBUG
13 #include <debug.h>
14
15 #define TAG_FREETYPE 'PYTF'
16
17 /*
18 * First some generic routines
19 */
20
21 ULONG
22 DbgPrint(IN PCCH Format, IN ...)
23 {
24 va_list args;
25
26 va_start(args, Format);
27 EngDebugPrint("ft2: ", (PCHAR)Format, args);
28 va_end(args);
29 return 0;
30 }
31
32 /*
33 * Memory allocation
34 *
35 * Because of realloc, we need to keep track of the size of the allocated
36 * buffer (need to copy the old contents to the new buffer). So, allocate
37 * extra space for a size_t, store the allocated size in there and return
38 * the address just past it as the allocated buffer.
39 */
40
41 void *
42 malloc(size_t Size)
43 {
44 void *Object;
45
46 Object = EngAllocMem(0, sizeof(size_t) + Size, TAG_FREETYPE);
47 if (Object != NULL)
48 {
49 *((size_t *)Object) = Size;
50 Object = (void *)((size_t *)Object + 1);
51 }
52
53 return Object;
54 }
55
56 void *
57 realloc(void *Object, size_t Size)
58 {
59 void *NewObject;
60 size_t CopySize;
61
62 NewObject = EngAllocMem(0, sizeof(size_t) + Size, TAG_FREETYPE);
63 if (NewObject != NULL)
64 {
65 *((size_t *)NewObject) = Size;
66 NewObject = (void *)((size_t *)NewObject + 1);
67 CopySize = *((size_t *)Object - 1);
68 if (Size < CopySize)
69 {
70 CopySize = Size;
71 }
72 memcpy(NewObject, Object, CopySize);
73 EngFreeMem((size_t *)Object - 1);
74 }
75
76 return NewObject;
77 }
78
79 void
80 free(void *Object)
81 {
82 if (Object != NULL)
83 {
84 EngFreeMem((size_t *)Object - 1);
85 }
86 }
87
88 /*
89 * File I/O
90 *
91 * This is easy, we don't want FreeType to do any I/O. So return an
92 * error on each I/O attempt. Note that errno is not being set, it is
93 * not used by FreeType.
94 */
95
96 FILE *
97 fopen(const char *FileName, const char *Mode)
98 {
99 DPRINT1("Freetype tries to open file %s\n", FileName);
100 return NULL;
101 }
102
103 int
104 fseek(FILE *Stream, long Offset, int Origin)
105 {
106 DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n");
107 return -1;
108 }
109
110 long
111 ftell(FILE *Stream)
112 {
113 DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n");
114 return -1;
115 }
116
117 size_t
118 fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
119 {
120 DPRINT1("Doubleplus ungood: freetype shouldn't fread!\n");
121 return 0;
122 }
123
124 int
125 fclose(FILE *Stream)
126 {
127 DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");
128 return EOF;
129 }