Initial revision

This commit is contained in:
Werner Lemberg 2001-09-20 11:58:51 +00:00
parent 093edacc49
commit 263f61bfb1
6 changed files with 918 additions and 0 deletions

85
builds/amiga/README Normal file
View File

@ -0,0 +1,85 @@
The smakefile is a makefile for Amiga SAS/C 6.58 (no longer available,
latest sold version was 6.50, updates can be found in Aminet). It is
based on the version found in the sourcecode of ttf.library 0.83b for
FreeType 1.3.1 from Richard Griffith (ragriffi@sprynet.com,
http://ragriffi.home.sprynet.com).
You will also need the latest include files and amiga.lib from the
Amiga Developer CD V2.1 (or newer, I hope...) for AmigaOS 3.5, the
generated code should work under AmigaOS 2.04 (V37) and up.
To use it, call "smake assign" and then "smake" from the builds/amiga
directory. The results are:
- A link library "ft2_680x0.lib" (where x depends on the setting of
the CPU entry in the smakefile) containing all FreeType2 parts
except of the init code, debugging code, and the system interface
code.
- ftsystem.o, an object module containing the standard version of the
system interface code which uses fopen() fclose() fread() fseek()
ftell() malloc() realloc() and free() from lib:sc.lib (not pure).
- ftsystempure.o, an object module containing the pure version of the
system interface code which uses Open() Close() Read() Seek()
ExamineFH() AsmAllocPooled() AsmFreePooled() etc. This version can
be used in both normal programs and in Amiga run-time shared system
librarys (can be linked with lib:libinit.o, no copying of DATA and
BSS hunks for each OpenLibrary() necessary). Source code is in
src/base/ftsystem.c.
- ftdebug.o, an object module containing the standard version of the
debugging code which uses vprintf() and exit() (not pure).
Debugging can be turned on in FT:include/freetype/config/ftoption.h
and with FT_SetTraceLevel().
- ftdebugpure.o, an object module containing the pure version of the
debugging code which uses KVPrintf() from lib:debug.lib and no
exit(). For debugging of Amiga run-time shared system libraries.
Source code is in src/base/ftdebug.c.
- NO ftinit.o. Since linking with a link library should result in
linking only the needed object modules in it, but standard
ftsystem.o would force ALL FreeType2 modules to be linked to your
program, I decided to use a different scheme: You must #include
FT:src/base/ftinit.c in your sourcecode and specify with #define
statements which modules you need. See
include/freetype/config/ftmodule.h.
To use in your own programs:
- Insert the #define and #include statements from top of
include/freetype/config/ftmodule.h in your source code and uncomment
the #define statements for the FreeType2 modules you need.
- You can use either PARAMETERS=REGISTER or PARAMETERS=STACK for
calling the FreeType2 functions, since the link library and the
object files are compiled with PARAMETERS=BOTH.
- "smake assign" (assign "FT:" to the FreeType2 main directory).
- Compile your program.
- Link with either ftsystem.o or ftsystempure.o, if debugging enabled
with either ftdebug.o or (ftdebugpure.o and lib:debug.lib), and with
ft2_680x0.lib as link library.
To adopt to other compilers:
- The standard ANSI C maximum length of 31 significant characters in
identifiers is not enough for FreeType2. Check if your compiler has
a minimum length of 40 significant characters or can be switched to
it. "idlen=40" is the option for SAS/C. Setting #define
HAVE_LIMIT_ON_IDENTS in an include file may also work (not tested).
- Make sure that the include directory in builds/amiga is searched
before the normal FreeType2 include directory, so you are able to
replace problematic include files with your own version (same may be
useful for the src directory).
- An example of how to replace/workaround a problematic include file
is include/config/ftconfig.h; it changes a #define that would
prevent SAS/C from generating XDEF's where it should do that and
then includes the standard FreeType2 include file.

View File

@ -0,0 +1,11 @@
// TetiSoft: We must change FT_BASE_DEF and FT_EXPORT_DEF
//#define FT_BASE_DEF( x ) extern x // SAS/C wouldn't generate an XDEF
//#define FT_EXPORT_DEF( x ) extern x // SAS/C wouldn't generate an XDEF
#undef FT_BASE_DEF
#define FT_BASE_DEF( x ) x
#undef FT_EXPORT_DEF
#define FT_EXPORT_DEF( x ) x
// TetiSoft: now include original file
#include "FT:include/freetype/config/ftconfig.h"

View File

@ -0,0 +1,91 @@
// TetiSoft: To specify which modules you need,
// insert the following in your source file and uncomment as needed:
/*
//#define FT_USE_AUTOHINT // autohinter
//#define FT_USE_RASTER // monochrome rasterizer
//#define FT_USE_SMOOTH // anti-aliasing rasterizer
//#define FT_USE_TT // truetype font driver
//#define FT_USE_T1 // type1 font driver
//#define FT_USE_T1CID // cid-keyed type1 font driver // no cmap support, useless
//#define FT_USE_CFF // opentype font driver // does not work with TektonPro
//#define FT_USE_PCF // pcf bitmap font driver // all tested fonts 12*12 (size unknown)
//#define FT_USE_WINFNT // windows .fnt|.fon bitmap font driver
#include "FT:src/base/ftinit.c"
*/
// TetiSoft: make sure that needed support modules are built in
#ifdef FT_USE_TT
#define FT_USE_SFNT
#endif
#ifdef FT_USE_CFF
#define FT_USE_SFNT
#endif
#ifdef FT_USE_T1
#define FT_USE_PSAUX
#endif
#ifdef FT_USE_T1CID
#define FT_USE_PSAUX
#endif
#ifdef FT_USE_PSAUX
#define FT_USE_PSNAMES
#endif
#ifdef FT_USE_SFNT
#define FT_USE_PSNAMES
#endif
// TetiSoft: Now include the modules
#ifdef FT_USE_AUTOHINT
FT_USE_MODULE(autohint_module_class)
#endif
#ifdef FT_USE_CFF
FT_USE_MODULE(cff_driver_class)
#endif
#ifdef FT_USE_T1CID
FT_USE_MODULE(t1cid_driver_class)
#endif
#ifdef FT_USE_PCF
FT_USE_MODULE(pcf_driver_class)
#endif
#ifdef FT_USE_PSAUX
FT_USE_MODULE(psaux_module_class)
#endif
#ifdef FT_USE_PSNAMES
FT_USE_MODULE(psnames_module_class)
#endif
#ifdef FT_USE_RASTER
FT_USE_MODULE(ft_raster1_renderer_class)
#endif
#ifdef FT_USE_SFNT
FT_USE_MODULE(sfnt_module_class)
#endif
#ifdef FT_USE_SMOOTH
FT_USE_MODULE(ft_smooth_renderer_class)
#endif
#ifdef FT_USE_TT
FT_USE_MODULE(tt_driver_class)
#endif
#ifdef FT_USE_T1
FT_USE_MODULE(t1_driver_class)
#endif
#ifdef FT_USE_WINFNT
FT_USE_MODULE(winfnt_driver_class)
#endif

219
builds/amiga/smakefile Normal file
View File

@ -0,0 +1,219 @@
#
# Makefile for FreeType2 link library using Amiga SAS/C 6.58
#
# to build from the builds/amiga directory call
#
# smake assign
# smake
#
# Your programs source code should start with this
# (uncomment the parts you do not need to keep the program small):
# ---8<---
#define FT_USE_AUTOHINT // autohinter
#define FT_USE_RASTER // monochrome rasterizer
#define FT_USE_SMOOTH // anti-aliasing rasterizer
#define FT_USE_TT // truetype font driver
#define FT_USE_T1 // type1 font driver
#define FT_USE_T1CID // cid-keyed type1 font driver
#define FT_USE_CFF // opentype font driver
#define FT_USE_PCF // pcf bitmap font driver
#define FT_USE_WINFNT // windows .fnt|.fon bitmap font driver
#include "FT:src/base/ftinit.c"
# ---8<---
#
# link your programs with ft2_680x0.lib and either ftsystem.o or ftsystempure.o
# (and either ftdebug.o or ftdebugpure.o if you enabled FT_DEBUG_LEVEL_ERROR or
# FT_DEBUG_LEVEL_TRACE in include/freetype/config/ftoption.h).
OBJBASE = ftbase.o ftglyph.o ftbbox.o ftmm.o ftsynth.o
OBJSYSTEM = ftsystem.o ftsystempure.o
OBJDEBUG = ftdebug.o ftdebugpure.o
OBJAHINT = autohint.o ahoptim.o
OBJPSAUX = psaux.o
OBJPSNAM = psnames.o
OBJRAST = raster.o
OBJSMOOTH = smooth.o
OBJSFNT = sfnt.o
OBJCACHE = ftcache.o
OBJOT = cff.o
OBJT1 = type1.o
OBJT1C = type1cid.o
OBJTT = truetype.o
OBJWINFNT = winfnt.o
OBJPCF = pcf.o
OBJPS = $(OBJPSAUX) $(OBJPSNAM)
OBJRASTER = $(OBJRAST) $(OBJSMOOTH)
OBJFONTD = $(OBJOT) $(OBJT1) $(OBJT1C) $(OBJTT) $(OBJWINFNT) $(OBJPCF)
CORE = FT:src/
CPU = 68000
#CPU = 68020
#CPU = 68030
#CPU = 68040
#CPU = 68060
OPTIMIZER = optinlocal
SCFLAGS = optimize opttime optsched strmerge strsect=near idlen=40 cpu=$(CPU)\
idir=include/ idir=$(CORE) idir=FT:include/ nostackcheck nochkabort\
noicons ignore=79,85,110,306 parameters=both
LIB = ft2_$(CPU).lib
# sample linker options
OPTS = link lib=$(LIB),lib:sc.lib,lib:amiga.lib,lib:debug.lib\
smallcode smalldata noicons utillib
# sample program entry
#myprog: myprog.c ftsystem.o $(LIB)
# sc $< programname=$@ ftsystem.o $(SCFLAGS) $(OPTS)
all: $(LIB) $(OBJSYSTEM) $(OBJDEBUG)
assign:
assign FT: //
# uses separate object modules in lib to make for easier debugging
# also, can make smaller programs if entire engine is not used
ft2_$(CPU).lib: $(OBJBASE) $(OBJAHINT) $(OBJPS) $(OBJRASTER) $(OBJSFNT) $(OBJCACHE) $(OBJFONTD)
oml $@ r $(OBJBASE) $(OBJAHINT) $(OBJPS) $(OBJRASTER) $(OBJSFNT) $(OBJCACHE) $(OBJFONTD)
clean:
-delete \#?.o
realclean: clean
-delete ft2$(CPU).lib
#
# freetype library base
#
ftbase.o: $(CORE)base/ftbase.c
sc $(SCFLAGS) objname=$@ $<
ftinit.o: $(CORE)base/ftinit.c
sc $(SCFLAGS) objname=$@ $<
ftsystem.o: $(CORE)base/ftsystem.c
sc $(SCFLAGS) objname=$@ $<
ftsystempure.o: src/base/ftsystem.c ## pure version for use in run-time library etc
sc $(SCFLAGS) objname=$@ $<
ftdebug.o: $(CORE)base/ftdebug.c
sc $(SCFLAGS) objname=$@ $<
ftdebugpure.o: src/base/ftdebug.c ## pure version for use in run-time library etc
sc $(SCFLAGS) objname=$@ $<
#
# freetype library base extensions
#
ftglyph.o: $(CORE)base/ftglyph.c
sc $(SCFLAGS) objname=$@ $<
ftbbox.o: $(CORE)base/ftbbox.c
sc $(SCFLAGS) objname=$@ $<
ftmm.o: $(CORE)base/ftmm.c
sc $(SCFLAGS) objname=$@ $<
ftsynth.o: $(CORE)base/ftsynth.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library autohinting module
#
autohint.o: $(CORE)autohint/autohint.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library autohinting module extensions
#
ahoptim.o: $(CORE)autohint/ahoptim.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library PS support module
#
psaux.o: $(CORE)psaux/psaux.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library PS glyph names module
#
psnames.o: $(CORE)psnames/psnames.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library monochrome raster module
#
raster.o: $(CORE)raster/raster.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library anti-aliasing raster module
#
smooth.o: $(CORE)smooth/smooth.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library 'sfnt' module
#
sfnt.o: $(CORE)sfnt/sfnt.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library glyph and image caching system (still experimental)
#
ftcache.o: $(CORE)cache/ftcache.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library OpenType font driver
#
cff.o: $(CORE)cff/cff.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library TrueType font driver
#
truetype.o: $(CORE)truetype/truetype.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library Type1 font driver
#
type1.o: $(CORE)type1/type1.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library CID-keyed Type1 font driver
#
type1cid.o: $(CORE)cid/type1cid.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library CID-keyed Type1 font driver extensions
#
#cidafm.o: $(CORE)cid/cidafm.c
# sc $(SCFLAGS) objname=$@ $<
#
# freetype library Windows FNT/FON bitmap font driver
#
winfnt.o: $(CORE)winfonts/winfnt.c
sc $(SCFLAGS) objname=$@ $<
#
# freetype library PCF bitmap font driver
#
pcf.o: $(CORE)pcf/pcf.c
sc $(SCFLAGS) objname=$@ $<

View File

@ -0,0 +1,123 @@
// TetiSoft: replaced vprintf() with KVPrintF() and commented out exit()
extern void __stdargs KVPrintF( const char *formatString, const void *values );
/***************************************************************************/
/* */
/* ftdebug.c */
/* */
/* Debugging and logging component (body). */
/* */
/* Copyright 1996-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This component contains various macros and functions used to ease the */
/* debugging of the FreeType engine. Its main purpose is in assertion */
/* checking, tracing, and error detection. */
/* */
/* There are now three debugging modes: */
/* */
/* - trace mode */
/* */
/* Error and trace messages are sent to the log file (which can be the */
/* standard error output). */
/* */
/* - error mode */
/* */
/* Only error messages are generated. */
/* */
/* - release mode: */
/* */
/* No error message is sent or generated. The code is free from any */
/* debugging parts. */
/* */
/*************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#ifdef FT_DEBUG_LEVEL_TRACE
char ft_trace_levels[trace_max];
#endif
#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
FT_EXPORT_DEF( void )
FT_Message( const char* fmt, ... )
{
va_list ap;
va_start( ap, fmt );
// vprintf( fmt, ap );
KVPrintF( fmt, ap );
va_end( ap );
}
FT_EXPORT_DEF( void )
FT_Panic( const char* fmt, ... )
{
va_list ap;
va_start( ap, fmt );
// vprintf( fmt, ap );
KVPrintF( fmt, ap );
va_end( ap );
// exit( EXIT_FAILURE );
}
#ifdef FT_DEBUG_LEVEL_TRACE
FT_EXPORT_DEF( void )
FT_SetTraceLevel( FT_Trace component,
char level )
{
if ( component >= trace_max )
return;
/* if component is `trace_any', change _all_ levels at once */
if ( component == trace_any )
{
int n;
for ( n = trace_any; n < trace_max; n++ )
ft_trace_levels[n] = level;
}
else /* otherwise, only change individual component */
ft_trace_levels[component] = level;
}
#endif /* FT_DEBUG_LEVEL_TRACE */
#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
/* ANSI C doesn't allow empty files, so we insert a dummy symbol */
extern const int ft_debug_dummy;
/* END */

