49static char *Eat_Spaces(
char *
string);
62 char sectionname[256];
68 memset(sectionname,0,256);
71 while (fgets(
string,256,in))
73 cptr=Eat_Spaces(
string);
74 if ((*cptr==0)||(*cptr==
'#'))
82 strcpy(sectionname,key.
get());
83 Wstring wssectionname;
85 if (strlen(sectionname)==2)
88 wssectionname.
set(
"");
91 wssectionname.
set(sectionname+1);
100 if (strchr(cptr,
'=')==
NULL)
108 if (strlen(sectionname))
109 key.
cat(sectionname);
111 cptr=Eat_Spaces(strchr(cptr,
'=')+1);
113 value.truncate(
'\r');
114 value.truncate(
'\n');
118 while(isgraph(
value.get()[strlen(
value.get())-1])==0)
122 Dictionary_.add(key,
value);
137 int seclen = strlen(section);
141 if (Dictionary_.iterate(index,offset,key,
value)==
FALSE)
151 if (strlen(section)+2 >= strlen(key.
get()))
155 const char *keystr = key.
get() + strlen(key.
get())-seclen-1;
156 if (strncmp(keystr,section,strlen(section))==0)
179 bit8 retval=Dictionary_.getValue(key,
value);
184 DBGMSG(
"Config entry missing: "<<key.
get());
213 bit8 retval=Dictionary_.getValue(key,svalue);
217 {
DBGMSG(
"Config entry missing: "<<key.get()); }
251 bit8 retval=Dictionary_.getValue(key,svalue);
255 {
DBGMSG(
"Config entry missing: "<<key.get()); }
290 bit8 retval=Dictionary_.remove(key);
294 {
DBGMSG(
"Config entry missing: "<<key.
get()); }
327 Dictionary_.remove(key);
336 if (!strcmp(
test.get(), section))
350 DBGMSG(
"Config could not set entry: "<<key.
get());
384 Dictionary_.remove(key);
385 bit8 retval=Dictionary_.add(key,svalue);
394 if (!strcmp(
test.get(), section))
407 {
DBGMSG(
"Config could not set entry: "<<key.
get()); }
428 ERRMSG(
"No FP on config file write!");
442 fprintf(config,
"[%s]\n", section.
get());
447 fprintf(config,
"%s=%s\n", key.
get(),
value.get());
449 fprintf(config,
"\n");
467 retval=
string.length();
468 for (
uint32 i=0; i<
string.length(); i++)
470 retval+=*(
string.get()+i);
472 retval=(retval<<8)^(retval>>24);
477static char *Eat_Spaces(
char *
string)
480 while (isspace(*retval))
bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=NULL) const
bit8 getInt(IN Wstring &key, OUT sint32 &value)
bit8 readFile(IN FILE *config)
ArrayList< Wstring > sectionList
bit8 setString(IN Wstring &key, IN Wstring &value, IN char *section=NULL)
bit8 removeEntry(IN Wstring &key, IN char *section=NULL)
bit8 setInt(IN Wstring &key, IN sint32 &value, IN char *section=NULL)
bit8 writeFile(FILE *config)
bit8 getString(IN Wstring &key, OUT Wstring &value)
bit8 cat(IN char *string)
char setFormatted(IN char *str,...)
bit8 truncate(uint32 len)