ReactOS  0.4.15-dev-494-g1d8c567
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 
21 ULONG
23 {
24  va_list args;
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 
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
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
126 {
127  DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");
128  return EOF;
129 }
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:39
ENGAPI VOID APIENTRY EngDebugPrint(_In_z_ PCHAR StandardPrefix, _In_z_ PCHAR DebugMessage, _In_ va_list ap)
Definition: debug.c:19
void * malloc(size_t Size)
Definition: rosglue.c:42
size_t fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
Definition: rosglue.c:118
_In_ ULONG Mode
Definition: hubbusif.h:303
int fseek(FILE *Stream, long Offset, int Origin)
Definition: rosglue.c:104
#define EngFreeMem
Definition: polytest.cpp:56
ULONG DbgPrint(IN PCCH Format, IN ...)
Definition: rosglue.c:22
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TAG_FREETYPE
Definition: rosglue.c:15
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
CONST CHAR * PCCH
Definition: ntbasedef.h:399
FILE * fopen(const char *FileName, const char *Mode)
Definition: rosglue.c:97
static IUnknown Object
Definition: main.c:512
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
long ftell(FILE *Stream)
Definition: rosglue.c:111
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define DPRINT1
Definition: precomp.h:8
#define EOF
Definition: stdio.h:24
int fclose(FILE *Stream)
Definition: rosglue.c:125
void * realloc(void *Object, size_t Size)
Definition: rosglue.c:57
unsigned int ULONG
Definition: retypes.h:1
void free(void *Object)
Definition: rosglue.c:80
_Inout_opt_ PACCESS_STATE _In_opt_ ACCESS_MASK _In_ ULONG _Out_opt_ PVOID * NewObject
Definition: obfuncs.h:71
#define args
Definition: format.c:66
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092