]> git.saurik.com Git - apt.git/commitdiff
* [ABI-Break] Implement EDSP in libapt-pkg so that all front-ends which
authorMichael Vogt <michael.vogt@ubuntu.com>
Wed, 8 Jun 2011 10:17:49 +0000 (12:17 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Wed, 8 Jun 2011 10:17:49 +0000 (12:17 +0200)
* [ABI-Break] merge lp:~mvo/apt/sha512-template to add support for sha512
* [ABI-Break] merge lp:~mvo/apt/dpointer to support easier extending
  without breaking the ABI

21 files changed:
apt-pkg/acquire-worker.h
apt-pkg/acquire.h
apt-pkg/algorithms.h
apt-pkg/cachefile.h
apt-pkg/cachefilter.h
apt-pkg/clean.h
apt-pkg/deb/debindexfile.h
apt-pkg/deb/deblistparser.h
apt-pkg/deb/debmetaindex.h
apt-pkg/deb/debrecords.h
apt-pkg/deb/debsrcrecords.h
apt-pkg/deb/debsystem.cc
apt-pkg/deb/debsystem.h
apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h
apt-pkg/indexcopy.h
apt-pkg/pkgrecords.h
apt-pkg/srcrecords.h
apt-pkg/tagfile.cc
apt-pkg/tagfile.h
debian/changelog

index 06283922e5e4dbe41c951b083d2eefd866ee68e7..62545829a264d28a9618c5d16c321e05557c5048 100644 (file)
@@ -44,6 +44,9 @@
  */
 class pkgAcquire::Worker : public WeakPointable
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+  
    friend class pkgAcquire;
    
    protected:
@@ -314,7 +317,7 @@ class pkgAcquire::Worker : public WeakPointable
     *  Closes the file descriptors; if MethodConfig::NeedsCleanup is
     *  \b false, also rudely interrupts the worker with a SIGINT.
     */
-   ~Worker();
+   virtual ~Worker();
 };
 
 /** @} */
index e3a4435b8d7d913d7a37706d1ebf5dd9d387989e..7db7a99586ddb714756afd3ec83298a598bc5a41 100644 (file)
@@ -91,6 +91,12 @@ class pkgAcquireStatus;
  */
 class pkgAcquire
 {   
+   private:
+   /** \brief FD of the Lock file we acquire in Setup (if any) */
+   int LockFD;
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    public:
    
    class Item;
@@ -359,9 +365,6 @@ class pkgAcquire
     */
    virtual ~pkgAcquire();
 
-   private:
-   /** \brief FD of the Lock file we acquire in Setup (if any) */
-   int LockFD;
 };
 
 /** \brief Represents a single download source from which an item
@@ -391,6 +394,9 @@ class pkgAcquire::Queue
    friend class pkgAcquire::UriIterator;
    friend class pkgAcquire::Worker;
 
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    /** \brief The next queue in the pkgAcquire object's list of queues. */
    Queue *Next;
    
@@ -540,12 +546,15 @@ class pkgAcquire::Queue
    /** Shut down all the worker processes associated with this queue
     *  and empty the queue.
     */
-   ~Queue();
+   virtual ~Queue();
 };
                                                                        /*}}}*/
 /** \brief Iterates over all the URIs being fetched by a pkgAcquire object.    {{{*/
 class pkgAcquire::UriIterator
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    /** The next queue to iterate over. */
    pkgAcquire::Queue *CurQ;
    /** The item that we currently point at. */
@@ -581,11 +590,15 @@ class pkgAcquire::UriIterator
         CurQ = CurQ->Next;
       }
    }   
+   virtual ~UriIterator() {};
 };
                                                                        /*}}}*/
 /** \brief Information about the properties of a single acquire method.        {{{*/
 struct pkgAcquire::MethodConfig
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+   
    /** \brief The next link on the acquire method list.
     *
     *  \todo Why not an STL container?
@@ -634,6 +647,9 @@ struct pkgAcquire::MethodConfig
     *  appropriate.
     */
    MethodConfig();
+
+   /* \brief Destructor, empty currently */
+   virtual ~MethodConfig() {};
 };
                                                                        /*}}}*/
 /** \brief A monitor object for downloads controlled by the pkgAcquire class.  {{{
@@ -644,6 +660,9 @@ struct pkgAcquire::MethodConfig
  */
 class pkgAcquireStatus
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    protected:
    
    /** \brief The last time at which this monitor object was updated. */
index 582cbc527b1c9b4e7d252fae526318319118a0bb..050934badcae91779107a61de54ae2c05cda20e9 100644 (file)
@@ -78,6 +78,9 @@ private:
                                                                        /*}}}*/
 class pkgProblemResolver                                               /*{{{*/
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    pkgDepCache &Cache;
    typedef pkgCache::PkgIterator PkgIterator;
    typedef pkgCache::VerIterator VerIterator;
