00001 /* spacedColumn - stuff to handle parsing text files where fields are 00002 * fixed width rather than tab delimited. */ 00003 00004 #ifndef SPACEDCOLUMN_H 00005 #define SPACEDCOLUMN_H 00006 00007 struct spacedColumn 00008 /* Specs on a column. */ 00009 { 00010 struct spacedColumn *next; 00011 int start; /* Starting index. */ 00012 int size; /* Size of column. */ 00013 }; 00014 00015 #define spacedColumnFreeList slFreeList 00016 00017 struct spacedColumn *spacedColumnFromWidthArray(int array[], int size); 00018 /* Return a list of spaced columns corresponding to widths in array. 00019 * The final char in each column should be whitespace. */ 00020 00021 struct spacedColumn *spacedColumnFromSample(char *sample); 00022 /* Return spaced column list from a sample line , which is assumed to 00023 * have no spaces except between columns */ 00024 00025 struct spacedColumn *spacedColumnFromSizeCommaList(char *commaList); 00026 /* Given an comma-separated list of widths in ascii, return 00027 * a list of spacedColumns. */ 00028 00029 struct spacedColumn *spacedColumnFromLineFile(struct lineFile *lf); 00030 /* Scan through lineFile and figure out column spacing. Assumes 00031 * file contains nothing but columns. */ 00032 00033 struct spacedColumn *spacedColumnFromFile(char *fileName); 00034 /* Read file and figure out where columns are. */ 00035 00036 int spacedColumnBiggestSize(struct spacedColumn *colList); 00037 /* Return size of biggest column. */ 00038 00039 boolean spacedColumnParseLine(struct spacedColumn *colList, 00040 char *line, char *row[]); 00041 /* Parse line into row according to colList. This will 00042 * trim leading and trailing spaces. It will write 0's 00043 * into line. Returns FALSE if there's a problem (like 00044 * line too short.) */ 00045 00046 #endif /* SPACEDCOLUMN_H */
1.5.2