#include "memfile.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <time.h>
#include "dernc.h"
Go to the source code of this file.
Functions | |
short | memfile_new (struct MEMORY_FILE **mfile, unsigned long alloc_len) |
Creates new MEMORY_FILE structure. | |
short | memfile_free (struct MEMORY_FILE **mfile) |
Frees the MEMORY_FILE structure. | |
short | memfile_growalloc (struct MEMORY_FILE *mfile, unsigned long alloc_len) |
Enlarges data buffer allocated for MEMORY_FILE. | |
short | memfile_add (struct MEMORY_FILE *mfile, const unsigned char *buf, unsigned long buf_len) |
Adds data from buffer to the MEMORY_FILE. | |
short | memfile_set (struct MEMORY_FILE *mfile, unsigned char *buf, unsigned long len, unsigned long alloc_len) |
Sets data from buffer as MEMORY_FILE. | |
unsigned char * | memfile_leave_content (struct MEMORY_FILE **mfile) |
Frees the MEMORY_FILE structure, leaving content. | |
short | memfile_read (struct MEMORY_FILE *mfile, const char *fname, unsigned long max_size) |
Read a file, possibly compressed, and decompress it if necessary. | |
short | memfile_readnew (struct MEMORY_FILE **mfile, const char *fname, unsigned long max_size) |
Read a file, possibly compressed, and decompress it if necessary. | |
char * | memfile_error (int errcode) |
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().
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().
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().
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().
unsigned char* memfile_leave_content | ( | struct MEMORY_FILE ** | mfile | ) |
Frees the MEMORY_FILE structure, leaving content.
mfile | Double pointer to MEMORY_FILE structure. |
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().
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().
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().
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().