index 09d3ec2676675c3063f32f5cc016b11eb7d245fe..d07337d387d216b180fc1798c38961fa2a840e9d 100644 (file)
@@ -25,6 +25,9 @@
 
 class pkgCacheFile
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    protected:
    
    MMap *Map;
index e7ab1723fe992e0b54e4e49b1be06d3053688aae..5d426008b26288abb9f83a2f1d671fedfe8ead51 100644 (file)
@@ -16,6 +16,8 @@ namespace APT {
 namespace CacheFilter {
 // PackageNameMatchesRegEx                                             /*{{{*/
 class PackageNameMatchesRegEx {
+         /** \brief dpointer placeholder (for later in case we need it) */
+         void *d;
        regex_t* pattern;
 public:
        PackageNameMatchesRegEx(std::string const &Pattern);
index 2aee2bf54fe31dbd61fe917a50f966653d5cabc3..1ebf68dc94d91fab50a46d3f43457daa45e9735d 100644 (file)
@@ -15,6 +15,9 @@
 
 class pkgArchiveCleaner
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    protected:
    
    virtual void Erase(const char * /*File*/,string /*Pkg*/,string /*Ver*/,struct stat & /*St*/) {};
index 6697c5f26dafb31f7e74aa5f408efa77049cae5d..678c22473253f7415709891ef4ce4091f0609dc0 100644 (file)
@@ -22,6 +22,9 @@
 
 class debStatusIndex : public pkgIndexFile
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    protected:
    string File;
 
@@ -41,10 +44,14 @@ class debStatusIndex : public pkgIndexFile
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
    debStatusIndex(string File);
+   virtual ~debStatusIndex() {};
 };
     
 class debPackagesIndex : public pkgIndexFile
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    string URI;
    string Dist;
    string Section;
@@ -74,10 +81,14 @@ class debPackagesIndex : public pkgIndexFile
 
    debPackagesIndex(string const &URI, string const &Dist, string const &Section,
                        bool const &Trusted, string const &Arch = "native");
+   virtual ~debPackagesIndex() {};
 };
 
 class debTranslationsIndex : public pkgIndexFile
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    string URI;
    string Dist;
    string Section;
@@ -105,10 +116,14 @@ class debTranslationsIndex : public pkgIndexFile
    virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
 
    debTranslationsIndex(string URI,string Dist,string Section, char const * const Language);
+   virtual ~debTranslationsIndex() {};
 };
 
 class debSourcesIndex : public pkgIndexFile
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    string URI;
    string Dist;
    string Section;
@@ -138,6 +153,7 @@ class debSourcesIndex : public pkgIndexFile
    virtual unsigned long Size() const;
    
    debSourcesIndex(string URI,string Dist,string Section,bool Trusted);
+   virtual ~debSourcesIndex() {};
 };
 
 #endif
index 8b8aff788dd0693b17e78198e188a6c369128357..41d712fbfac6b194af4b9983a17f95e6a6c61852 100644 (file)
@@ -26,8 +26,11 @@ class debListParser : public pkgCacheGenerator::ListParser
       unsigned char Val;
    };
 
-   protected:
+   private:
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
 
+   protected:
    pkgTagFile Tags;
    pkgTagSection Section;
    unsigned long iOffset;
@@ -74,6 +77,7 @@ class debListParser : public pkgCacheGenerator::ListParser
    static const char *ConvertRelation(const char *I,unsigned int &Op);
 
    debListParser(FileFd *File, string const &Arch = "");
+   virtual ~debListParser() {};
 };
 
 #endif
index 1561c6e009341a364ab9fd401c47fefd32ec9874..0aaf7f14acf4c6eb7da3808715cf51bd2ec3990b 100644 (file)
@@ -19,12 +19,14 @@ class debReleaseIndex : public metaIndex {
    };
 
    private:
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
    std::map<string, vector<debSectionEntry const*> > ArchEntries;
 
    public:
 
    debReleaseIndex(string const &URI, string const &Dist);
-   ~debReleaseIndex();
+   virtual ~debReleaseIndex();
 
    virtual string ArchiveURI(string const &File) const {return URI + File;};
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
index 05159ea1eaae1caa78d6a015d382dc410863c5b4..9692ac94cfaf4ebd1fc5aa63b811c68fa4e87c7f 100644 (file)
@@ -20,6 +20,9 @@
 
 class debRecordParser : public pkgRecords::Parser
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    FileFd File;
    pkgTagFile Tags;
    pkgTagSection Section;
@@ -50,6 +53,7 @@ class debRecordParser : public pkgRecords::Parser
    virtual void GetRec(const char *&Start,const char *&Stop);
    
    debRecordParser(string FileName,pkgCache &Cache);
+   virtual ~debRecordParser() {};
 };
 
 #endif
index 905264daa0608a7665a5fde3c688f6d14ee292b9..aa859b0e6378f088b4200637be5ff2245107192c 100644 (file)
@@ -18,6 +18,9 @@
 
 class debSrcRecordParser : public pkgSrcRecords::Parser
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    FileFd Fd;
    pkgTagFile Tags;
    pkgTagSection Sect;
