]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/sourcelist.cc
Full translation for 0.5.4.9 (new, Greek)
[apt.git] / apt-pkg / sourcelist.cc
index 51289a43d1af6da05f3765c6af2145ce4b97d6d2..12db63079caaad1e17a7f5565afa827bd5920d8c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: sourcelist.cc,v 1.19 2001/03/13 06:51:46 jgg Exp $
+// $Id: sourcelist.cc,v 1.24 2002/07/08 04:18:07 jgg Exp $
 /* ######################################################################
 
    List of Sources
 
 #include <apti18n.h>
 
-#include <fstream.h>
+#include <fstream>
                                                                        /*}}}*/
 
-// Global list of Item supported
+using namespace std;
+
+// Global list of Items supported
 static  pkgSourceList::Type *ItmList[10];
 pkgSourceList::Type **pkgSourceList::Type::GlobalList = ItmList;
 unsigned long pkgSourceList::Type::GlobalListLen = 0;
@@ -126,6 +128,18 @@ pkgSourceList::pkgSourceList(string File)
    Read(File);
 }
                                                                        /*}}}*/
+// SourceList::~pkgSourceList - Destructor                             /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+pkgSourceList::~pkgSourceList()
+{
+   for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+      delete *I;
+   for (vector<Vendor const *>::const_iterator I = VendorList.begin(); 
+       I != VendorList.end(); I++)
+      delete *I;
+}
+                                                                       /*}}}*/
 // SourceList::ReadVendors - Read list of known package vendors                /*{{{*/
 // ---------------------------------------------------------------------
 /* This also scans a directory of vendor files similar to apt.conf.d 
@@ -145,6 +159,11 @@ bool pkgSourceList::ReadVendors()
       if (ReadConfigFile(Cnf,CnfFile,true) == false)
         return false;
 
+   for (vector<Vendor const *>::const_iterator I = VendorList.begin(); 
+       I != VendorList.end(); I++)
+      delete *I;
+   VendorList.erase(VendorList.begin(),VendorList.end());
+   
    // Process 'simple-key' type sections
    const Configuration::Item *Top = Cnf.Tree("simple-key");
    for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
@@ -169,6 +188,31 @@ bool pkgSourceList::ReadVendors()
       VendorList.push_back(Vendor);
    }
 
+   /* XXX Process 'group-key' type sections
+      This is currently faked out so that the vendors file format is
+      parsed but nothing is done with it except check for validity */
+   Top = Cnf.Tree("group-key");
+   for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next)
+   {
+      Configuration Block(Top);
+      Vendor *Vendor;
+      
+      Vendor = new pkgSourceList::Vendor;
+      
+      Vendor->VendorID = Top->Tag;
+      Vendor->Description = Block.Find("Name");
+
+      if (Vendor->Description.empty() == true)
+      {
+         _error->Error(_("Vendor block %s is invalid"), 
+                      Vendor->VendorID.c_str());
+        delete Vendor;
+        continue;
+      }
+      
+      VendorList.push_back(Vendor);
+   }
+   
    return !_error->PendingError();
 }
                                                                        /*}}}*/
@@ -186,10 +230,12 @@ bool pkgSourceList::ReadMainList()
 bool pkgSourceList::Read(string File)
 {
    // Open the stream for reading
-   ifstream F(File.c_str(),ios::in | ios::nocreate);
+   ifstream F(File.c_str(),ios::in /*| ios::nocreate*/);
    if (!F != 0)
       return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str());
    
+   for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++)
+      delete *I;
    SrcList.erase(SrcList.begin(),SrcList.end());
    char Buffer[300];
 
@@ -199,7 +245,10 @@ bool pkgSourceList::Read(string File)
       F.getline(Buffer,sizeof(Buffer));
       CurLine++;
       _strtabexpand(Buffer,sizeof(Buffer));
-      
+      if (F.fail() && !F.eof())
+        return _error->Error(_("Line %u too long in source list %s."),
+                             CurLine,File.c_str());
+
       
       char *I;
       for (I = Buffer; *I != 0 && *I != '#'; I++);