// -*- 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
// ---------------------------------------------------------------------
/* 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);
To = (char *)To + Res;
Size -= Res;
+ if (Actual != 0)
+ *Actual += Res;
}
while (Res > 0 && Size > 0);
return true;
// Eof handling
- if (AllowEof == true)
+ if (Actual != 0)
{
Flags |= HitEof;
return true;
// -*- 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
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);
// -*- 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
// 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;
# 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
// -*- 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
{
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();
}
Start = Buffer;
End = Buffer + EndSize;
- if (Left == 0)
+ if (Done == true)
{
if (EndSize <= 3)
return false;
}
// 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)
Left -= Size - (End - Buffer);
End = Buffer + Size;
- }
+ }*/
+
return true;
}
/*}}}*/
// Reposition and reload..
iOffset = Offset;
- Left = TotalSize - Offset;
+ Done = false;
if (Fd.Seek(Offset) == false)
return false;
End = Start = Buffer;
// -*- 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
char *Buffer;
char *Start;
char *End;
- unsigned long Left;
+ bool Done;
unsigned long iOffset;
unsigned long Size;
- unsigned long TotalSize;
bool Fill();