Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

General read/write operations
[Global/general functions]

Data Structures

Defines

Typedefs

Functions


Detailed Description

MiniGUI's general read/write operation provides a general interface to read from and write to various data source, such as files, memory, and so on.

Define Documentation

#define MGUI_RWclose ctx   )     (ctx)->close(ctx)
 

Closes an MG_RWops object.

This macro close the MG_RWops object pointed to by ctx.

Parameters:
ctx The pointer to the MG_RWops object.
Returns:
Upon successful completion 0 is returned, otherwise non-zero on error.
See also:
MGUI_RWread

Definition at line 312 of file endianrw.h.

#define MGUI_RWeof ctx   )     (ctx)->eof(ctx)
 

Tests the end-of-file indicator for an data source.

This macro tests the end-of-file indicator for the data source pointed to by ctx.

Parameters:
ctx The pointer to the MG_RWops object.
Returns:
Non-zero if end-of-file indicator is set.
See also:
MGUI_RWtell

Definition at line 327 of file endianrw.h.

#define MGUI_RWread ctx,
ptr,
size,
 )     (ctx)->read(ctx, ptr, size, n)
 

Reads data blocks from a data source.

This macro reads up to n objects each of size size from the data source ctx to the area pointed to by ptr.

Parameters:
ctx The pointer to the MG_RWops object.
ptr The buffer will save the data read.
size The size of each object.
n The number of objects to be read.
Returns:
The number of objects read, or -1 if the read failed.
See also:
MGUI_RWwrite

Definition at line 280 of file endianrw.h.

#define MGUI_RWseek ctx,
offset,
whence   )     (ctx)->seek(ctx, offset, whence)
 

Seeks an MG_RWops object.

This macro seeks to offset relative to whence.

Parameters:
ctx The pointer to the MG_RWops object.
offset The offset relative to whence.
whence One of stdio's whence values:
  • SEEK_SET
    the offset is relative to the start of the file.
  • SEEK_CUR
    the offset is relative to the current position indicator.
  • SEEK_END
    the offset is relative to the end of the file.

Returns:
The final offset in the data source.
See also:
MGUI_RWtell

Definition at line 248 of file endianrw.h.

#define MGUI_RWtell ctx   )     (ctx)->seek(ctx, 0, SEEK_CUR)
 

Obtains the current value of the position indicator for a data source.

This macro obtains the current value of the position indicator for the data source pointed to by ctx.

Parameters:
ctx The pointer to the MG_RWops object.
Returns:
The current value of the position indicator.
See also:
MGUI_RWseek

Definition at line 263 of file endianrw.h.

#define MGUI_RWwrite ctx,
ptr,
size,
 )     (ctx)->write(ctx, ptr, size, n)
 

Writes data blocks to a data source.

This macro writes exactly n objects each of size size from the area pointed to by ptr to the data source ctx.

Parameters:
ctx The pointer to the MG_RWops object.
ptr The buffer contains the data to be written.
size The size of each object.
n The number of objects to be written.
Returns:
The number written, or -1 if the write failed.
See also:
MGUI_RWread

Definition at line 297 of file endianrw.h.


Typedef Documentation

typedef struct _MG_RWops MG_RWops
 

The read/write operation structure.


Function Documentation

MG_RWops * MGUI_AllocRW void   ) 
 

Allocates an uninitialized MG_RWops object.

This function allocates an uninitialized MG_RWops object. You can specify the fields of the structure, and implemente a customized MG_RWops object.

Returns:
The pointer to allocated MG_RWops structure, NULL indicates error.
See also:
MG_RWops

void MGUI_FreeRW MG_RWops area  ) 
 

Frees an MG_RWops object.

This function frees the MG_RWops object pointed to by area.

Parameters:
area The pointer to the MG_RWops object.
See also:
MGUI_RWFromFile, MGUI_RWFromFP, MGUI_RWFromMem

void MGUI_InitMemRW MG_RWops area,
void *  mem,
int  size
 

Initializes an MG_RWops object from a block of memory.

This function initializes an MG_RWops object pointed to by area from a block of memory pointed to by mem, which is size bytes long.

Parameters:
area The pointer to the MG_RWops object.
mem The pointer to the memory block.
size The size of the memory block.
Returns:
None.
See also:
MG_RWops, MGUI_FreeRW, MGUI_RWFromMem

MG_RWops * MGUI_RWFromFile const char *  file,
const char *  mode
 

Creates an MG_RWops object from a file.

This function uses the mode specified by mode and opens the file file by using stdio function fopen. If success, this function creates a MG_RWops object and returns it.

Parameters:
file The file name.
mode The mode will be passed to fopen.
Returns:
The pointer to created MG_RWops structure, NULL indicates error.
See also:
MG_RWops, MGUI_RWFromFP, MGUI_FreeRW, fopen(3)

MG_RWops * MGUI_RWFromFP FILE *  fp,
int  autoclose
 

Creates an MG_RWops object from an opened stdio FILE object.

This function uses an opened stdio FILE object fp to create a MG_RWops object.

Parameters:
fp The opened stdio FILE object.
autoclose Indicates whether to close the FILE object when close method is called.
Returns:
The pointer to created MG_RWops structure, NULL indicates error.
See also:
MG_RWops, MGUI_RWFromFile, MGUI_FreeRW

MG_RWops * MGUI_RWFromMem void *  mem,
int  size
 

Creates an MG_RWops object from a block of memory.

This function creates an MG_RWops object from a block of memory pointed to by mem, which is size bytes long.

Parameters:
mem The pointer to the memory block.
size The size of the memory block.
Returns:
The pointer to created MG_RWops structure, NULL indicates error.
See also:
MG_RWops, MGUI_FreeRW

int MGUI_RWgetc MG_RWops area  ) 
 

Reads the next character from an data source.

This function reads the next character from the data source pointed to by area, and returns it as an unsigned char cast to an int, or EOF on end of file or error.

Parameters:
area The pointer to the MG_RWops object.
Returns:
The character read, EOF indicates end-of-file or error.
See also:
MGUI_RWread


Generated on Mon Jun 26 13:54:29 2006 for MiniGUI V1.6.9 API Reference by  doxygen 1.4.2