summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/cmndline.cc11
-rw-r--r--apt-pkg/contrib/cmndline.h3
-rw-r--r--apt-pkg/contrib/configuration.cc61
-rw-r--r--apt-pkg/contrib/configuration.h10
-rw-r--r--apt-pkg/contrib/error.cc15
-rw-r--r--apt-pkg/contrib/error.h3
-rw-r--r--apt-pkg/contrib/fileutl.cc18
-rw-r--r--apt-pkg/contrib/fileutl.h4
-rw-r--r--apt-pkg/contrib/md5.h10
-rw-r--r--apt-pkg/contrib/mmap.h3
-rw-r--r--apt-pkg/contrib/progress.h3
-rw-r--r--apt-pkg/contrib/strutl.cc8
-rw-r--r--apt-pkg/contrib/system.h3
13 files changed, 92 insertions, 60 deletions
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 629b8e9e5..ccacb9609 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cmndline.cc,v 1.7 1998/12/14 02:23:47 jgg Exp $
+// $Id: cmndline.cc,v 1.8 1999/01/18 06:20:07 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -96,7 +96,6 @@ bool CommandLine::Parse(int argc,const char **argv)
if (Opt == OptEnd)
return _error->Error("Command line option %s is not understood",argv[I]);
Opt++;
- cout << Opt << endl;
for (A = ArgList; A->end() == false &&
stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
@@ -205,7 +204,13 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
return true;
}
- Conf->Set(A->ConfName,Argument);
+ const char *I = A->ConfName;
+ for (; *I != 0 && *I != ' '; I++);
+ if (*I == ' ')
+ Conf->Set(string(A->ConfName,0,I-A->ConfName),string(I+1) + Argument);
+ else
+ Conf->Set(A->ConfName,string(I) + Argument);
+
return true;
}
diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h
index 40d7f08ba..e611cd637 100644
--- a/apt-pkg/contrib/cmndline.h
+++ b/apt-pkg/contrib/cmndline.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cmndline.h,v 1.5 1998/12/14 02:23:47 jgg Exp $
+// $Id: cmndline.h,v 1.6 1999/01/18 06:20:07 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -38,7 +38,6 @@
##################################################################### */
/*}}}*/
-// Header section: pkglib
#ifndef PKGLIB_CMNDLINE_H
#define PKGLIB_CMNDLINE_H
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index da026f0f6..e03001f84 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.cc,v 1.10 1998/11/05 07:21:43 jgg Exp $
+// $Id: configuration.cc,v 1.11 1999/01/18 06:20:07 jgg Exp $
/* ######################################################################
Configuration Class
@@ -43,10 +43,17 @@ Configuration::Item *Configuration::Lookup(Item *Head,const char *S,
int Res = 1;
Item *I = Head->Child;
Item **Last = &Head->Child;
- for (; I != 0; Last = &I->Next, I = I->Next)
- if ((Res = stringcasecmp(I->Tag.begin(),I->Tag.end(),S,S + Len)) == 0)
- break;
+ // Empty strings match nothing. They are used for lists.
+ if (Len != 0)
+ {
+ for (; I != 0; Last = &I->Next, I = I->Next)
+ if ((Res = stringcasecmp(I->Tag.begin(),I->Tag.end(),S,S + Len)) == 0)
+ break;
+ }
+ else
+ for (; I != 0; Last = &I->Next, I = I->Next);
+
if (Res == 0)
return I;
if (Create == false)
@@ -73,7 +80,7 @@ Configuration::Item *Configuration::Lookup(const char *Name,bool Create)
const char *End = Start + strlen(Name);
const char *TagEnd = Name;
Item *Itm = Root;
- for (; End - TagEnd > 2; TagEnd++)
+ for (; End - TagEnd >= 2; TagEnd++)
{
if (TagEnd[0] == ':' && TagEnd[1] == ':')
{
@@ -84,6 +91,13 @@ Configuration::Item *Configuration::Lookup(const char *Name,bool Create)
}
}
+ // This must be a trailing ::, we create unique items in a list
+ if (End - Start == 0)
+ {
+ if (Create == false)
+ return 0;
+ }
+
Itm = Lookup(Itm,Start,End - Start,Create);
return Itm;
}
@@ -377,17 +391,11 @@ bool ReadConfigFile(Configuration &Conf,string FName)
continue;
// Parse off the tag
- string::size_type Pos = LineBuffer.find(' ');
- if (Pos == string::npos)
- {
- if (TermChar == '{')
- Pos = LineBuffer.length();
- else
- return _error->Error("Syntax error %s:%u: Tag with no value",FName.c_str(),CurLine);
- }
+ 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);
- string Tag = string(LineBuffer,0,Pos);
-
// Go down a level
if (TermChar == '{')
{
@@ -398,17 +406,16 @@ bool ReadConfigFile(Configuration &Conf,string FName)
Tag = string();
}
- // We dont have a value to set
- if (Pos == LineBuffer.length())
- {
- LineBuffer = string();
- continue;
- }
-
// Parse off the word
string Word;
- if (ParseCWord(LineBuffer.c_str()+Pos,Word) == false)
- return _error->Error("Syntax error %s:%u: Malformed value",FName.c_str(),CurLine);
+ if (ParseCWord(Pos,Word) == false)
+ {
+ if (TermChar != '{')
+ {
+ Word = Tag;
+ Tag = "";
+ }
+ }
// Generate the item name
string Item;
@@ -416,10 +423,10 @@ bool ReadConfigFile(Configuration &Conf,string FName)
Item = Tag;
else
{
- if (Tag.empty() == true)
- Item = ParentTag;
- else
+ if (TermChar != '{' || Tag.empty() == false)
Item = ParentTag + "::" + Tag;
+ else
+ Item = ParentTag;
}
// Set the item in the configuration class
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index c5c32ef2f..adda854cb 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.h,v 1.8 1998/11/04 07:11:12 jgg Exp $
+// $Id: configuration.h,v 1.9 1999/01/18 06:20:07 jgg Exp $
/* ######################################################################
Configuration Class
@@ -14,13 +14,17 @@
And has associated with it a text string. The Configuration class only
provides storage and lookup for this tree, other classes provide
configuration file formats (and parsers/emitters if needed).
-
+
Most things can get by quite happily with,
cout << _config->Find("Foo::Bar") << endl;
+
+ A special extension, support for ordered lists is provided by using the
+ special syntax, "block::list::" the trailing :: designates the
+ item as a list. To access the list you must use the tree function on
+ "block::list".
##################################################################### */
/*}}}*/
-// Header section: pkglib
#ifndef PKGLIB_CONFIGURATION_H
#define PKGLIB_CONFIGURATION_H
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index bbd081d50..8ae2686de 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: error.cc,v 1.5 1998/09/18 02:42:40 jgg Exp $
+// $Id: error.cc,v 1.6 1999/01/18 06:20:07 jgg Exp $
/* ######################################################################
Global Erorr Class - Global error mechanism
@@ -80,8 +80,9 @@ bool GlobalError::Errno(const char *Function,const char *Description,...)
// sprintf the description
char S[400];
- vsprintf(S,Description,args);
- sprintf(S + strlen(S)," - %s (%i %s)",Function,errno,strerror(errno));
+ vsnprintf(S,sizeof(S),Description,args);
+ snprintf(S + strlen(S),sizeof(S) - strlen(S),
+ " - %s (%i %s)",Function,errno,strerror(errno));
// Put it on the list
Item *Itm = new Item;
@@ -108,8 +109,8 @@ bool GlobalError::WarningE(const char *Function,const char *Description,...)
// sprintf the description
char S[400];
- vsprintf(S,Description,args);
- sprintf(S + strlen(S)," - %s (%i %s)",Function,errno,strerror(errno));
+ vsnprintf(S,sizeof(S),Description,args);
+ snprintf(S + strlen(S),sizeof(S) - strlen(S)," - %s (%i %s)",Function,errno,strerror(errno));
// Put it on the list
Item *Itm = new Item;
@@ -130,7 +131,7 @@ bool GlobalError::Error(const char *Description,...)
// sprintf the description
char S[400];
- vsprintf(S,Description,args);
+ vsnprintf(S,sizeof(S),Description,args);
// Put it on the list
Item *Itm = new Item;
@@ -153,7 +154,7 @@ bool GlobalError::Warning(const char *Description,...)
// sprintf the description
char S[400];
- vsprintf(S,Description,args);
+ vsnprintf(S,sizeof(S),Description,args);
// Put it on the list
Item *Itm = new Item;
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index 9b54b72a5..bb42e73ba 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: error.h,v 1.5 1998/09/18 02:42:41 jgg Exp $
+// $Id: error.h,v 1.6 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
Global Erorr Class - Global error mechanism
@@ -37,7 +37,6 @@
##################################################################### */
/*}}}*/
-// Header section: pkglib
#ifndef PKGLIB_ERROR_H
#define PKGLIB_ERROR_H
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 379641c2c..b65757925 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.16 1998/11/27 04:20:52 jgg Exp $
+// $Id: fileutl.cc,v 1.17 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
File Utilities
@@ -102,8 +102,11 @@ string SafeGetCWD()
// Stash the current dir.
char S[300];
S[0] = 0;
- if (getcwd(S,sizeof(S)) == 0)
+ if (getcwd(S,sizeof(S)-2) == 0)
return "/";
+ unsigned int Len = strlen(S);
+ S[Len] = '/';
+ S[Len+1] = 0;
return S;
}
/*}}}*/
@@ -263,6 +266,17 @@ bool FileFd::Seek(unsigned long To)
return true;
}
/*}}}*/
+// FileFd::Tell - Current seek position /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+unsigned long FileFd::Tell()
+{
+ off_t Res = lseek(iFd,0,SEEK_CUR);
+ if (Res == (off_t)-1)
+ _error->Errno("lseek","Failed to determine the current file position");
+ return Res;
+}
+ /*}}}*/
// FileFd::Size - Return the size of the file /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 0c477caf0..f35cf04d6 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.h,v 1.11 1998/12/08 05:24:43 jgg Exp $
+// $Id: fileutl.h,v 1.12 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
File Utilities
@@ -18,7 +18,6 @@
##################################################################### */
/*}}}*/
-// Header section: pkglib
#ifndef PKGLIB_FILEUTL_H
#define PKGLIB_FILEUTL_H
@@ -43,6 +42,7 @@ class FileFd
bool Read(void *To,unsigned long Size);
bool Write(const void *From,unsigned long Size);
bool Seek(unsigned long To);
+ unsigned long Tell();
unsigned long Size();
bool Close();
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index 84863f7c0..9cfa6ae72 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: md5.h,v 1.2 1998/11/25 23:54:45 jgg Exp $
+// $Id: md5.h,v 1.3 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
MD5SumValue - Storage for a MD5Sum
@@ -39,9 +39,13 @@ class MD5SumValue
// Accessors
bool operator ==(const MD5SumValue &rhs) const;
string Value() const;
- inline operator string() const {return Value();};
+ inline void Value(unsigned char S[16])
+ {for (int I = 0; I != sizeof(Sum); I++) S[I] = Sum[I];};
+ inline operator string() const {return Value();};
bool Set(string Str);
-
+ inline void Set(unsigned char S[16])
+ {for (int I = 0; I != sizeof(Sum); I++) Sum[I] = S[I];};
+
MD5SumValue(string Str);
MD5SumValue();
};
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index 682024789..3cb6c6468 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: mmap.h,v 1.7 1998/11/12 03:14:40 jgg Exp $
+// $Id: mmap.h,v 1.8 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
MMap Class - Provides 'real' mmap or a faked mmap using read().
@@ -22,7 +22,6 @@
##################################################################### */
/*}}}*/
-// Header section: pkglib
#ifndef PKGLIB_MMAP_H
#define PKGLIB_MMAP_H
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index 094c4b016..f09545156 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: progress.h,v 1.4 1998/10/02 04:39:54 jgg Exp $
+// $Id: progress.h,v 1.5 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
OpProgress - Operation Progress
@@ -18,7 +18,6 @@
##################################################################### */
/*}}}*/
-// Header section: pkglib
#ifndef PKGLIB_PROGRESS_H
#define PKGLIB_PROGRESS_H
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index a05359f82..6a90b2b88 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.16 1998/12/31 05:45:26 jgg Exp $
+// $Id: strutl.cc,v 1.17 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -189,7 +189,7 @@ string QuoteString(string Str,const char *Bad)
*I <= 0x20 || *I >= 0x7F)
{
char Buf[10];
- sprintf(Buf,"%%%02x",(unsigned int)((unsigned char)*I));
+ sprintf(Buf,"%%%02x",(int)*I);
Res += Buf;
}
else
@@ -214,7 +214,7 @@ string SizeToStr(double Size)
/* bytes, KiloBytes, MegaBytes, GigaBytes, TeraBytes, PetaBytes,
ExaBytes, ZettaBytes, YottaBytes */
- char Ext[] = {'b','k','M','G','T','P','E','Z','Y'};
+ char Ext[] = {'\0','k','M','G','T','P','E','Z','Y'};
int I = 0;
while (I <= 8)
{
@@ -456,6 +456,7 @@ int StringToBool(string Text,int Default = -1)
if (strcasecmp(Text.c_str(),"no") == 0 ||
strcasecmp(Text.c_str(),"false") == 0 ||
strcasecmp(Text.c_str(),"without") == 0 ||
+ strcasecmp(Text.c_str(),"off") == 0 ||
strcasecmp(Text.c_str(),"disable") == 0)
return 0;
@@ -463,6 +464,7 @@ int StringToBool(string Text,int Default = -1)
if (strcasecmp(Text.c_str(),"yes") == 0 ||
strcasecmp(Text.c_str(),"true") == 0 ||
strcasecmp(Text.c_str(),"with") == 0 ||
+ strcasecmp(Text.c_str(),"on") == 0 ||
strcasecmp(Text.c_str(),"enable") == 0)
return 1;
diff --git a/apt-pkg/contrib/system.h b/apt-pkg/contrib/system.h
index e652348b0..325576dbf 100644
--- a/apt-pkg/contrib/system.h
+++ b/apt-pkg/contrib/system.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: system.h,v 1.1 1998/07/02 02:58:13 jgg Exp $
+// $Id: system.h,v 1.2 1999/01/18 06:20:08 jgg Exp $
/* ######################################################################
System Header - Usefull private definitions
@@ -11,7 +11,6 @@
##################################################################### */
/*}}}*/
// Private header
-// Header section: /
#ifndef SYSTEM_H
#define SYSTEM_H