int mg_open( MG_FCTXT *fcp, char *filename )
int mg_read( void )
int mg_parse( void )
void mg_close( void )
The mg_open routine takes an uninitialized MG_FCTXT structure and a file name as its arguments. If filename is the NULL pointer, the standard input is "opened." The fcp structure will be set by mg_open prior to its return, and the global mg_file pointer will be assigned to point to it. This variable must not be destroyed until after the file is closed with a call to mg_close. (See the mg_load page for a definition of mg_file and the MG_FCTXT type.)
The mg_read function reads the next input line from the current file, returning the number of characters in the line, or zero if the end of file is reached or there is a file error. If the value returned equals MG_MAXLINE-1, then the input line was too long, and you should return an MG_ELINE error. The function keeps track of the line number in the current file context mg_file, which also contains the line that was read.
The mg_parse function breaks the current line in the mg_file structure into words and calls the appropriate handler routine, if any. Blank lines and unsupported entities cause a quick return.
The mg_close routine closes the current input file (unless it is the standard input) and returns to the previous file context (if any).
The mg_parse function returns MG_OK if the current line was successfully interpreted, or one of the defined error values if there is a problem. (See the mg_load page for the defined error values.)