45 #define __NOGLOBALIFACE__ 46 #define __USE_INLINE__ 47 #include <proto/exec.h> 48 #include <dos/stdio.h> 49 #include <proto/dos.h> 51 extern struct ExecIFace *IExec;
52 extern struct DOSIFace *IDOS;
58 #define IOBUF_SIZE 512 77 ULONG newSize = memSize +
sizeof ( ULONG );
78 ULONG *mem = AllocPooled( poolHeader, newSize );
91 ULONG *realmem = (ULONG *)memory - 1;
93 FreePooled( poolHeader, realmem, *realmem );
98 #include FT_CONFIG_CONFIG_H 99 #include FT_INTERNAL_DEBUG_H 145 return AllocVecPooled( memory->user,
size );
181 new_block = AllocVecPooled ( memory->user, new_size );
185 if ( new_block !=
NULL )
187 CopyMem ( block, new_block,
188 ( new_size > cur_size ) ? cur_size : new_size );
190 FreeVecPooled ( memory->user, block );
217 FreeVecPooled( memory->user, block );
238 #define FT_COMPONENT trace_io 242 #define STREAM_FILE( stream ) ( (struct SysFile *)stream->descriptor.pointer ) 259 struct SysFile* sysfile;
262 Close ( sysfile->file );
263 FreeMem ( sysfile,
sizeof (
struct SysFile ));
265 stream->descriptor.pointer =
NULL;
295 unsigned long count )
297 struct SysFile* sysfile;
298 unsigned long read_bytes;
308 if ( !sysfile->iobuf_end ||
offset != sysfile->iobuf_end )
311 Seek( sysfile->file,
offset, OFFSET_BEGINNING );
313 sysfile->iobuf_start =
offset;
314 sysfile->iobuf_end = 0;
330 read_bytes = Read( sysfile->file, sysfile->iobuf,
IOBUF_SIZE );
331 if ( read_bytes == -1UL )
338 sysfile->iobuf_end =
offset + read_bytes;
340 if ( read_bytes >
count )
352 if ( read_bytes == -1UL )
362 sysfile->iobuf_end =
offset + read_bytes;
363 sysfile->iobuf_start = sysfile->iobuf_end -
bufsize;
364 CopyMem( &
buffer[read_bytes - bufsize] , sysfile->iobuf, bufsize );
382 const char* filepathname )
384 struct FileInfoBlock* fib;
385 struct SysFile* sysfile;
389 return FT_Err_Invalid_Stream_Handle;
392 sysfile = AllocMem (
sizeof (
struct SysFile ), MEMF_SHARED );
394 sysfile = AllocMem (
sizeof (
struct SysFile ), MEMF_PUBLIC );
399 FT_ERROR((
" could not open `%s'\n", filepathname ));
401 return FT_Err_Cannot_Open_Resource;
403 sysfile->file = Open( (STRPTR)filepathname, MODE_OLDFILE );
404 if ( !sysfile->file )
406 FreeMem ( sysfile,
sizeof (
struct SysFile ));
408 FT_ERROR((
" could not open `%s'\n", filepathname ));
410 return FT_Err_Cannot_Open_Resource;
413 fib = AllocDosObject( DOS_FIB,
NULL );
416 Close ( sysfile->file );
417 FreeMem ( sysfile,
sizeof (
struct SysFile ));
419 FT_ERROR((
" could not open `%s'\n", filepathname ));
421 return FT_Err_Cannot_Open_Resource;
423 if ( !( ExamineFH( sysfile->file, fib ) ) )
425 FreeDosObject( DOS_FIB, fib );
426 Close ( sysfile->file );
427 FreeMem ( sysfile,
sizeof (
struct SysFile ));
429 FT_ERROR((
" could not open `%s'\n", filepathname ));
431 return FT_Err_Cannot_Open_Resource;
433 stream->size = fib->fib_Size;
434 FreeDosObject( DOS_FIB, fib );
436 stream->descriptor.pointer = (
void *)sysfile;
437 stream->pathname.pointer = (
char*)filepathname;
438 sysfile->iobuf_start = 0;
439 sysfile->iobuf_end = 0;
449 FT_ERROR((
" opened `%s' but zero-sized\n", filepathname ));
450 return FT_Err_Cannot_Open_Stream;;
454 FT_TRACE1((
" opened `%s' (%ld bytes) successfully\n",
455 filepathname,
stream->size ));
461 #ifdef FT_DEBUG_MEMORY 481 memory = (
FT_Memory)AllocVec(
sizeof ( *memory ), MEMF_SHARED );
483 memory = (
FT_Memory)AllocVec(
sizeof ( *memory ), MEMF_PUBLIC );
488 memory->user = CreatePool( MEMF_SHARED, 16384, 16384 );
490 memory->user = CreatePool( MEMF_PUBLIC, 16384, 16384 );
492 if ( memory->user ==
NULL )
502 #ifdef FT_DEBUG_MEMORY 503 ft_mem_debug_init( memory );
517 #ifdef FT_DEBUG_MEMORY 518 ft_mem_debug_done( memory );
521 DeletePool( memory->user );
GLenum GLuint GLsizei bufsize
ft_amiga_stream_close(FT_Stream stream)
#define FT_TRACE1(varformat)
#define FT_ERROR(varformat)
FT_Stream_Open(FT_Stream stream, const char *filepathname)
void Free_VecPooled(APTR poolHeader, APTR memory)
#define FT_CALLBACK_DEF(x)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
ft_free(FT_Memory memory, void *block)
ft_amiga_stream_io(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count)
APTR Alloc_VecPooled(APTR poolHeader, ULONG memSize)
GLuint GLuint GLsizei count
ft_alloc(FT_Memory memory, long size)
FT_Done_Memory(FT_Memory memory)
#define STREAM_FILE(stream)
ft_realloc(FT_Memory memory, long cur_size, long new_size, void *block)