mdcore
0.1.5
|
00001 /******************************************************************************* 00002 * This file is part of mdcore. 00003 * Coypright (c) 2011 Pedro Gonnet (pedro.gonnet@durham.ac.uk) 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published 00007 * by the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 ******************************************************************************/ 00019 00020 /* reader error codes */ 00021 #define reader_err_ok 0 00022 #define reader_err_null -1 00023 #define reader_err_malloc -2 00024 #define reader_err_io -3 00025 #define reader_err_buff -4 00026 #define reader_err_eof -5 00027 00028 00030 #define reader_flag_none 0 00031 #define reader_flag_ready 1 00032 #define reader_flag_eof 2 00033 00034 00036 extern int reader_err; 00037 00038 00040 struct reader { 00041 00043 unsigned int flags; 00044 00046 FILE *file; 00047 00049 int c; 00050 00052 int line, col; 00053 00055 char *ws; 00056 int nr_ws; 00057 00059 char *comm_start, *comm_stop; 00060 int nr_comm_start, nr_comm_stop; 00061 00062 }; 00063 00064 00065 /* associated functions */ 00066 int reader_getc ( struct reader *r ); 00067 int reader_init ( struct reader *r , FILE *file , char *ws , char *comm_start , char *comm_stop ); 00068 int reader_gettoken ( struct reader *r , char *buff , int buff_size ); 00069 int reader_getcomment ( struct reader *r , char *buff , int buff_size ); 00070 int reader_getline ( struct reader *r , char *buff , int buff_size ); 00071 int reader_skiptoken ( struct reader *r ); 00072 int reader_skipcomment ( struct reader *r ); 00073 int reader_skipline ( struct reader *r ); 00074 int reader_isws ( struct reader *r , int c ); 00075 int reader_iscomm_start ( struct reader *r , int c ); 00076 int reader_iscomm_stop ( struct reader *r , int c );