Author: jgg
Date: 2001-04-22 05:42:52 GMT
Tag file can read from unseekable objects
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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
/* ######################################################################
File Utilities
// ---------------------------------------------------------------------
/* We are carefull to handle interruption by a signal while reading
gracefully. */
// ---------------------------------------------------------------------
/* 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)
+ if (Actual != 0)
+ *Actual = 0;
+
do
{
Res = read(iFd,To,Size);
do
{
Res = read(iFd,To,Size);
To = (char *)To + Res;
Size -= Res;
To = (char *)To + Res;
Size -= Res;
+ if (Actual != 0)
+ *Actual += Res;
}
while (Res > 0 && Size > 0);
}
while (Res > 0 && Size > 0);
return true;
// Eof handling
return true;
// Eof handling
{
Flags |= HitEof;
return true;
{
Flags |= HitEof;
return true;
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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
/* ######################################################################
File Utilities
public:
enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp};
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);
bool Write(const void *From,unsigned long Size);
bool Seek(unsigned long To);
bool Skip(unsigned long To);
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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
/* ######################################################################
Init - Initialize the package library
// See the makefile
#define APT_PKG_MAJOR 3
// 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;
extern const char *pkgVersion;
extern const char *pkgLibVersion;
# The library name, don't forget to update init.h
LIBRARY=apt-pkg
LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
# The library name, don't forget to update init.h
LIBRARY=apt-pkg
LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
SLIBS=$(PTHREADLIB)
# Source code for the contributed non-core things
SLIBS=$(PTHREADLIB)
# Source code for the contributed non-core things
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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
/* ######################################################################
Fast scanner for RFC-822 type header information
{
Buffer = 0;
Start = End = Buffer = 0;
{
Buffer = 0;
Start = End = Buffer = 0;
iOffset = 0;
return;
}
Buffer = new char[Size];
Start = End = Buffer;
iOffset = 0;
return;
}
Buffer = new char[Size];
Start = End = Buffer;
- Left = Fd.Size();
- TotalSize = Fd.Size();
Start = Buffer;
End = Buffer + EndSize;
Start = Buffer;
End = Buffer + EndSize;
{
if (EndSize <= 3)
return false;
{
if (EndSize <= 3)
return false;
}
// See if only a bit of the file is left
}
// 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)
if (Left < Size - (End - Buffer))
{
if (Fd.Read(End,Left) == false)
Left -= Size - (End - Buffer);
End = Buffer + Size;
Left -= Size - (End - Buffer);
End = Buffer + Size;
// Reposition and reload..
iOffset = Offset;
// Reposition and reload..
iOffset = Offset;
- Left = TotalSize - Offset;
if (Fd.Seek(Offset) == false)
return false;
End = Start = Buffer;
if (Fd.Seek(Offset) == false)
return false;
End = Start = Buffer;
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
// -*- 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
/* ######################################################################
Fast scanner for RFC-822 type header information
char *Buffer;
char *Start;
char *End;
char *Buffer;
char *Start;
char *End;
unsigned long iOffset;
unsigned long Size;
unsigned long iOffset;
unsigned long Size;
- unsigned long TotalSize;