3 * COPYRIGHT: See COPYING in the top level directory
\r
4 * PROJECT: FreeType implementation for ReactOS
\r
5 * PURPOSE: Glue functions between FreeType
\r
6 * FILE: thirdparty/freetype/rosglue.c
\r
7 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
\r
11 #include <ddk/ntddk.h>
22 #define TAG_FREETYPE TAG('F', 'T', 'Y', 'P')
25 * First some generic routines
29 memcpy(void *Dest, const void *Source, size_t Size)
31 RtlMoveMemory(Dest, Source, Size);
38 memcmp(const void *p1, const void *p2, size_t Size)
44 s1 = (const char *) p1;
45 s2 = (const char *) p2;
46 for (i = 0; i < Size; i++)
50 return((*s1) - (*s2));
58 /* Hopefully we're only passed ASCII characters.... */
62 assert(0x20 <= c && c <= 0x7f);
64 return (('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'));
70 return (j < 0 ? -j : j);
76 * Because of realloc, we need to keep track of the size of the allocated
77 * buffer (need to copy the old contents to the new buffer). So, allocate
78 * extra space for a size_t, store the allocated size in there and return
79 * the address just past it as the allocated buffer.
87 Object = ExAllocatePoolWithTag(NonPagedPool, sizeof(size_t) + Size, TAG_FREETYPE);
90 *((size_t *) Object) = Size;
91 Object = (void *)((size_t *) Object + 1);
98 realloc(void *Object, size_t Size)
103 NewObject = ExAllocatePoolWithTag(NonPagedPool, sizeof(size_t) + Size, TAG_FREETYPE);
104 if (NULL != NewObject)
106 *((size_t *) NewObject) = Size;
107 NewObject = (void *)((size_t *) NewObject + 1);
108 CopySize = *((size_t *) Object - 1);
113 memcpy(NewObject, Object, CopySize);
114 ExFreePool((size_t *) Object - 1);
123 ExFreePool((size_t *) Object - 1);
129 * This is easy, we don't want FreeType to do any I/O. So return an
130 * error on each I/O attempt. Note that errno is not being set, it is
131 * not used by FreeType.
135 fopen(const char *FileName, const char *Mode)
137 DPRINT1("Freetype tries to open file %s\n", FileName);
143 fseek(FILE *Stream, long Offset, int Origin)
145 DPRINT1("Doubleplus ungood: freetype shouldn't fseek!\n");
153 DPRINT1("Doubleplus ungood: freetype shouldn't ftell!\n");
159 fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
161 DPRINT1("Doubleplus ungood: freetype shouldn't fread!\n");
169 DPRINT1("Doubleplus ungood: freetype shouldn't fclose!\n");