00001 #ifndef XFILE_H 00002 #define XFILE_H 00003 #include <stdio.h> 00004 #include "kwdset.h" 00005 00006 /** aliases for keyword handling - used in XFILE structure and xfscanf function: 00007 ignore - %k conversions are ignored, no keywords are searched for/printed out 00008 sequnet_mode - keywords are searched sequentially as the XFILE is being processed, 00009 the searching starts from the actual position in the XFILE and the next string 00010 must match to the given keyword otherwise the error code is returned 00011 line_mode - keywords are searched within the scope of the acutal line, if the keyword is not found 00012 the error code is returned 00013 sect_mode_seq - keywords are searched within the scope of the actual section starting from the actual 00014 position in the section and the next string must match to the given keyword 00015 otherwise the error code is returned. It is similar mode as sequent_mode but the ends 00016 of sections are checked for. 00017 sect_mode_full - keywords are searched within the scope of the actual section starting from the beginning of 00018 the actual section for each %k conversion in the format string. If the given keyword was not found 00019 in the given section the error code is returned. 00020 sect_mode_ignore - same as the ignore mode but ends of section are checked for 00021 sect_mode_fwd - keywords are searched within the scope of the actual section starting from the actual 00022 position in the section. The keywords are searched for until the end of section is reached. 00023 If the keyword was not found from the actual position in the section till the end of section 00024 then the error code is returned 00025 */ 00026 enum kwd_handling {ignore=0, sequent_mode = 1, line_mode=2, sect_mode_seq = 3, sect_mode_full = 4, sect_mode_ignore = 5, sect_mode_fwd = 6}; 00027 00028 00029 00030 struct xfsection; 00031 struct XFILE; 00032 00033 00034 00035 /** 00036 Structure of file description. This file type is used for xfscanf function and 00037 it has extended functionality comparing with traditional FILE type - 00038 - actual line and column number, 00039 - file name string, 00040 - error and warning management, 00041 - support for keywords. 00042 00043 Created by Tomas Koudelka, koudelka@cml.fsv.cvut.cz, 12.2006 00044 */ 00045 struct XFILE 00046 { 00047 FILE *file; ///< pointer to standard file structure 00048 long line; ///< actual line 00049 long col; ///< actual column 00050 long lnfpos; ///< actual position of actual line beginning in file 00051 char *fname; ///< name of opened file 00052 char *lnstr; ///< line buffer where the actual file line is stored 00053 00054 00055 int warning; ///< flag which handles warning (0=no warning/1=print warning/2=treat warning as an error) 00056 long maxlnover; ///< flag with the number of last oversized line (=0 if no oversized line detected) 00057 00058 kwd_handling kwdmode; ///< keyword handling mode 00059 long ignorecase; ///< flag for case sensitive(=0)/case insensitive(=1) keyword searching 00060 00061 // following data members are necessary only in case that kwdmode=sect_mode 00062 long index_created; ///< flag for created index of particular sections 00063 long id_sec; ///< index of actual section 00064 xfsection *asect; ///< pointer to actual section 00065 long num_sec; ///< number of detected sections 00066 xfsection *sect; ///< array with descriptions of detected sections 00067 00068 char *lnpref; ///< prefix string of line beginning (for XFILE output) 00069 char *lnpostf; ///< postfix string of line end (for XFILE output) 00070 long lnprefl; ///< length of lnpref string 00071 long lnpostfl; ///< length of lnpostf string 00072 00073 private: 00074 long maxlnsize; ///< max line size 00075 public: 00076 XFILE(); 00077 ~XFILE(); 00078 long give_maxlnsize(); ///< returns size of line buffer 00079 void set_maxlnsize(long lnsize); ///< sets size of line buffer 00080 }; 00081 00082 00083 00084 /** 00085 Structure contains data about XFILE sections. It is used 00086 in case that kwdmode=sect_mode 00087 00088 Created by Tomas Koudelka, koudelka@cml.fsv.cvut.cz, 12.2006 00089 */ 00090 struct xfsection 00091 { 00092 long beg_secpos; ///< position of section beginning in xfile (section begins at the first character after the keyword for the section begining) 00093 long end_secpos; ///< position of section end in xfile (section ends at the last character befor the keyword for the section end) 00094 long beg_secln; ///< line number of section beginning 00095 long end_secln; ///< line number of section end 00096 long beg_seccol; ///< column number of section begining (immediately after keyword of section beginning) 00097 long end_seccol; ///< column number of section end (the last position before keyword of section end) 00098 enumstr name; ///< section name and enum alias 00099 }; 00100 #endif