00001 /* Stuff to parse .ra files. Ra files are simple text databases. 00002 * The database is broken into records by blank lines. 00003 * Each field takes a line. The name of the field is the first 00004 * word in the line. The value of the field is the rest of the line. 00005 * 00006 * This file is copyright 2002 Jim Kent, but license is hereby 00007 * granted for all use - public, private or commercial. */ 00008 00009 #ifndef RA_H 00010 00011 struct hash *raNextRecord(struct lineFile *lf); 00012 /* Return a hash containing next record. 00013 * Returns NULL at end of file. freeHash this 00014 * when done. Note this will free the hash 00015 * keys and values as well, so you'll have to 00016 * cloneMem them if you want them for later. */ 00017 00018 struct hash *raFromString(char *string); 00019 /* Return hash of key/value pairs from string. 00020 * As above freeHash this when done. */ 00021 00022 boolean raFoldInOne(struct lineFile *lf, struct hash *hashOfHash); 00023 /* Fold in one record from ra file into hashOfHash. 00024 * This will add ra's and ra fields to whatever already 00025 * exists in the hashOfHash, overriding fields of the 00026 * same name if they exist already. */ 00027 00028 void raFoldIn(char *fileName, struct hash *hashOfHash); 00029 /* Read ra's in file name and fold them into hashOfHash. 00030 * This will add ra's and ra fields to whatever already 00031 * exists in the hashOfHash, overriding fields of the 00032 * same name if they exist already. */ 00033 00034 struct hash *raReadSingle(char *fileName); 00035 /* Read in first ra record in file and return as hash. */ 00036 00037 struct hash *raReadAll(char *fileName, char *keyField); 00038 /* Return hash that contains all ra records in file keyed 00039 * by given field, which must exist. The values of the 00040 * hash are themselves hashes. */ 00041 00042 #endif /* RA_H */ 00043
1.5.2