@@ -50,7 +53,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    debSrcRecordParser(string const &File,pkgIndexFile const *Index) 
       : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400), 
         Buffer(0), BufSize(0) {}
-   ~debSrcRecordParser();
+   virtual ~debSrcRecordParser();
 };
 
 #endif
index 8619822dffc5e713b34cdeeb88e46a5ca30adbe2..7644bc66bed295f5e063fc180427dd4203664e73 100644 (file)
 
 debSystem debSys;
 
+class debSystemPrivate {
+public:
+   debSystemPrivate() : LockFD(-1), LockCount(0), StatusFile(0)
+   {
+   }
+   // For locking support
+   int LockFD;
+   unsigned LockCount;
+   
+   debStatusIndex *StatusFile;
+};
+
 // System::debSystem - Constructor                                     /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 debSystem::debSystem()
 {
-   LockFD = -1;
-   LockCount = 0;
-   StatusFile = 0;
-   
+   d = new debSystemPrivate();
    Label = "Debian dpkg interface";
    VS = &debVS;
 }
@@ -44,7 +53,8 @@ debSystem::debSystem()
 /* */
 debSystem::~debSystem()
 {
-   delete StatusFile;
+   delete d->StatusFile;
+   delete d;
 }
                                                                        /*}}}*/
 // System::Lock - Get the lock                                         /*{{{*/
@@ -54,16 +64,16 @@ debSystem::~debSystem()
 bool debSystem::Lock()
 {
    // Disable file locking
-   if (_config->FindB("Debug::NoLocking",false) == true || LockCount > 1)
+   if (_config->FindB("Debug::NoLocking",false) == true || d->LockCount > 1)
    {
-      LockCount++;
+      d->LockCount++;
       return true;
    }
 
    // Create the lockfile
    string AdminDir = flNotFile(_config->Find("Dir::State::status"));
-   LockFD = GetLock(AdminDir + "lock");
-   if (LockFD == -1)
+   d->LockFD = GetLock(AdminDir + "lock");
+   if (d->LockFD == -1)
    {
       if (errno == EACCES || errno == EAGAIN)
         return _error->Error(_("Unable to lock the administration directory (%s), "
@@ -76,8 +86,8 @@ bool debSystem::Lock()
    // See if we need to abort with a dirty journal
    if (CheckUpdates() == true)
    {
-      close(LockFD);
-      LockFD = -1;
+      close(d->LockFD);
+      d->LockFD = -1;
       const char *cmd;
       if (getenv("SUDO_USER") != NULL)
         cmd = "sudo dpkg --configure -a";
@@ -89,7 +99,7 @@ bool debSystem::Lock()
                              "run '%s' to correct the problem. "), cmd);
    }
 
-        LockCount++;
+        d->LockCount++;
       
    return true;
 }
@@ -99,15 +109,15 @@ bool debSystem::Lock()
 /* */
 bool debSystem::UnLock(bool NoErrors)
 {
-   if (LockCount == 0 && NoErrors == true)
+   if (d->LockCount == 0 && NoErrors == true)
       return false;
    
-   if (LockCount < 1)
+   if (d->LockCount < 1)
       return _error->Error(_("Not locked"));
-   if (--LockCount == 0)
+   if (--d->LockCount == 0)
    {
-      close(LockFD);
-      LockCount = 0;
+      close(d->LockFD);
+      d->LockCount = 0;
    }
    
    return true;
@@ -168,9 +178,9 @@ bool debSystem::Initialize(Configuration &Cnf)
    Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status");
    Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
 
-   if (StatusFile) {
-     delete StatusFile;
-     StatusFile = 0;
+   if (d->StatusFile) {
+     delete d->StatusFile;
+     d->StatusFile = 0;
    }
 
    return true;
@@ -208,9 +218,9 @@ signed debSystem::Score(Configuration const &Cnf)
 /* */
 bool debSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
 {
-   if (StatusFile == 0)
-      StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status"));
-   List.push_back(StatusFile);
+   if (d->StatusFile == 0)
+      d->StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status"));
+   List.push_back(d->StatusFile);
    return true;
 }
                                                                        /*}}}*/
@@ -220,11 +230,11 @@ bool debSystem::AddStatusFiles(vector<pkgIndexFile *> &List)
 bool debSystem::FindIndex(pkgCache::PkgFileIterator File,
                          pkgIndexFile *&Found) const
 {
-   if (StatusFile == 0)
+   if (d->StatusFile == 0)
       return false;
-   if (StatusFile->FindInCache(*File.Cache()) == File)
+   if (d->StatusFile->FindInCache(*File.Cache()) == File)
    {
-      Found = StatusFile;
+      Found = d->StatusFile;
       return true;
    }
    
index 5f9995e5dc7c9716cc0d97ee09fdb0469c778235..23215525675761dbdb81552bb276e34efb374786 100644 (file)
 
 #include <apt-pkg/pkgsystem.h>
 
+class debSystemPrivate;
+
 class debStatusIndex;
 class debSystem : public pkgSystem
 {
-   // For locking support
-   int LockFD;
-   unsigned LockCount;
+   // private d-pointer
+   debSystemPrivate *d;
    bool CheckUpdates();
-   
-   debStatusIndex *StatusFile;
-   
+
    public:
 
    virtual bool Lock();
@@ -35,7 +34,7 @@ class debSystem : public pkgSystem
                          pkgIndexFile *&Found) const;
 
    debSystem();
-   ~debSystem();
+   virtual ~debSystem();
 };
 
 extern debSystem debSys;
index b37980b7ecbbdae96d210bb6ffca6a700c94d23b..cd7c4e5d589c048f8fb6bfac7a44b2eb48a7925a 100644 (file)
 
 using namespace std;
 
+class pkgDPkgPMPrivate 
+{
+public:
+   pkgDPkgPMPrivate() : dpkgbuf_pos(0), term_out(NULL), history_out(NULL)
+   {
+   }
+   bool stdin_is_dev_null;
+   // the buffer we use for the dpkg status-fd reading
+   char dpkgbuf[1024];
+   int dpkgbuf_pos;
+   FILE *term_out;
+   FILE *history_out;
+   string dpkg_error;
+};
+
 namespace
 {
   // Maps the dpkg "processing" info to human readable names.  Entry 0
@@ -108,9 +123,9 @@ ionice(int PID)
 // ---------------------------------------------------------------------
 /* */
 pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache) 
-   : pkgPackageManager(Cache), dpkgbuf_pos(0),
-     term_out(NULL), history_out(NULL), PackagesDone(0), PackagesTotal(0)
+   : pkgPackageManager(Cache), PackagesDone(0), PackagesTotal(0)
 {
+   d = new pkgDPkgPMPrivate();
 }
                                                                        /*}}}*/
 // DPkgPM::pkgDPkgPM - Destructor                                      /*{{{*/
@@ -118,6 +133,7 @@ pkgDPkgPM::pkgDPkgPM(pkgDepCache *Cache)
 /* */
 pkgDPkgPM::~pkgDPkgPM()
 {
+   delete d;
 }
                                                                        /*}}}*/
 // DPkgPM::Install - Install a package                                 /*{{{*/
@@ -374,7 +390,7 @@ void pkgDPkgPM::DoStdin(int master)
    if (len)
       write(master, input_buf, len);
    else
-      stdin_is_dev_null = true;
+      d->stdin_is_dev_null = true;
 }
                                                                        /*}}}*/
 // DPkgPM::DoTerminalPty - Read the terminal pty and write log         /*{{{*/
@@ -399,8 +415,8 @@ void pkgDPkgPM::DoTerminalPty(int master)
    if(len <= 0) 
       return;
    write(1, term_buf, len);
-   if(term_out)
-      fwrite(term_buf, len, sizeof(char), term_out);
+   if(d->term_out)
+      fwrite(term_buf, len, sizeof(char), d->term_out);
 }
                                                                        /*}}}*/
 // DPkgPM::ProcessDpkgStatusBuf                                                /*{{{*/
@@ -604,14 +620,14 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd)
    char *p, *q;
    int len;
 
