Birds Bot Manager (BBM) ----------------------- BBM provides a class called "CfgFile" for loading, parsing, updating and re-writing config files. CfgFile format -------------- A CfgFile is a text file with one or more "sections" containing one or more free-form lines of text. Each section is introduced by placing "[section-name]" on a line of its own. There must be at least one blank line between sections. Within each section, the lines of text are free-form, with the restriction that there can be at most 32 "words" on each line. Words are separated from each other by whitespace. Opening a CfgFile ----------------- The Bot method OpenConfigFile(char *name) returns a CfgFile * object. The filename is resolved relative to the bots data directory, and cannot contain ".." or start with a "/". Other Methods ------------- int CountSections() Returns a count of the number of sections. int SectionByName(char *sname) Returns a "section number" for the given section name. char * SectionByNumber(int snum) Returns the (char *) name of the given section number. int CountLines(int snum) Returns the number of lines present in the given section. cfgentry_t * GetEntry(int snum, int lnum) Returns the config line struct for the line lnum in the section snum. cfgentry_t contains char *toks[32] as an array of up to 32 "words" from the line. int FindEntry(int snum, int lnum, char *argname, char ***toklist) FindEntry() looks through lines in the given section, starting at line lnum, for the first line that starts with the word argname[]. The actual lline number of this entry is returned, and toklist is pointed at the (char *toks[32]) entry for that line. BOOL DeleteEntry(int snum, int lnum) Deletes the line "lnum" from the section "snum". All remaining lines are moved up to fill in the gap. Returns TRUE if there was a line at that location which is now deleted. BOOL AddEntry(int snum, char *line) Adds a new line (given by line[]) to the section number snum. BOOL WriteFile(char *fname) BOOL WiteFile(void) Writes the contents of the CfgFile object out to a file. If no filename is given then the original file will be overwritten with the new data. Comments in the original file are not preserved.