]> git.saurik.com Git - apt.git/commitdiff
Dsync merge
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:52:26 +0000 (16:52 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:52:26 +0000 (16:52 +0000)
Author: jgg
Date: 1999-01-18 06:20:07 GMT
Dsync merge

14 files changed:
apt-pkg/contrib/cmndline.cc
apt-pkg/contrib/cmndline.h
apt-pkg/contrib/configuration.cc
apt-pkg/contrib/configuration.h
apt-pkg/contrib/error.cc
apt-pkg/contrib/error.h
apt-pkg/contrib/fileutl.cc
apt-pkg/contrib/fileutl.h
apt-pkg/contrib/md5.h
apt-pkg/contrib/mmap.h
apt-pkg/contrib/progress.h
apt-pkg/contrib/strutl.cc
apt-pkg/contrib/system.h
methods/file.cc

index 629b8e9e5c099e94cc2f9e0356d726f01cf410d9..ccacb96096c1bc1eeb401237b64cd6cdfc9c6ebd 100644 (file)
@@ -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;
    }
    
index 40d7f08bad65582d285725dbbd327eaeb5c5f894..e611cd6372f30fbc72799b7450402b81f565b97a 100644 (file)
@@ -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
 
index da026f0f62a59fb4f7f701930d89d98667c2e8bc..e03001f84a9226bd9f5c37fd3e28bfab4528697a 100644 (file)
@@ -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
index c5c32ef2f7325bd497463f0e46a8612dfae543d3..adda854cbacf648180a93fe7aa22c14b28b7cd0b 100644 (file)
@@ -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
    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
 
index bbd081d50650b5e7fc3e41aa93d103557c3afe45..8ae2686de8da19dfc626269d0204b2323dcbebcb 100644 (file)
@@ -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;
index 9b54b72a5633e78ba143bf4c4c3046dc47147cc6..bb42e73ba641ab37bfbc3d648349a9768960675a 100644 (file)
@@ -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
 
index 379641c2c72d7bfa627908a710370f602821ffd0..b65757925695809ba7329d63d0bbf64b5240b1b3 100644 (file)
@@ -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                          /*{{{*/
 // ---------------------------------------------------------------------
 /* */
index 0c477caf0351affef20de3733ef643ea8da9490d..f35cf04d69116b038cdc60a350797d929699115a 100644 (file)
@@ -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();
 
index 84863f7c085abfd483a4729ee0a302d142d76e48..9cfa6ae7286bf68e2f21208f1fc58b10fee0bab8 100644 (file)
@@ -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();
 };
index 6820247895d3aeb23a3543cd208192b79ec1cfe7..3cb6c646898a51c09001a2f3e4e39d7d3320c5e2 100644 (file)
@@ -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
 
index 094c4b016d2889883f27a15edd0cf688fc14501c..f095451560cebcc3a4202aeed90320b2daa25afd 100644 (file)
@@ -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
 
index a05359f825914d3c0cf0a9986c0fd403ea3a9978..6a90b2b8803ab9debca1d87c654d3613c7b69287 100644 (file)
@@ -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;
    
index e652348b07b243553282ca1f528a3480736ede69..325576dbf17899fcbbd6e27f552cb06579721ad3 100644 (file)
@@ -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
 
index 1b3183f05989fa08f05005ca4a8140c444d591d2..f2bcf371a1fa6e1386fbf9a1bcb6b5118a972439 100644 (file)
@@ -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)