diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:57:31 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:57:31 +0000 |
commit | f604cf55e27db1121895a84a525f305a78a3dad9 (patch) | |
tree | d049f8efc18eceed369f7df04792aa511c804480 /apt-pkg | |
parent | 5d622d510f558981275d6004ec015013dea9cdbf (diff) |
Tag file can read from unseekable objects
Author: jgg
Date: 2001-04-22 05:42:52 GMT
Tag file can read from unseekable objects
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 11 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 11 | ||||
-rw-r--r-- | apt-pkg/init.h | 6 | ||||
-rw-r--r-- | apt-pkg/makefile | 4 | ||||
-rw-r--r-- | apt-pkg/tagfile.cc | 21 | ||||
-rw-r--r-- | apt-pkg/tagfile.h | 5 |
6 files changed, 38 insertions, 20 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index db878064d..97dcb82b8 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.cc,v 1.37 2001/03/03 22:45:59 tausq Exp $ +// $Id: fileutl.cc,v 1.38 2001/04/22 05:42:52 jgg Exp $ /* ###################################################################### File Utilities @@ -431,10 +431,13 @@ FileFd::~FileFd() // --------------------------------------------------------------------- /* We are carefull to handle interruption by a signal while reading gracefully. */ -bool FileFd::Read(void *To,unsigned long Size,bool AllowEof) +bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual) { int Res; errno = 0; + if (Actual != 0) + *Actual = 0; + do { Res = read(iFd,To,Size); @@ -448,6 +451,8 @@ bool FileFd::Read(void *To,unsigned long Size,bool AllowEof) To = (char *)To + Res; Size -= Res; + if (Actual != 0) + *Actual += Res; } while (Res > 0 && Size > 0); @@ -455,7 +460,7 @@ bool FileFd::Read(void *To,unsigned long Size,bool AllowEof) return true; // Eof handling - if (AllowEof == true) + if (Actual != 0) { Flags |= HitEof; return true; diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 74e0d542f..8d5f03b05 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.h,v 1.24 2001/03/03 22:36:20 tausq Exp $ +// $Id: fileutl.h,v 1.25 2001/04/22 05:42:53 jgg Exp $ /* ###################################################################### File Utilities @@ -40,7 +40,14 @@ class FileFd public: enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp}; - bool Read(void *To,unsigned long Size,bool AllowEof = false); + inline bool Read(void *To,unsigned long Size,bool AllowEof) + { + unsigned long Jnk; + if (AllowEof) + return Read(To,Size,&Jnk); + return Read(To,Size); + } + bool Read(void *To,unsigned long Size,unsigned long *Actual = 0); bool Write(const void *From,unsigned long Size); bool Seek(unsigned long To); bool Skip(unsigned long To); diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 998c073ea..b07bc99ec 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: init.h,v 1.7 2001/03/06 07:15:29 jgg Exp $ +// $Id: init.h,v 1.8 2001/04/22 05:42:52 jgg Exp $ /* ###################################################################### Init - Initialize the package library @@ -18,8 +18,8 @@ // See the makefile #define APT_PKG_MAJOR 3 -#define APT_PKG_MINOR 1 -#define APT_PKG_RELEASE 3 +#define APT_PKG_MINOR 2 +#define APT_PKG_RELEASE 0 extern const char *pkgVersion; extern const char *pkgLibVersion; diff --git a/apt-pkg/makefile b/apt-pkg/makefile index 9099cc12c..e1b4d6153 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -12,8 +12,8 @@ include ../buildlib/defaults.mak # The library name, don't forget to update init.h LIBRARY=apt-pkg LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER) -MAJOR=3.1 -MINOR=3 +MAJOR=3.2 +MINOR=0 SLIBS=$(PTHREADLIB) # Source code for the contributed non-core things diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index fdeb09329..faea00ec5 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: tagfile.cc,v 1.28 2001/03/13 06:51:46 jgg Exp $ +// $Id: tagfile.cc,v 1.29 2001/04/22 05:42:52 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -34,15 +34,14 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) : Fd(*pFd), Size(Size) { Buffer = 0; Start = End = Buffer = 0; - Left = 0; + Done = true; iOffset = 0; return; } Buffer = new char[Size]; Start = End = Buffer; - Left = Fd.Size(); - TotalSize = Fd.Size(); + Done = false; iOffset = 0; Fill(); } @@ -88,7 +87,7 @@ bool pkgTagFile::Fill() Start = Buffer; End = Buffer + EndSize; - if (Left == 0) + if (Done == true) { if (EndSize <= 3) return false; @@ -107,6 +106,13 @@ bool pkgTagFile::Fill() } // See if only a bit of the file is left + unsigned long Actual; + if (Fd.Read(End,Size - (End - Buffer),&Actual) == false) + return false; + if (Actual != Size - (End - Buffer)) + Done = true; + End += Actual; +/* if (Left < Size - (End - Buffer)) { if (Fd.Read(End,Left) == false) @@ -122,7 +128,8 @@ bool pkgTagFile::Fill() Left -= Size - (End - Buffer); End = Buffer + Size; - } + }*/ + return true; } /*}}}*/ @@ -143,7 +150,7 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset) // Reposition and reload.. iOffset = Offset; - Left = TotalSize - Offset; + Done = false; if (Fd.Seek(Offset) == false) return false; End = Start = Buffer; diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index a85d24b7e..f7f1bb42c 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: tagfile.h,v 1.16 2001/03/11 07:22:19 jgg Exp $ +// $Id: tagfile.h,v 1.17 2001/04/22 05:42:52 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -72,10 +72,9 @@ class pkgTagFile char *Buffer; char *Start; char *End; - unsigned long Left; + bool Done; unsigned long iOffset; unsigned long Size; - unsigned long TotalSize; bool Fill(); |