diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:52:26 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:52:26 +0000 |
commit | 7f25bdff3a0fa55ba897964d5c82475b45f3325a (patch) | |
tree | 7190f1448161be6bfd163cdd88efee6101e1ae8c | |
parent | a9975068c7d55b2fbe46aacf94a36b460fd1d9da (diff) |
Dsync merge
Author: jgg
Date: 1999-01-18 06:20:07 GMT
Dsync merge
-rw-r--r-- | apt-pkg/contrib/cmndline.cc | 11 | ||||
-rw-r--r-- | apt-pkg/contrib/cmndline.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/configuration.cc | 61 | ||||
-rw-r--r-- | apt-pkg/contrib/configuration.h | 10 | ||||
-rw-r--r-- | apt-pkg/contrib/error.cc | 15 | ||||
-rw-r--r-- | apt-pkg/contrib/error.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 18 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/md5.h | 10 | ||||
-rw-r--r-- | apt-pkg/contrib/mmap.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/progress.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 8 | ||||
-rw-r--r-- | apt-pkg/contrib/system.h | 3 | ||||
-rw-r--r-- | methods/file.cc | 6 |
14 files changed, 96 insertions, 62 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 diff --git a/methods/file.cc b/methods/file.cc index 1b3183f05..f2bcf371a 100644 --- a/methods/file.cc +++ b/methods/file.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: file.cc,v 1.6 1998/11/14 01:39:49 jgg Exp $ +// $Id: file.cc,v 1.7 1999/01/18 06:20:08 jgg Exp $ /* ###################################################################### File URI method for APT @@ -37,7 +37,9 @@ bool FileMethod::Fetch(FetchItem *Itm) URI Get = Itm->Uri; string File = Get.Path; FetchResult Res; - + if (Get.Host.empty() == false) + return _error->Error("Invalid URI, local URIS must not start with //"); + // See if the file exists struct stat Buf; if (stat(File.c_str(),&Buf) == 0) |