ReactOS 0.4.15-dev-8119-g4fb2fdb
rosglue.c
Go to the documentation of this file.
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
23{
25
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
41void *
42malloc(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
56void *
57realloc(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
79void
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
96FILE *
97fopen(const char *FileName, const char *Mode)
98{
99 DPRINT1("Freetype tries to open file %s\n", FileName);
100 return NULL;
101}
102
103int
104fseek(FILE *Stream, long Offset, int Origin)
105{
106 DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n");
107 return -1;
108}
109
110long
112{
113 DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n");
114 return -1;
115}
116
117size_t
118fread(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
124int
126{
127 DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");
128 return EOF;
129}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
long ftell(FILE *Stream)
Definition: rosglue.c:111
#define TAG_FREETYPE
Definition: rosglue.c:15
FILE * fopen(const char *FileName, const char *Mode)
Definition: rosglue.c:97
int fseek(FILE *Stream, long Offset, int Origin)
Definition: rosglue.c:104
int fclose(FILE *Stream)
Definition: rosglue.c:125
size_t fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
Definition: rosglue.c:118
#define DbgPrint
Definition: hal.h:12
_In_ ULONG Mode
Definition: hubbusif.h:303
#define EOF
Definition: stdio.h:24
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static IStream Stream
Definition: htmldoc.c:1115
int Count
Definition: noreturn.cpp:7
CONST CHAR * PCCH
Definition: ntbasedef.h:392
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define EngFreeMem
Definition: polytest.cpp:56
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define args
Definition: format.c:66
Definition: match.c:390
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
ENGAPI VOID APIENTRY EngDebugPrint(_In_z_ PCHAR StandardPrefix, _In_z_ PCHAR DebugMessage, _In_ va_list ap)
Definition: debug.c:19
_Inout_opt_ PACCESS_STATE _In_opt_ ACCESS_MASK _In_ ULONG _Out_opt_ PVOID * NewObject
Definition: obfuncs.h:74