-   len=read(statusfd, &dpkgbuf[dpkgbuf_pos], sizeof(dpkgbuf)-dpkgbuf_pos);
-   dpkgbuf_pos += len;
+   len=read(statusfd, &d->dpkgbuf[d->dpkgbuf_pos], sizeof(d->dpkgbuf)-d->dpkgbuf_pos);
+   d->dpkgbuf_pos += len;
    if(len <= 0)
       return;
 
    // process line by line if we have a buffer
-   p = q = dpkgbuf;
-   while((q=(char*)memchr(p, '\n', dpkgbuf+dpkgbuf_pos-p)) != NULL)
+   p = q = d->dpkgbuf;
+   while((q=(char*)memchr(p, '\n', d->dpkgbuf+d->dpkgbuf_pos-p)) != NULL)
    {
       *q = 0;
       ProcessDpkgStatusLine(OutStatusFd, p);
@@ -619,8 +635,8 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd)
    }
 
    // now move the unprocessed bits (after the final \n that is now a 0x0) 
-   // to the start and update dpkgbuf_pos
-   p = (char*)memrchr(dpkgbuf, 0, dpkgbuf_pos);
+   // to the start and update d->dpkgbuf_pos
+   p = (char*)memrchr(d->dpkgbuf, 0, d->dpkgbuf_pos);
    if(p == NULL)
       return;
 
@@ -628,8 +644,8 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd)
    p++;
 
    // move the unprocessed tail to the start and update pos
-   memmove(dpkgbuf, p, p-dpkgbuf);
-   dpkgbuf_pos = dpkgbuf+dpkgbuf_pos-p;
+   memmove(d->dpkgbuf, p, p-d->dpkgbuf);
+   d->dpkgbuf_pos = d->dpkgbuf+d->dpkgbuf_pos-p;
 }
                                                                        /*}}}*/
 // DPkgPM::WriteHistoryTag                                             /*{{{*/
