[FTFD] Fix indentation
[reactos.git] / reactos / 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 EngFreeMem((size_t *)Object - 1);
83 }
84
85 /*
86 * File I/O
87 *
88 * This is easy, we don't want FreeType to do any I/O. So return an
89 * error on each I/O attempt. Note that errno is not being set, it is
90 * not used by FreeType.
91 */
92
93 FILE *
94 fopen(const char *FileName, const char *Mode)
95 {
96 DPRINT1("Freetype tries to open file %s\n", FileName);
97 return NULL;
98 }
99
100 int
101 fseek(FILE *Stream, long Offset, int Origin)
102 {
103 DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n");
104 return -1;
105 }
106
107 long
108 ftell(FILE *Stream)
109 {
110 DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n");
111 return -1;
112 }
113
114 size_t
115 fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
116 {
117 DPRINT1("Doubleplus ungood: freetype shouldn't fread!\n");
118 return 0;
119 }
120
121 int
122 fclose(FILE *Stream)
123 {
124 DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");
125 return EOF;
126 }