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