// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.cc,v 1.27 2003/07/26 00:27:36 mdz Exp $
+// $Id: configuration.cc,v 1.28 2004/04/30 04:00:15 mdz Exp $
/* ######################################################################
Configuration Class
char S[300];
snprintf(S,sizeof(S),"%i",Value);
Itm->Value = S;
+}
+ /*}}}*/
+// Configuration::Clear - Clear an single value from a list /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void Configuration::Clear(string Name, int Value)
+{
+ char S[300];
+ snprintf(S,sizeof(S),"%i",Value);
+ Clear(Name, S);
+}
+ /*}}}*/
+// Configuration::Clear - Clear an single value from a list /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void Configuration::Clear(string Name, string Value)
+{
+ Item *Top = Lookup(Name.c_str(),false);
+ if (Top == 0 || Top->Child == 0)
+ return;
+
+ Item *Tmp, *Prev, *I;
+ Prev = I = Top->Child;
+
+ while(I != NULL)
+ {
+ if(I->Value == Value)
+ {
+ Tmp = I;
+ // was first element, point parent to new first element
+ if(Top->Child == Tmp)
+ Top->Child = I->Next;
+ I = I->Next;
+ Prev->Next = I;
+ delete Tmp;
+ } else {
+ Prev = I;
+ I = I->Next;
+ }
+ }
+
}
/*}}}*/
// Configuration::Clear - Clear an entire tree /*{{{*/
void Configuration::Clear(string Name)
{
Item *Top = Lookup(Name.c_str(),false);
- if (Top == 0)
+ if (Top == 0)
return;
-
+
Top->Value = string();
Item *Stop = Top;
Top = Top->Child;
if (!F != 0)
return _error->Errno("ifstream::ifstream",_("Opening configuration file %s"),FName.c_str());
- char Buffer[300];
+ char Buffer[1024];
string LineBuffer;
string Stack[100];
unsigned int StackPos = 0;
{
F.getline(Buffer,sizeof(Buffer));
CurLine++;
+ // This should be made to work instead, but this is better than looping
+ if (F.fail() && !F.eof())
+ return _error->Error(_("Line %d too long (max %d)"), CurLine, sizeof(Buffer));
+
_strtabexpand(Buffer,sizeof(Buffer));
_strstrip(Buffer);
string Tag;
const char *Pos = LineBuffer.c_str();
if (ParseQuoteWord(Pos,Tag) == false)
- return _error->Error(_("Syntax error %s:%u: Malformed Tag"),FName.c_str(),CurLine);
+ return _error->Error(_("Syntax error %s:%u: Malformed tag"),FName.c_str(),CurLine);
// Parse off the word
string Word;