- Check that all pins have been closed when the last filter reference is gone
[reactos.git] / reactos / 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 <stdarg.h>
12 #include <stdio.h>
13 #include <windef.h>
14 #include <wingdi.h>
15 #include <winddi.h>
16
17 #define NDEBUG
18 #include <debug.h>
19
20 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
21 #define TAG_FREETYPE TAG('F', 'T', 'Y', 'P')
22
23 /*
24 * First some generic routines
25 */
26
27 ULONG
28 DbgPrint(IN PCCH Format, IN ...)
29 {
30 va_list args;
31
32 va_start(args, Format);
33 EngDebugPrint("ft2: ", (PCHAR)Format, args);
34 va_end(args);
35 return 0;
36 }
37
38 /*
39 * Memory allocation
40 *
41 * Because of realloc, we need to keep track of the size of the allocated
42 * buffer (need to copy the old contents to the new buffer). So, allocate
43 * extra space for a size_t, store the allocated size in there and return
44 * the address just past it as the allocated buffer.
45 */
46
47 void *
48 malloc(size_t Size)
49 {
50 void *Object;
51
52 Object = EngAllocMem(0, sizeof(size_t) + Size, TAG_FREETYPE);
53 if (NULL != Object)
54 {
55 *((size_t *) Object) = Size;
56 Object = (void *)((size_t *) Object + 1);
57 }
58
59 return Object;
60 }
61
62 void *
63 realloc(void *Object, size_t Size)
64 {
65 void *NewObject;
66 size_t CopySize;
67
68 NewObject = EngAllocMem(0, sizeof(size_t) + Size, TAG_FREETYPE);
69 if (NULL != NewObject)
70 {
71 *((size_t *) NewObject) = Size;
72 NewObject = (void *)((size_t *) NewObject + 1);
73 CopySize = *((size_t *) Object - 1);
74 if (Size < CopySize)
75 {
76 CopySize = Size;
77 }
78 memcpy(NewObject, Object, CopySize);
79 EngFreeMem((size_t *) Object - 1);
80 }
81
82 return NewObject;
83 }
84
85 void
86 free(void *Object)
87 {
88 EngFreeMem((size_t *) Object - 1);
89 }
90
91 /*
92 * File I/O
93 *
94 * This is easy, we don't want FreeType to do any I/O. So return an
95 * error on each I/O attempt. Note that errno is not being set, it is
96 * not used by FreeType.
97 */
98
99 FILE *
100 fopen(const char *FileName, const char *Mode)
101 {
102 DPRINT1("Freetype tries to open file %s\n", FileName);
103
104 return NULL;
105 }
106
107 int
108 fseek(FILE *Stream, long Offset, int Origin)
109 {
110 DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n");
111
112 return -1;
113 }
114
115 long
116 ftell(FILE *Stream)
117 {
118 DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n");
119
120 return -1;
121 }
122
123 size_t
124 fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
125 {
126 DPRINT1("Doubleplus ungood: freetype shouldn't fread!\n");
127
128 return 0;
129 }
130
131 int
132 fclose(FILE *Stream)
133 {
134 DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");
135
136 return EOF;
137 }