memfile.h File Reference

#include "globals.h"

Go to the source code of this file.

Data Structures

struct  MEMORY_FILE

Defines

#define MAX_FILE_SIZE   734003200
 Maximal acceptable file size for all reading operations.
#define MFILE_OK   0
#define MFILE_CANNOT_OPEN   -17
#define MFILE_MALLOC_ERR   -18
#define MFILE_SIZE_ERR   -19
#define MFILE_READ_ERR   -20
#define MFILE_INTERNAL   -21

Functions

DLLIMPORT short memfile_new (struct MEMORY_FILE **mfile, unsigned long alloc_len)
 Creates new MEMORY_FILE structure.
DLLIMPORT short memfile_free (struct MEMORY_FILE **mfile)
 Frees the MEMORY_FILE structure.
DLLIMPORT unsigned char * memfile_leave_content (struct MEMORY_FILE **mfile)
 Frees the MEMORY_FILE structure, leaving content.
DLLIMPORT short memfile_read (struct MEMORY_FILE *mfile, const char *fname, unsigned long max_size)
 Read a file, possibly compressed, and decompress it if necessary.
DLLIMPORT short memfile_readnew (struct MEMORY_FILE **mfile, const char *fname, unsigned long max_size)
 Read a file, possibly compressed, and decompress it if necessary.
DLLIMPORT short memfile_add (struct MEMORY_FILE *mfile, const unsigned char *buf, unsigned long buf_len)
 Adds data from buffer to the MEMORY_FILE.
DLLIMPORT short memfile_set (struct MEMORY_FILE *mfile, unsigned char *buf, unsigned long len, unsigned long alloc_len)
 Sets data from buffer as MEMORY_FILE.
DLLIMPORT short memfile_growalloc (struct MEMORY_FILE *mfile, unsigned long alloc_len)
 Enlarges data buffer allocated for MEMORY_FILE.
DLLIMPORT char * memfile_error (int errcode)


Define Documentation

#define MAX_FILE_SIZE   734003200

#define MFILE_CANNOT_OPEN   -17

Definition at line 34 of file memfile.h.

Referenced by memfile_error(), and memfile_read().

#define MFILE_INTERNAL   -21

Definition at line 38 of file memfile.h.

Referenced by memfile_read(), and memfile_set().

#define MFILE_MALLOC_ERR   -18

Definition at line 35 of file memfile.h.

Referenced by memfile_growalloc(), memfile_new(), and memfile_read().

#define MFILE_OK   0

#define MFILE_READ_ERR   -20

Definition at line 37 of file memfile.h.

Referenced by memfile_read().

#define MFILE_SIZE_ERR   -19

Definition at line 36 of file memfile.h.

Referenced by memfile_read().


Function Documentation

DLLIMPORT short memfile_add ( struct MEMORY_FILE mfile,
const unsigned char *  buf,
unsigned long  buf_len 
)

Adds data from buffer to the MEMORY_FILE.

Parameters:
mfile Pointer to MEMORY_FILE structure.
buf The input buffer.
buf_len Length of the input buffer.
Returns:
Returns MFILE_OK, or negative error code.

Definition at line 112 of file memfile.c.

Referenced by memfile_read().

DLLIMPORT char* memfile_error ( int  errcode  ) 

Definition at line 328 of file memfile.c.

Referenced by levfile_error(), load_mapfile_msg(), and script_load_and_execute_file().

DLLIMPORT short memfile_free ( struct MEMORY_FILE **  mfile  ) 

Frees the MEMORY_FILE structure.

Parameters:
mfile Double pointer to MEMORY_FILE structure.
Returns:
Returns MFILE_OK, or negative error code.

Definition at line 69 of file memfile.c.

Referenced by load_apt(), load_clm(), load_cubedata(), load_dat(), load_flg(), load_inf(), load_lgt(), load_mapfile_msg(), load_own(), load_palette(), load_slb(), load_text_file(), load_texture(), load_textureanim(), load_tng(), load_txt(), load_vsn(), load_wib(), load_wlb(), memfile_readnew(), and script_load_and_execute_file().

DLLIMPORT short memfile_growalloc ( struct MEMORY_FILE mfile,
unsigned long  alloc_len 
)

Enlarges data buffer allocated for MEMORY_FILE.

Parameters:
mfile Pointer to MEMORY_FILE structure.
alloc_len The minimal length allocated for buffer.
Returns:
Returns MFILE_OK, or negative error code.

Definition at line 87 of file memfile.c.

Referenced by memfile_add().

DLLIMPORT unsigned char* memfile_leave_content ( struct MEMORY_FILE **  mfile  ) 

Frees the MEMORY_FILE structure, leaving content.

Parameters:
mfile Double pointer to MEMORY_FILE structure.
Returns:
Returns the MEMORY_FILE content.

Definition at line 165 of file memfile.c.

DLLIMPORT short memfile_new ( struct MEMORY_FILE **  mfile,
unsigned long  alloc_len 
)

Creates new MEMORY_FILE structure.

Parameters:
mfile Double pointer to MEMORY_FILE structure.
alloc_len Initial size of allocated memory.
Returns:
Returns MFILE_OK, or negative error code. On error, the *mfile pointer is set to NULL.

Definition at line 39 of file memfile.c.

Referenced by memfile_readnew().

DLLIMPORT short memfile_read ( struct MEMORY_FILE mfile,
const char *  fname,
unsigned long  max_size 
)

Read a file, possibly compressed, and decompress it if necessary.

Requires MEMORY_FILE to be preallocated.

See also:
memfile_new
Parameters:
mfile Pointer to MEMORY_FILE structure, which will contain the file.
fname The input file name.
max_size Maximum acceptable input file size.
Returns:
Returns MFILE_OK, or negative error code.

Definition at line 186 of file memfile.c.

Referenced by memfile_readnew().

DLLIMPORT short memfile_readnew ( struct MEMORY_FILE **  mfile,
const char *  fname,
unsigned long  max_size 
)

Read a file, possibly compressed, and decompress it if necessary.

Automatically creates new MEMORY_FILE at start.

See also:
memfile_read
Parameters:
mfile Double pointer to MEMORY_FILE structure, which will contain the file.
fname The input file name.
max_size Maximum acceptable input file size.
Returns:
Returns MFILE_OK, or negative error code. On error, the *mfile is set to NULL.

Definition at line 315 of file memfile.c.

Referenced by load_apt(), load_clm(), load_cubedata(), load_dat(), load_flg(), load_inf(), load_lgt(), load_mapfile_msg(), load_own(), load_palette(), load_slb(), load_text_file(), load_texture(), load_textureanim(), load_tng(), load_txt(), load_vsn(), load_wib(), load_wlb(), and script_load_and_execute_file().

DLLIMPORT short memfile_set ( struct MEMORY_FILE mfile,
unsigned char *  buf,
unsigned long  len,
unsigned long  alloc_len 
)

Sets data from buffer as MEMORY_FILE.

The MEMORY_FILE content is directly replaced by the buffer. Input buffer is not copied - the direct pointer is set as content.

Parameters:
mfile Pointer to MEMORY_FILE structure.
buf The input buffer.
len Length of the file in the input buffer.
alloc_len Allocated length of the input buffer.
Returns:
Returns MFILE_OK, or negative error code.

Definition at line 139 of file memfile.c.

Referenced by memfile_read().


Generated on Tue Sep 2 18:51:50 2008 for libAdikted by  doxygen 1.5.6