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)
11 #include <ddk/ntddk.h>
22 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
23 #define TAG_FREETYPE TAG('F', 'T', 'Y', 'P')
26 * First some generic routines
30 memcpy(void *Dest
, const void *Source
, size_t Size
)
32 RtlMoveMemory(Dest
, Source
, Size
);
39 memcmp(const void *p1
, const void *p2
, size_t Size
)
45 s1
= (const char *) p1
;
46 s2
= (const char *) p2
;
47 for (i
= 0; i
< Size
; i
++)
51 return((*s1
) - (*s2
));
59 /* Hopefully we're only passed ASCII characters.... */
63 assert(0x20 <= c
&& c
<= 0x7f);
65 return (('0' <= c
&& c
<= '9') || ('a' <= c
&& c
<= 'z') || ('A' <= c
&& c
<= 'Z'));
71 return (j
< 0 ? -j
: j
);
77 * Because of realloc, we need to keep track of the size of the allocated
78 * buffer (need to copy the old contents to the new buffer). So, allocate
79 * extra space for a size_t, store the allocated size in there and return
80 * the address just past it as the allocated buffer.
88 Object
= ExAllocatePoolWithTag(PagedPool
, sizeof(size_t) + Size
, TAG_FREETYPE
);
91 *((size_t *) Object
) = Size
;
92 Object
= (void *)((size_t *) Object
+ 1);
99 realloc(void *Object
, size_t Size
)
104 NewObject
= ExAllocatePoolWithTag(PagedPool
, sizeof(size_t) + Size
, TAG_FREETYPE
);
105 if (NULL
!= NewObject
)
107 *((size_t *) NewObject
) = Size
;
108 NewObject
= (void *)((size_t *) NewObject
+ 1);
109 CopySize
= *((size_t *) Object
- 1);
114 memcpy(NewObject
, Object
, CopySize
);
115 ExFreePool((size_t *) Object
- 1);
124 ExFreePool((size_t *) Object
- 1);
130 * This is easy, we don't want FreeType to do any I/O. So return an
131 * error on each I/O attempt. Note that errno is not being set, it is
132 * not used by FreeType.
136 fopen(const char *FileName
, const char *Mode
)
138 DPRINT1("Freetype tries to open file %s\n", FileName
);
144 fseek(FILE *Stream
, long Offset
, int Origin
)
146 DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n");
154 DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n");
160 fread(void *Buffer
, size_t Size
, size_t Count
, FILE *Stream
)
162 DPRINT1("Doubleplus ungood: freetype shouldn't fread!\n");
170 DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");