View File

@ -0,0 +1,389 @@
// TetiSoft: Modified to avoid fopen() fclose() fread() fseek() ftell()
// malloc() realloc() and free() which can't be used in an amiga
// shared run-time library linked with libinit.o
#include <proto/exec.h>
#include <proto/dos.h>
/* TetiSoft: Missing in alib_protos.h, see amiga.lib autodoc
* (These amiga.lib functions work under AmigaOS V33 and up)
*/
extern APTR __asm AsmCreatePool(register __d0 ULONG memFlags,
register __d1 ULONG puddleSize,
register __d2 ULONG threshSize,
register __a6 struct ExecBase *SysBase);
extern VOID __asm AsmDeletePool(register __a0 APTR poolHeader,
register __a6 struct ExecBase *SysBase);
extern APTR __asm AsmAllocPooled(register __a0 APTR poolHeader,
register __d0 ULONG memSize,
register __a6 struct ExecBase *SysBase);
extern VOID __asm AsmFreePooled(register __a0 APTR poolHeader,
register __a1 APTR memory,
register __d0 ULONG memSize,
register __a6 struct ExecBase *SysBase);
// TetiSoft: C implementation of AllocVecPooled (see autodoc exec/AllocPooled)
APTR AllocVecPooled(APTR poolHeader, ULONG memSize)
{
ULONG newSize = memSize + 4;
ULONG *mem = AsmAllocPooled(poolHeader, newSize, SysBase);
if (!mem)
return NULL;
*mem = newSize;
return mem + 1;
}
// TetiSoft: C implementation of FreeVecPooled (see autodoc exec/AllocPooled)
void FreeVecPooled(APTR poolHeader, APTR memory)
{
ULONG *realmem = (ULONG *)memory - 1;
AsmFreePooled(poolHeader, realmem, *realmem, SysBase);
}
/***************************************************************************/
/* */
/* ftsystem.c */
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
/* Copyright 1996-2001 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file contains the default interface used by FreeType to access */
/* low-level, i.e. memory management, i/o access as well as thread */
/* synchronisation. It can be replaced by user-specific routines if */
/* necessary. */
/* */
/*************************************************************************/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_DEBUG_H
#include FT_SYSTEM_H
#include FT_ERRORS_H
#include FT_TYPES_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*************************************************************************/
/* */
/* MEMORY MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* It is not necessary to do any error checking for the */
/* allocation-related functions. This will be done by the higher level */
/* routines like FT_Alloc() or FT_Realloc(). */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* ft_alloc */
/* */
/* <Description> */
/* The memory allocation function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* size :: The requested size in bytes. */
/* */
/* <Return> */
/* The address of newly allocated block. */
/* */
FT_CALLBACK_DEF( void* )
ft_alloc( FT_Memory memory,
long size )
{
// FT_UNUSED( memory );
// return malloc( size );
return AllocVecPooled( memory->user, size );
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_realloc */
/* */
/* <Description> */
/* The memory reallocation function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* cur_size :: The current size of the allocated memory block. */
/* */
/* new_size :: The newly requested size in bytes. */
/* */
/* block :: The current address of the block in memory. */
/* */
/* <Return> */
/* The address of the reallocated memory block. */
/* */
FT_CALLBACK_DEF( void* )
ft_realloc( FT_Memory memory,
long cur_size,
long new_size,
void* block )
{
// FT_UNUSED( memory );
// FT_UNUSED( cur_size );
// return realloc( block, new_size );
void* new_block;
new_block = AllocVecPooled ( memory->user, new_size );
if ( new_block != NULL )
{
CopyMem ( block, new_block,
( new_size > cur_size ) ? cur_size : new_size );
FreeVecPooled ( memory->user, block );
}
return new_block;
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_free */
/* */
/* <Description> */
/* The memory release function. */
/* */
/* <Input> */
/* memory :: A pointer to the memory object. */
/* */
/* block :: The address of block in memory to be freed. */
/* */
FT_CALLBACK_DEF( void )
ft_free( FT_Memory memory,
void* block )
{
// FT_UNUSED( memory );
// free( block );
FreeVecPooled( memory->user, block );
}
/*************************************************************************/
/* */
/* RESOURCE MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
/* messages during execution. */
/* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_io
/* We use the macro STREAM_FILE for convenience to extract the */
/* system-specific stream handle from a given FreeType stream object */
//#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer )
#define STREAM_FILE( stream ) ( (BPTR)stream->descriptor.pointer ) // TetiSoft
/*************************************************************************/
/* */
/* <Function> */
/* ft_close_stream */
/* */
/* <Description> */
/* The function to close a stream. */
/* */
/* <Input> */
/* stream :: A pointer to the stream object. */
/* */
FT_CALLBACK_DEF( void )
ft_close_stream( FT_Stream stream )
{
// fclose( STREAM_FILE( stream ) );
Close( STREAM_FILE( stream ) ); // TetiSoft
stream->descriptor.pointer = NULL;
stream->size = 0;
stream->base = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_io_stream */
/* */
/* <Description> */
/* The function to open a stream. */
/* */
/* <Input> */
/* stream :: A pointer to the stream object. */
/* */
/* offset :: The position in the data stream to start reading. */
/* */
/* buffer :: The address of buffer to store the read data. */
/* */
/* count :: The number of bytes to read from the stream. */
/* */
/* <Return> */
/* The number of bytes actually read. */
/* */
FT_CALLBACK_DEF( unsigned long )
ft_io_stream( FT_Stream stream,
unsigned long offset,
unsigned char* buffer,
unsigned long count )
{
// FILE* file;
BPTR file; // TetiSoft
file = STREAM_FILE( stream );
// fseek( file, offset, SEEK_SET );
Seek( file, offset, OFFSET_BEGINNING ); // TetiSoft
// return (unsigned long)fread( buffer, 1, count, file );
return (unsigned long)FRead( file, buffer, 1, count);
}
/* documentation is in ftobjs.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Stream( const char* filepathname,
FT_Stream astream )
{
// FILE* file;
BPTR file; // TetiSoft
struct FileInfoBlock *fib; // TetiSoft
if ( !astream )
return FT_Err_Invalid_Stream_Handle;
// file = fopen( filepathname, "rb" );
file = Open( filepathname, MODE_OLDFILE ); // TetiSoft
if ( !file )
{
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource;
}
// fseek( file, 0, SEEK_END );
// astream->size = ftell( file );
// fseek( file, 0, SEEK_SET );
fib = AllocDosObject( DOS_FIB, NULL );
if ( !fib )
{
Close ( file );
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource;
}
if (!( ExamineFH ( file, fib )))
{
FreeDosObject(DOS_FIB, fib);
Close ( file );
FT_ERROR(( "FT_New_Stream:" ));
FT_ERROR(( " could not open `%s'\n", filepathname ));
return FT_Err_Cannot_Open_Resource;
}
astream->size = fib->fib_Size;
FreeDosObject(DOS_FIB, fib);
// astream->descriptor.pointer = file;
astream->descriptor.pointer = (void *)file;
astream->pathname.pointer = (char*)filepathname;
astream->pos = 0;
astream->read = ft_io_stream;
astream->close = ft_close_stream;
FT_TRACE1(( "FT_New_Stream:" ));
FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
filepathname, astream->size ));
return FT_Err_Ok;
}
/* documentation is in ftobjs.h */
FT_EXPORT_DEF( FT_Memory )
FT_New_Memory( void )
{
FT_Memory memory;
// memory = (FT_Memory)malloc( sizeof ( *memory ) );
memory = (FT_Memory)AllocVec( sizeof ( *memory ), MEMF_PUBLIC );
if ( memory )
{
// memory->user = 0;
memory->user = AsmCreatePool ( MEMF_PUBLIC, 2048, 2048, SysBase );
memory->alloc = ft_alloc;
memory->realloc = ft_realloc;
memory->free = ft_free;
if ( memory->user == NULL )
{
FreeVec ( memory );
memory = NULL;
}
}
return memory;
}
/* documentation is in ftobjs.h */
FT_EXPORT_DEF( void )
FT_Done_Memory( FT_Memory memory )
{
// memory->free( memory, memory );
AsmDeletePool( memory->user, SysBase );
FreeVec( memory );
}
/* END */