From b8f90d97faa461380f7aa2d2368f66b8b25b2356 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Jan 2011 21:37:15 +0100 Subject: apt-pkg/deb/debsystem.{cc,h}: add dpointer --- apt-pkg/deb/debsystem.cc | 62 ++++++++++++++++++++++++++++-------------------- apt-pkg/deb/debsystem.h | 11 ++++----- 2 files changed, 41 insertions(+), 32 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 8619822df..7644bc66b 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -26,15 +26,24 @@ 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 &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 &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; } diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h index 5f9995e5d..7c53e1829 100644 --- a/apt-pkg/deb/debsystem.h +++ b/apt-pkg/deb/debsystem.h @@ -12,16 +12,15 @@ #include +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(); -- cgit v1.2.3 From 697a1d8ab6744181355cda92b4de01b996c1bc1d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Jan 2011 21:59:23 +0100 Subject: apt-pkg/deb/dpkgpm.{cc,h}: convert to use dpointers --- apt-pkg/deb/dpkgpm.cc | 108 +++++++++++++++++++++++++++++--------------------- apt-pkg/deb/dpkgpm.h | 11 +---- 2 files changed, 64 insertions(+), 55 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 9f0da3be6..55525db85 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -44,6 +44,21 @@ 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 /*{{{*/ @@ -369,7 +385,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 /*{{{*/ @@ -393,8 +409,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 /*{{{*/ @@ -598,14 +614,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); @@ -613,8 +629,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; @@ -622,8 +638,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 /*{{{*/ @@ -635,7 +651,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() @@ -656,13 +672,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 @@ -670,11 +686,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++) { @@ -704,7 +720,7 @@ bool pkgDPkgPM::OpenLog() WriteHistoryTag("Downgrade",downgrade); WriteHistoryTag("Remove",remove); WriteHistoryTag("Purge",purge); - fflush(history_out); + fflush(d->history_out); } return true; @@ -718,16 +734,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) { @@ -744,12 +760,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; } @@ -857,7 +873,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) } } - stdin_is_dev_null = false; + d->stdin_is_dev_null = false; // create log OpenLog(); @@ -1043,8 +1059,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; @@ -1169,7 +1185,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) @@ -1223,14 +1239,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(dpkg_error.c_str()); + if(d->dpkg_error.size() > 0) + _error->Error(d->dpkg_error.c_str()); if(stopOnError) { @@ -1377,8 +1393,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"); diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index b7b5a6def..ddf9485c7 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -18,19 +18,12 @@ 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 -- cgit v1.2.3 From 1abbce9eafbba7a6fd22bd6ddd9287e97113fc87 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Jan 2011 22:22:51 +0100 Subject: apt-pkg/tagfile.{cc,h}: add dpointer to pkgTagFile --- apt-pkg/tagfile.cc | 123 +++++++++++++++++++++++++++++++---------------------- apt-pkg/tagfile.h | 19 +++------ 2 files changed, 79 insertions(+), 63 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 96a681bec..ff6593e26 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -24,26 +24,40 @@ 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; } diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 6891c1d81..60d3c2cd0 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -23,16 +23,17 @@ #include #include - + 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; + int *reserved1; + int *reserved2; + int *reserved3; /* This very simple hash function for the last 8 letters gives very good performance on the debian package files */ @@ -44,7 +45,6 @@ class pkgTagSection return Res & 0xFF; } - protected: const char *Stop; @@ -80,15 +80,10 @@ class pkgTagSection pkgTagSection() : Section(0), Stop(0) {}; }; +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(); @@ -96,7 +91,7 @@ class pkgTagFile public: bool Step(pkgTagSection &Section); - inline unsigned long Offset() {return iOffset;}; + inline unsigned long Offset(); bool Jump(pkgTagSection &Tag,unsigned long Offset); pkgTagFile(FileFd *F,unsigned long Size = 32*1024); -- cgit v1.2.3 From 4b2746d5ff7d6c5ed3b23a44a67fc323475cfd7d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 27 Jan 2011 22:26:56 +0100 Subject: apt-pkg/tagfile.{cc,h}: add comment, remove "inline" from pkgTagFile::Offset() --- apt-pkg/tagfile.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 60d3c2cd0..68f1642d9 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -31,9 +31,11 @@ class pkgTagSection unsigned int Indexes[256]; unsigned int AlphaIndexes[0x100]; unsigned int TagCount; + // for later int *reserved1; int *reserved2; int *reserved3; + int *reserved4; /* This very simple hash function for the last 8 letters gives very good performance on the debian package files */ @@ -91,7 +93,7 @@ class pkgTagFile public: bool Step(pkgTagSection &Section); - inline unsigned long Offset(); + unsigned long Offset(); bool Jump(pkgTagSection &Tag,unsigned long Offset); pkgTagFile(FileFd *F,unsigned long Size = 32*1024); -- cgit v1.2.3 From 43fb90dcd5d3f8887c1903073ad21a53847974ba Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 28 Jan 2011 20:55:45 +0100 Subject: apt-pkg/tagfile.h: add dpointer placeholder, make destructor virtual; apt-pkg/deb/debsystem.h: make destructor virtual --- apt-pkg/deb/debsystem.h | 2 +- apt-pkg/tagfile.h | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h index 7c53e1829..232155256 100644 --- a/apt-pkg/deb/debsystem.h +++ b/apt-pkg/deb/debsystem.h @@ -34,7 +34,7 @@ class debSystem : public pkgSystem pkgIndexFile *&Found) const; debSystem(); - ~debSystem(); + virtual ~debSystem(); }; extern debSystem debSys; diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 68f1642d9..f361a787f 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -31,11 +31,8 @@ class pkgTagSection unsigned int Indexes[256]; unsigned int AlphaIndexes[0x100]; unsigned int TagCount; - // for later - int *reserved1; - int *reserved2; - int *reserved3; - int *reserved4; + // 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 */ @@ -80,6 +77,7 @@ class pkgTagSection }; pkgTagSection() : Section(0), Stop(0) {}; + virtual ~pkgTagSection() {}; }; class pkgTagFilePrivate; @@ -97,7 +95,7 @@ class pkgTagFile 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 -- cgit v1.2.3 From e92e897a6f47d4a5088f1362651476c160197b35 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Feb 2011 22:21:21 +0100 Subject: apt-pkg/acquire.h: add placeholder dpointer --- apt-pkg/acquire.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index e3a4435b8..7db7a9958 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -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. */ -- cgit v1.2.3 From be9b62f76406cf2546d21f3ca27587ee20e0fc37 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Feb 2011 22:30:45 +0100 Subject: add more dpointer placeholders --- apt-pkg/acquire-worker.h | 5 ++++- apt-pkg/algorithms.h | 3 +++ apt-pkg/cachefile.h | 3 +++ apt-pkg/cachefilter.h | 2 ++ apt-pkg/clean.h | 3 +++ apt-pkg/indexcopy.h | 8 ++++++-- apt-pkg/pkgrecords.h | 5 +++-- apt-pkg/srcrecords.h | 2 ++ 8 files changed, 26 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 06283922e..62545829a 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -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(); }; /** @} */ diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index cf4a98c4f..42945a6f2 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -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; diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h index 09d3ec267..d07337d38 100644 --- a/apt-pkg/cachefile.h +++ b/apt-pkg/cachefile.h @@ -25,6 +25,9 @@ class pkgCacheFile { + /** \brief dpointer placeholder (for later in case we need it) */ + void *d; + protected: MMap *Map; diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h index e7ab1723f..5d426008b 100644 --- a/apt-pkg/cachefilter.h +++ b/apt-pkg/cachefilter.h @@ -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); diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h index 2aee2bf54..1ebf68dc9 100644 --- a/apt-pkg/clean.h +++ b/apt-pkg/clean.h @@ -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*/) {}; diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h index 6fcd3b8ce..277fb561c 100644 --- a/apt-pkg/indexcopy.h +++ b/apt-pkg/indexcopy.h @@ -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); diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index c2c98188a..93e342534 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -28,12 +28,13 @@ class pkgRecords /*{{{*/ class Parser; private: + /** \brief dpointer placeholder (for later in case we need it) */ + void *d; pkgCache &Cache; std::vectorFiles; - public: - + public: // Lookup function Parser &Lookup(pkgCache::VerFileIterator const &Ver); Parser &Lookup(pkgCache::DescFileIterator const &Desc); diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index a49533864..a681d2e31 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -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 Files; -- cgit v1.2.3 From ff72bd0dc7bd4d3bb6979e70d7bca9a07d28af28 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Feb 2011 22:37:01 +0100 Subject: apt-pkg/deb/*: add placeholder dpointer and make destructors virtual --- apt-pkg/deb/debindexfile.h | 15 +++++++++++++++ apt-pkg/deb/deblistparser.h | 3 +++ apt-pkg/deb/debmetaindex.h | 4 +++- apt-pkg/deb/debrecords.h | 4 ++++ apt-pkg/deb/debsrcrecords.h | 5 ++++- apt-pkg/srcrecords.h | 2 +- 6 files changed, 30 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index b5085992d..0f8d4433f 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -22,6 +22,8 @@ class debStatusIndex : public pkgIndexFile { + /** \brief dpointer placeholder (for later in case we need it) */ + void *d; string File; public: @@ -39,10 +41,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; @@ -72,10 +78,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; @@ -103,10 +113,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; @@ -136,6 +150,7 @@ class debSourcesIndex : public pkgIndexFile virtual unsigned long Size() const; debSourcesIndex(string URI,string Dist,string Section,bool Trusted); + virtual ~debSourcesIndex() {}; }; #endif diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 4bc1bd93c..54da938ec 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -27,6 +27,8 @@ class debListParser : public pkgCacheGenerator::ListParser }; private: + /** \brief dpointer placeholder (for later in case we need it) */ + void *d; pkgTagFile Tags; pkgTagSection Section; @@ -73,6 +75,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 diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index 360fa5419..ffcc7c4bb 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -19,12 +19,14 @@ class debReleaseIndex : public metaIndex { }; private: + /** \brief dpointer placeholder (for later in case we need it) */ + void *d; std::map > 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; diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index 6f358abfa..bbcb5640d 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -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; @@ -49,6 +52,7 @@ class debRecordParser : public pkgRecords::Parser virtual void GetRec(const char *&Start,const char *&Stop); debRecordParser(string FileName,pkgCache &Cache); + virtual ~debRecordParser() {}; }; #endif diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index 905264daa..aa859b0e6 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -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 diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index a681d2e31..8a78d7711 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -95,7 +95,7 @@ class pkgSrcRecords Parser *Find(const char *Package,bool const &SrcOnly = false); pkgSrcRecords(pkgSourceList &List); - ~pkgSrcRecords(); + virtual ~pkgSrcRecords(); }; #endif -- cgit v1.2.3