MeatAxe
2.4
|
The MeatAxe is written for a UNIX-like operating environment and uses many functions of the standard C library. To make the MeatAxe more portable between different operating systems, some C library and system calls are accessed through wrapper functions. These wrapper functions have names that begin with 'Sys'. For example SysFree()
is the wrapper function for free()
.
Macros | |
#define | FM_READ 0x01 |
File mode: read. | |
#define | FM_CREATE 0x02 |
File mode: write. | |
#define | FM_APPEND 0x03 |
File mode: append. | |
Functions | |
void | SysInit () |
OS-specific initialization. More... | |
long | SysTimeUsed (void) |
CPU time. More... | |
void | SysSetTimeLimit (long nsecs) |
Set CPU time limit. More... | |
FILE * | SysFopen (const char *name, int mode) |
Open a file. More... | |
int | SysFseek (FILE *file, long pos) |
Set file pointer. More... | |
int | SysRemoveFile (const char *name) |
Remove a file This function deletes a file. More... | |
int | SysRemoveDirectory (const char *name) |
Remove a directory. More... | |
int | SysCreateDirectory (const char *name) |
Create a directory. More... | |
int | SysFseekRelative (FILE *file, long distance) |
Set file pointer relative to current position. More... | |
void * | SysMalloc (size_t nbytes) |
Allocate memory. More... | |
void * | SysRealloc (void *buf, size_t nbytes) |
Resize memory block. More... | |
void | SysFree (void *x) |
Free memory block. More... | |
int | SysGetPid () |
Get process id. More... | |
int SysCreateDirectory | ( | const char * | name | ) |
Create a directory.
This function creates a new directory. If the directory cannot be created for some reason, a run-time error is generated and the function returns -1.
name | Name of the directory. |
FILE* SysFopen | ( | const char * | name, |
int | mode | ||
) |
Open a file.
This function opens a file, like fopen()
. The second argument, must be one of the predfined constants FM_READ (open for reading), FM_CREAT (create a new file and open for writing, or FM_APPEND (append to existing file or create a new file). Additional flags may be or'ed to the mode:
MTXLIB
, or at compile-time by the macro MTXLIB
. void SysFree | ( | void * | x | ) |
Free memory block.
This function works like free()
but checks if the argument is not NULL. Otherwise, an appropriate error message is generated.
x | Pointer to the memory block. |
int SysFseek | ( | FILE * | file, |
long | pos | ||
) |
Set file pointer.
This function sets the file pointer to a given position. If pos is greater than or equal to zero, it is interpreted as an absolute position (relative to start of file). If pos
is negative, the file pointer is moved to the end of file.
file | File handle. |
pos | New position of file pointer. |
int SysFseekRelative | ( | FILE * | file, |
long | distance | ||
) |
Set file pointer relative to current position.
This function moves the file pointer by a given number of bytes, which may be positive or negative.
file | The file handle. |
distance | The number of bytes by which the file pointer shall be moved. |
int SysGetPid | ( | ) |
Get process id.
This function returns a number which uniquely identifies the calling process on the local system. The exact meaning of this number depends on the operating system. In an UNIX environment, it is the process id (PID).
void SysInit | ( | void | ) |
OS-specific initialization.
This function is called during library initialization. It performs any OS-specific actions. Applications should never call this function directly. Use MtxInit() instead.
void* SysMalloc | ( | size_t | nbytes | ) |
Allocate memory.
This function works like malloc()
, but the return value is never 0, even when the function was called with a 0 argument.
nbytes | Size of memory block to allocate. |
void* SysRealloc | ( | void * | buf, |
size_t | nbytes | ||
) |
Resize memory block.
This function works like realloc()
but handles zero-length blocks differently (namely, by allocating 1 byte instead) to avoid problems with broken realloc()
implementations.
buf | Pointer to memory block. |
nbytes | Desired new size. |
int SysRemoveDirectory | ( | const char * | name | ) |
Remove a directory.
This function removes the specified directory.
name | Name of the directory. |
int SysRemoveFile | ( | const char * | name | ) |
Remove a file This function deletes a file.
On a UNIX system, SysRemoveFile() just calls remove(). If the file to be deleted does not exist or cannot be removed for some other reason, run-time error error is generated.
void SysSetTimeLimit | ( | long | nsecs | ) |
Set CPU time limit.
This function sets a CPU time limit for the calling process. When the limit is exceeded the process is killed.
nsecs | CPU time limit in seconds. |
long SysTimeUsed | ( | void | ) |
CPU time.
This function returns the CPU time used by the calling process in units of 1/10 seconds.