#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 MAX_FILE_SIZE 734003200 |
Maximal acceptable file size for all reading operations.
Value set to 700MB.
Definition at line 30 of file memfile.h.
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_read(), and script_load_and_execute_file().
#define MFILE_CANNOT_OPEN -17 |
#define MFILE_INTERNAL -21 |
#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 |
Definition at line 33 of file memfile.h.
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_add(), memfile_free(), memfile_growalloc(), memfile_new(), memfile_readnew(), memfile_set(), and script_load_and_execute_file().
#define MFILE_READ_ERR -20 |
#define MFILE_SIZE_ERR -19 |
DLLIMPORT short memfile_add | ( | struct MEMORY_FILE * | mfile, | |
const unsigned char * | buf, | |||
unsigned long | buf_len | |||
) |
Adds data from buffer to the MEMORY_FILE.
mfile | Pointer to MEMORY_FILE structure. | |
buf | The input buffer. | |
buf_len | Length of the input buffer. |
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.
mfile | Double pointer to MEMORY_FILE structure. |
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.
mfile | Pointer to MEMORY_FILE structure. | |
alloc_len | The minimal length allocated for buffer. |
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.
mfile | Double pointer to MEMORY_FILE structure. |
DLLIMPORT short memfile_new | ( | struct MEMORY_FILE ** | mfile, | |
unsigned long | alloc_len | |||
) |
Creates new MEMORY_FILE structure.
mfile | Double pointer to MEMORY_FILE structure. | |
alloc_len | Initial size of allocated memory. |
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.
mfile | Pointer to MEMORY_FILE structure, which will contain the file. | |
fname | The input file name. | |
max_size | Maximum acceptable input file size. |
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.
mfile | Double pointer to MEMORY_FILE structure, which will contain the file. | |
fname | The input file name. | |
max_size | Maximum acceptable input file size. |
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.
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. |
Definition at line 139 of file memfile.c.
Referenced by memfile_read().