Browse Source

Tag file can read from unseekable objects

Author: jgg
Date: 2001-04-22 05:42:52 GMT
Tag file can read from unseekable objects
debian/1.8.y
Arch Librarian 18 years ago
parent
commit
f604cf55e2
  1. 11
      apt-pkg/contrib/fileutl.cc
  2. 11
      apt-pkg/contrib/fileutl.h
  3. 6
      apt-pkg/init.h
  4. 4
      apt-pkg/makefile
  5. 21
      apt-pkg/tagfile.cc
  6. 5
      apt-pkg/tagfile.h

11
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;

11
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);

6
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;

4
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

21
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;

5
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();

Loading…
Cancel
Save