@@ -641,7 +657,7 @@ void pkgDPkgPM::WriteHistoryTag(string const &tag, string value)
    // poor mans rstrip(", ")
    if (value[length-2] == ',' && value[length-1] == ' ')
       value.erase(length - 2, 2);
-   fprintf(history_out, "%s: %s\n", tag.c_str(), value.c_str());
+   fprintf(d->history_out, "%s: %s\n", tag.c_str(), value.c_str());
 }                                                                      /*}}}*/
 // DPkgPM::OpenLog                                                     /*{{{*/
 bool pkgDPkgPM::OpenLog()
@@ -662,13 +678,13 @@ bool pkgDPkgPM::OpenLog()
                                   _config->Find("Dir::Log::Terminal"));
    if (!logfile_name.empty())
    {
-      term_out = fopen(logfile_name.c_str(),"a");
-      if (term_out == NULL)
+      d->term_out = fopen(logfile_name.c_str(),"a");
+      if (d->term_out == NULL)
         return _error->WarningE("OpenLog", _("Could not open file '%s'"), logfile_name.c_str());
-      setvbuf(term_out, NULL, _IONBF, 0);
-      SetCloseExec(fileno(term_out), true);
+      setvbuf(d->term_out, NULL, _IONBF, 0);
+      SetCloseExec(fileno(d->term_out), true);
       chmod(logfile_name.c_str(), 0600);
-      fprintf(term_out, "\nLog started: %s\n", timestr);
+      fprintf(d->term_out, "\nLog started: %s\n", timestr);
    }
 
    // write your history
@@ -676,11 +692,11 @@ bool pkgDPkgPM::OpenLog()
                                   _config->Find("Dir::Log::History"));
    if (!history_name.empty())
    {
-      history_out = fopen(history_name.c_str(),"a");
-      if (history_out == NULL)
+      d->history_out = fopen(history_name.c_str(),"a");
+      if (d->history_out == NULL)
         return _error->WarningE("OpenLog", _("Could not open file '%s'"), history_name.c_str());
       chmod(history_name.c_str(), 0644);
-      fprintf(history_out, "\nStart-Date: %s\n", timestr);
+      fprintf(d->history_out, "\nStart-Date: %s\n", timestr);
       string remove, purge, install, upgrade, downgrade;
       for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       {
@@ -710,7 +726,7 @@ bool pkgDPkgPM::OpenLog()
       WriteHistoryTag("Downgrade",downgrade);
       WriteHistoryTag("Remove",remove);
       WriteHistoryTag("Purge",purge);
-      fflush(history_out);
+      fflush(d->history_out);
    }
    
    return true;
@@ -724,16 +740,16 @@ bool pkgDPkgPM::CloseLog()
    struct tm *tmp = localtime(&t);
    strftime(timestr, sizeof(timestr), "%F  %T", tmp);
 
-   if(term_out)
+   if(d->term_out)
    {
-      fprintf(term_out, "Log ended: ");
-      fprintf(term_out, "%s", timestr);
-      fprintf(term_out, "\n");
-      fclose(term_out);
+      fprintf(d->term_out, "Log ended: ");
+      fprintf(d->term_out, "%s", timestr);
+      fprintf(d->term_out, "\n");
+      fclose(d->term_out);
    }
-   term_out = NULL;
+   d->term_out = NULL;
 
-   if(history_out)
+   if(d->history_out)
    {
       if (disappearedPkgs.empty() == false)
       {
@@ -750,12 +766,12 @@ bool pkgDPkgPM::CloseLog()
         }
         WriteHistoryTag("Disappeared", disappear);
       }
-      if (dpkg_error.empty() == false)
-        fprintf(history_out, "Error: %s\n", dpkg_error.c_str());
-      fprintf(history_out, "End-Date: %s\n", timestr);
-      fclose(history_out);
+      if (d->dpkg_error.empty() == false)
+        fprintf(d->history_out, "Error: %s\n", d->dpkg_error.c_str());
+      fprintf(d->history_out, "End-Date: %s\n", timestr);
+      fclose(d->history_out);
    }
-   history_out = NULL;
+   d->history_out = NULL;
 
    return true;
 }
@@ -863,7 +879,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       }
    }
 
-   stdin_is_dev_null = false;
+   d->stdin_is_dev_null = false;
 
    // create log
    OpenLog();
@@ -1063,8 +1079,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
            const char *s = _("Can not write log, openpty() "
                              "failed (/dev/pts not mounted?)\n");
            fprintf(stderr, "%s",s);
