mdcore  0.1.5
Data Structures | Defines | Functions | Variables
/home/pedro/work/mdcore/src/reader.h File Reference

Go to the source code of this file.

Data Structures

struct  reader

Defines

#define reader_err_ok   0
#define reader_err_null   -1
#define reader_err_malloc   -2
#define reader_err_io   -3
#define reader_err_buff   -4
#define reader_err_eof   -5
#define reader_flag_none   0
#define reader_flag_ready   1
#define reader_flag_eof   2

Functions

int reader_getc (struct reader *r)
 Read the next char.
int reader_init (struct reader *r, FILE *file, char *ws, char *comm_start, char *comm_stop)
 Initialize the reader.
int reader_gettoken (struct reader *r, char *buff, int buff_size)
 Read a token from the given reader.
int reader_getcomment (struct reader *r, char *buff, int buff_size)
 Read the next comment from the given reader.
int reader_getline (struct reader *r, char *buff, int buff_size)
 Read until a newline.
int reader_skiptoken (struct reader *r)
 Skip a token from the given reader.
int reader_skipcomment (struct reader *r)
 Skip the next comment from the given reader.
int reader_skipline (struct reader *r)
 Skip until a newline.
int reader_isws (struct reader *r, int c)
 Check if a character is whitespace.
int reader_iscomm_start (struct reader *r, int c)
 Check if a character is a comment start.
int reader_iscomm_stop (struct reader *r, int c)
 Check if a character is a comment stop.

Variables

int reader_err

Define Documentation

#define reader_err_buff   -4
#define reader_err_eof   -5
#define reader_err_io   -3
#define reader_err_malloc   -2
#define reader_err_null   -1
#define reader_err_ok   0
#define reader_flag_eof   2
#define reader_flag_none   0

Flags.

#define reader_flag_ready   1

Function Documentation

int reader_getc ( struct reader r)

Read the next char.

Parameters:
rThe reader.
Returns:
The next character or < 0 on error (see reader_err).
int reader_getcomment ( struct reader r,
char *  buff,
int  buff_size 
)

Read the next comment from the given reader.

Parameters:
rthe reader.
buffPointer to char at which to store the token.
buff_sizeSize of the buff.
Returns:
The number of read characters or < 0 on error (see reader_err).
int reader_getline ( struct reader r,
char *  buff,
int  buff_size 
)

Read until a newline.

Parameters:
rThe reader.
buffPointer to char at which to store the token.
buff_sizeSize of the buff.
Returns:
The number of read characters or < 0 on error (see reader_err).
int reader_gettoken ( struct reader r,
char *  buff,
int  buff_size 
)

Read a token from the given reader.

Parameters:
rThe reader.
buffPointer to char at which to store the token.
buff_sizeSize of the buff.
Returns:
The number of read characters or < 0 on error (see reader_err).
int reader_init ( struct reader r,
FILE *  file,
char *  ws,
char *  comm_start,
char *  comm_stop 
)

Initialize the reader.

Parameters:
rThe reader structure.
fileThe FILE with which the reader should be associated.
wsString containing the accepted whitespace characters.
comm_startString containing characters indicating the start of a comment.
comm_stopString containing characters indicating the end of a comment.

The FILE supplied should be open and will be read as of its current position.

Returns:
reader_err_ok or < 0 on error (see reader_err).
int reader_iscomm_start ( struct reader r,
int  c 
)

Check if a character is a comment start.

Parameters:
rThe reader.
cThe character to verify.
Returns:
1 if c is in the comm_start of the reader r or 0 otherwise.
int reader_iscomm_stop ( struct reader r,
int  c 
)

Check if a character is a comment stop.

Parameters:
rThe reader.
cThe character to verify.
Returns:
1 if c is in the comm_stop of the reader r or 0 otherwise.
int reader_isws ( struct reader r,
int  c 
)

Check if a character is whitespace.

Parameters:
rThe reader.
cThe character to verify.
Returns:
1 if c is in the comm_stop of the reader r or 0 otherwise.
int reader_skipcomment ( struct reader r)

Skip the next comment from the given reader.

Parameters:
rthe reader.
Returns:
The number of read characters or < 0 on error (see reader_err).
int reader_skipline ( struct reader r)

Skip until a newline.

Parameters:
rThe reader.
Returns:
The number of read characters or < 0 on error (see reader_err).
int reader_skiptoken ( struct reader r)

Skip a token from the given reader.

Parameters:
rThe reader.
Returns:
The number of read characters or < 0 on error (see reader_err).

Variable Documentation

ID of the last error

 All Data Structures Files Functions Variables Typedefs Enumerator Defines