sourcemod/sourcepawn/compiler/memfile.h
Scott Ehlert 251cced1f8 Spring Cleaning, Part Ichi (1)
Various minor things done to project files
Updated sample extension project file and updated makefile to the new unified version (more changes likely on the way)
Updated regex project file and makefile

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401971
2008-03-30 07:00:22 +00:00

56 lines
1.1 KiB
C

#ifndef _INCLUDE_MEMFILE_H
#define _INCLUDE_MEMFILE_H
#include <malloc.h>
typedef struct memfile_s
{
char *name;
char *base;
long offs;
long usedoffs;
size_t size;
int _static;
} memfile_t;
/**
* Creates a new memory file
* init is the initial size in bytes
*/
memfile_t *memfile_creat(const char *name, size_t init);
/**
* Frees the memory associated.
*/
void memfile_destroy(memfile_t *mf);
/**
* Seeks to a given offset (always from start)
*/
void memfile_seek(memfile_t *mf, long seek);
/**
* Writes to a memory buffer (expands as necessary).
* Returns 1 on success, 0 on failure.
*/
int memfile_write(memfile_t *mf, const void *buffer, size_t size);
/**
* Reads a number of bytes from a memory buffer.
* Returns the number of bytes read until the end was hit.
*/
size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize);
/**
* Returns the current position from the start.
*/
long memfile_tell(memfile_t *mf);
/**
* Resets all the states of the memory buffer.
* (does not actually free or zero memory)
*/
void memfile_reset(memfile_t *mf);
#endif //_INCLUDE_MEMFILE_H