-            if(term_out)
-              fprintf(term_out, "%s",s);
+            if(d->term_out)
+              fprintf(d->term_out, "%s",s);
            master = slave = -1;
         }  else {
            struct termios rtt;
@@ -1194,7 +1210,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 
         // wait for input or output here
         FD_ZERO(&rfds);
-        if (master >= 0 && !stdin_is_dev_null)
+        if (master >= 0 && !d->stdin_is_dev_null)
            FD_SET(0, &rfds); 
         FD_SET(_dpkgin, &rfds);
         if(master >= 0)
@@ -1248,14 +1264,14 @@ bool pkgDPkgPM::Go(int OutStatusFd)
            RunScripts("DPkg::Post-Invoke");
 
         if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) 
-           strprintf(dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]);
+           strprintf(d->dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]);
         else if (WIFEXITED(Status) != 0)
-           strprintf(dpkg_error, "Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
+           strprintf(d->dpkg_error, "Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
         else 
-           strprintf(dpkg_error, "Sub-process %s exited unexpectedly",Args[0]);
+           strprintf(d->dpkg_error, "Sub-process %s exited unexpectedly",Args[0]);
 
-        if(dpkg_error.size() > 0)
-           _error->Error("%s", dpkg_error.c_str());
+        if(d->dpkg_error.size() > 0)
+           _error->Error("%s", d->dpkg_error.c_str());
 
         if(stopOnError) 
         {
@@ -1402,8 +1418,8 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
    fprintf(report, "ErrorMessage:\n %s\n", errormsg);
 
    // ensure that the log is flushed
-   if(term_out)
-      fflush(term_out);
+   if(d->term_out)
+      fflush(d->term_out);
 
    // attach terminal log it if we have it
    string logfile_name = _config->FindFile("Dir::Log::Terminal");
index b7b5a6def6243f877cf3056fa78901fe6a054fc1..ddf9485c746d2d9f9a0f949a815d07a1b46fa72e 100644 (file)
 using std::vector;
 using std::map;
 
+class pkgDPkgPMPrivate;
 
 class pkgDPkgPM : public pkgPackageManager
 {
    private:
-
-   bool stdin_is_dev_null;
-
-   // the buffer we use for the dpkg status-fd reading
-   char dpkgbuf[1024];
-   int dpkgbuf_pos;
-   FILE *term_out;
-   FILE *history_out;
-   string dpkg_error;
+   pkgDPkgPMPrivate *d;
 
    /** \brief record the disappear action and handle accordingly
 
index 6fcd3b8ce4e1a110c9efd9639931d5233de0f78e..277fb561c0b3410efa34da2b87b5279a29e8d3d3 100644 (file)
@@ -24,6 +24,9 @@ class pkgCdromStatus;
 
 class IndexCopy                                                                /*{{{*/
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    protected:
    
    pkgTagSection *Section;
@@ -55,7 +58,6 @@ class PackageCopy : public IndexCopy                                  /*{{{*/
    virtual const char *GetFileName() {return "Packages";};
    virtual const char *Type() {return "Package";};
    
-   public:
 };
                                                                        /*}}}*/
 class SourceCopy : public IndexCopy                                    /*{{{*/
@@ -67,7 +69,6 @@ class SourceCopy : public IndexCopy                                   /*{{{*/
    virtual const char *GetFileName() {return "Sources";};
    virtual const char *Type() {return "Source";};
    
-   public:
 };
                                                                        /*}}}*/
 class TranslationsCopy                                                 /*{{{*/
@@ -82,6 +83,9 @@ class TranslationsCopy                                                        /*{{{*/
                                                                        /*}}}*/
 class SigVerify                                                                /*{{{*/
 {
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
+
    bool Verify(string prefix,string file, indexRecords *records);
    bool CopyMetaIndex(string CDROM, string CDName, 
                      string prefix, string file);
index 2d994211db38ae1f7c1306d03f0af43d3b5cfd6e..78e39e577cf0cf18af4d44921b7425cf619cec1b 100644 (file)
@@ -28,12 +28,13 @@ class pkgRecords                                                    /*{{{*/
    class Parser;
    
    private:
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
    
    pkgCache &Cache;
    std::vector<Parser *>Files;
 
-   public:
-
+    public:
    // Lookup function
    Parser &Lookup(pkgCache::VerFileIterator const &Ver);
    Parser &Lookup(pkgCache::DescFileIterator const &Desc);
index a495338648f324de010f985d6c60f67eb965f84c..8a78d77112258eaddf567ab45c377973313d67ae 100644 (file)
@@ -79,6 +79,8 @@ class pkgSrcRecords
    };
    
    private:
+   /** \brief dpointer placeholder (for later in case we need it) */
+   void *d;
    
    // The list of files and the current parser pointer
    vector<Parser*> Files;
@@ -93,7 +95,7 @@ class pkgSrcRecords
    Parser *Find(const char *Package,bool const &SrcOnly = false);
    
    pkgSrcRecords(pkgSourceList &List);
-   ~pkgSrcRecords();
+   virtual ~pkgSrcRecords();
 };
 
 #endif
index b7245073d3152237d22f36e95fea31244d797316..a8f04b23af304654b4d011a217c1290c2e0aac8a 100644 (file)
 
 using std::string;
 
+class pkgTagFilePrivate
+{
+public:
+   pkgTagFilePrivate(FileFd *pFd, unsigned long Size) : Fd(*pFd), Size(Size)
+   {
+   }
+   FileFd &Fd;
+   char *Buffer;
+   char *Start;
+   char *End;
+   bool Done;
+   unsigned long iOffset;
+   unsigned long Size;
+};
+
 // TagFile::pkgTagFile - Constructor                                   /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) :
-     Fd(*pFd),
-     Size(Size)
+pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size)
 {
-   if (Fd.IsOpen() == false)
+   d = new pkgTagFilePrivate(pFd, Size);
+
+   if (d->Fd.IsOpen() == false)
    {
-      Buffer = 0;
-      Start = End = Buffer = 0;
-      Done = true;
-      iOffset = 0;
+      d->Start = d->End = d->Buffer = 0;
+      d->Done = true;
+      d->iOffset = 0;
       return;
    }
    
-   Buffer = new char[Size];
-   Start = End = Buffer;
-   Done = false;
-   iOffset = 0;
+   d->Buffer = new char[Size];
+   d->Start = d->End = d->Buffer;
+   d->Done = false;
+   d->iOffset = 0;
    Fill();
 }
                                                                        /*}}}*/
@@ -52,7 +66,14 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) :
 /* */
 pkgTagFile::~pkgTagFile()
 {
-   delete [] Buffer;
+   delete [] d->Buffer;
+   delete d;
+}
+                                                                       /*}}}*/
+// TagFile::Offset - Return the current offset in the buffer           /*{{{*/
+unsigned long pkgTagFile::Offset()
+{
+   return d->iOffset;
 }
                                                                        /*}}}*/
 // TagFile::Resize - Resize the internal buffer                                /*{{{*/
@@ -63,22 +84,22 @@ pkgTagFile::~pkgTagFile()
 bool pkgTagFile::Resize()
 {
    char *tmp;
-   unsigned long EndSize = End - Start;
+   unsigned long EndSize = d->End - d->Start;
 
    // fail is the buffer grows too big
-   if(Size > 1024*1024+1)
+   if(d->Size > 1024*1024+1)
       return false;
 
    // get new buffer and use it
-   tmp = new char[2*Size];
-   memcpy(tmp, Buffer, Size);
-   Size = Size*2;
-   delete [] Buffer;
-   Buffer = tmp;
+   tmp = new char[2*d->Size];
+   memcpy(tmp, d->Buffer, d->Size);
+   d->Size = d->Size*2;
+   delete [] d->Buffer;
+   d->Buffer = tmp;
 
    // update the start/end pointers to the new buffer
-   Start = Buffer;
-   End = Start + EndSize;
+   d->Start = d->Buffer;
+   d->End = d->Start + EndSize;
    return true;
 }
                                                                        /*}}}*/
@@ -90,20 +111,20 @@ bool pkgTagFile::Resize()
  */
 bool pkgTagFile::Step(pkgTagSection &Tag)
 {
-   while (Tag.Scan(Start,End - Start) == false)
+   while (Tag.Scan(d->Start,d->End - d->Start) == false)
    {
       if (Fill() == false)
         return false;
       
-      if(Tag.Scan(Start,End - Start))
+      if(Tag.Scan(d->Start,d->End - d->Start))
         break;
 
       if (Resize() == false)
         return _error->Error(_("Unable to parse package file %s (1)"),
-                                Fd.Name().c_str());
+                              d->Fd.Name().c_str());
    }
-   Start += Tag.size();
-   iOffset += Tag.size();
+   d->Start += Tag.size();
+   d->iOffset += Tag.size();
 
    Tag.Trim();
    return true;
@@ -115,37 +136,37 @@ bool pkgTagFile::Step(pkgTagSection &Tag)
    then fills the rest from the file */
 bool pkgTagFile::Fill()
 {
-   unsigned long EndSize = End - Start;
+   unsigned long EndSize = d->End - d->Start;
    unsigned long Actual = 0;
    
-   memmove(Buffer,Start,EndSize);
-   Start = Buffer;
-   End = Buffer + EndSize;
+   memmove(d->Buffer,d->Start,EndSize);
+   d->Start = d->Buffer;
+   d->End = d->Buffer + EndSize;
    
-   if (Done == false)
+   if (d->Done == false)
    {
       // See if only a bit of the file is left
-      if (Fd.Read(End,Size - (End - Buffer),&Actual) == false)
+      if (d->Fd.Read(d->End, d->Size - (d->End - d->Buffer),&Actual) == false)
         return false;
-      if (Actual != Size - (End - Buffer))
-        Done = true;
-      End += Actual;
+      if (Actual != d->Size - (d->End - d->Buffer))
+        d->Done = true;
+      d->End += Actual;
    }
    
-   if (Done == true)
+   if (d->Done == true)
    {
       if (EndSize <= 3 && Actual == 0)
         return false;
-      if (Size - (End - Buffer) < 4)
+      if (d->Size - (d->End - d->Buffer) < 4)
         return true;
       
       // Append a double new line if one does not exist
       unsigned int LineCount = 0;
-      for (const char *E = End - 1; E - End < 6 && (*E == '\n' || *E == '\r'); E--)
+      for (const char *E = d->End - 1; E - d->End < 6 && (*E == '\n' || *E == '\r'); E--)
         if (*E == '\n')
            LineCount++;
       for (; LineCount < 2; LineCount++)
-        *End++ = '\n';
+        *d->End++ = '\n';
       
       return true;
    }
@@ -160,33 +181,33 @@ bool pkgTagFile::Fill()
 bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
 {
    // We are within a buffer space of the next hit..
-   if (Offset >= iOffset && iOffset + (End - Start) > Offset)
+   if (Offset >= d->iOffset && d->iOffset + (d->End - d->Start) > Offset)
    {
-      unsigned long Dist = Offset - iOffset;
-      Start += Dist;
-      iOffset += Dist;
+      unsigned long Dist = Offset - d->iOffset;
+      d->Start += Dist;
+      d->iOffset += Dist;
       return Step(Tag);
    }
 
    // Reposition and reload..
-   iOffset = Offset;
-   Done = false;
-   if (Fd.Seek(Offset) == false)
+   d->iOffset = Offset;
+   d->Done = false;
+   if (d->Fd.Seek(Offset) == false)
       return false;
-   End = Start = Buffer;
+   d->End = d->Start = d->Buffer;
    
    if (Fill() == false)
       return false;
 
-   if (Tag.Scan(Start,End - Start) == true)
+   if (Tag.Scan(d->Start, d->End - d->Start) == true)
       return true;
    
    // This appends a double new line (for the real eof handling)
    if (Fill() == false)
       return false;
    
-   if (Tag.Scan(Start,End - Start) == false)
-      return _error->Error(_("Unable to parse package file %s (2)"),Fd.Name().c_str());
+   if (Tag.Scan(d->Start, d->End - d->Start) == false)
+      return _error->Error(_("Unable to parse package file %s (2)"),d->Fd.Name().c_str());
    
    return true;
 }
index 61491aa047adeb5572835cc9f7a9ef0b2931c52b..23f5c57e6df33361df220bea05dd40610a98b483 100644 (file)
 
 #include <apt-pkg/fileutl.h>
 #include <stdio.h>
-    
+
 class pkgTagSection
 {
    const char *Section;
-   
    // We have a limit of 256 tags per section.
    unsigned int Indexes[256];
    unsigned int AlphaIndexes[0x100];
-   
    unsigned int TagCount;
+   // dpointer placeholder (for later in case we need it)
+   void *d;
 
    /* This very simple hash function for the last 8 letters gives
       very good performance on the debian package files */
@@ -44,7 +44,6 @@ class pkgTagSection
       return Res & 0xFF;
    }
 
-
    protected:
    const char *Stop;
 
@@ -80,17 +79,13 @@ class pkgTagSection
    };
    
    pkgTagSection() : Section(0), Stop(0) {};
+   virtual ~pkgTagSection() {};
 };
 
+class pkgTagFilePrivate;
 class pkgTagFile
 {
-   FileFd &Fd;
-   char *Buffer;
-   char *Start;
-   char *End;
-   bool Done;
-   unsigned long iOffset;
-   unsigned long Size;
+   pkgTagFilePrivate *d;
 
    bool Fill();
    bool Resize();
@@ -98,11 +93,11 @@ class pkgTagFile
    public:
 
    bool Step(pkgTagSection &Section);
-   inline unsigned long Offset() {return iOffset;};
+   unsigned long Offset();
    bool Jump(pkgTagSection &Tag,unsigned long Offset);
 
    pkgTagFile(FileFd *F,unsigned long Size = 32*1024);
-   ~pkgTagFile();
+   virtual ~pkgTagFile();
 };
 
 /* This is the list of things to rewrite. The rewriter
index b144d35ad05e8a03b29d6bcd9e50132ad61b202e..999417bffa5c1c08455b475018633ecfafef4717 100644 (file)
@@ -1,7 +1,7 @@
 apt (0.8.15) UNRELEASED; urgency=low
 
   [ David Kalnischkies ]
-  * Implement EDSP in libapt-pkg so that all front-ends which
+  * [ABI-Break] Implement EDSP in libapt-pkg so that all front-ends which
     use the internal resolver can now be used also with external
     ones as the usage is hidden in between the old API
   * provide two edsp solvers in apt-utils:
@@ -25,7 +25,9 @@ apt (0.8.15) UNRELEASED; urgency=low
     - describe EDSP and the configuration interface around it
   
   [ Michael Vogt ]
-  * merge lp:~mvo/apt/sha512-template to add support for sha512
+  * [ABI-Break] merge lp:~mvo/apt/sha512-template to add support for sha512
+  * [ABI-Break] merge lp:~mvo/apt/dpointer to support easier extending
+    without breaking the ABI
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Tue, 17 May 2011 18:43:21 +0200