]> git.saurik.com Git - wxWidgets.git/commitdiff
* wxStream: I've rewritten the inheritance
authorGuilhem Lavaux <lavaux@easynet.fr>
Tue, 14 Jul 1998 12:06:50 +0000 (12:06 +0000)
committerGuilhem Lavaux <lavaux@easynet.fr>
Tue, 14 Jul 1998 12:06:50 +0000 (12:06 +0000)
* added wxZlib*Stream
* updated makefiles and data.cpp
* modified a bit wxFile so I can use it in wxFile*Stream

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@263 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

18 files changed:
include/wx/file.h
include/wx/fstream.h
include/wx/mstream.h
include/wx/stream.h
include/wx/zstream.h [new file with mode: 0644]
src/Makefile.in
src/common/file.cpp
src/common/fstream.cpp
src/common/mstream.cpp
src/common/stream.cpp
src/common/zstream.cpp [new file with mode: 0644]
src/gtk/data.cpp
src/gtk1/data.cpp
src/msw/data.cpp
src/msw/makefile.b32
src/msw/makefile.dos
src/msw/makefile.g95
src/msw/makefile.nt

index bf58ce69c079df7aa3235ad9a29f3ad8d192d0b0..e3f8ab1fc3b0667400606bef86198a3bb518fdc2 100644 (file)
@@ -23,6 +23,7 @@
 
 #include  "wx/string.h"
 #include  "wx/filefn.h"
+#include  "wx/stream.h" // for wxSeekMode
 
 // define off_t
 #include  <sys/types.h>
@@ -54,8 +55,6 @@ public:
   enum OpenMode { read, write, read_write, write_append };
     // standard values for file descriptor
   enum { fd_invalid = -1, fd_stdin, fd_stdout, fd_stderr };
-    // seek type
-  enum SeekMode { FromStart, FromEnd, FromCurrent };
 
   // static functions
   // ----------------
@@ -84,7 +83,7 @@ public:
     // returns number of bytes read or ofsInvalid on error
   off_t Read(void *pBuf, off_t nCount);
     // returns true on success
-  bool Write(const void *pBuf, uint nCount);
+  uint Write(const void *pBuf, uint nCount);
     // returns true on success
   bool Write(const wxString& str) { return Write(str.c_str(), str.Len()); }
     // flush data not yet written
@@ -92,9 +91,9 @@ public:
 
   // file pointer operations (return ofsInvalid on failure)
     // move ptr ofs bytes related to start/current off_t/end of file
-  off_t Seek(off_t ofs, SeekMode mode = FromStart);
+  off_t Seek(off_t ofs, wxSeekMode mode = wxFromStart);
     // move ptr to ofs bytes before the end
-  off_t SeekEnd(off_t ofs = 0) { return Seek(ofs, FromEnd); }
+  off_t SeekEnd(off_t ofs = 0) { return Seek(ofs, wxFromEnd); }
     // get current off_t
   off_t Tell() const;
     // get current file length
@@ -105,6 +104,8 @@ public:
   bool IsOpened() const { return m_fd != fd_invalid; }
     // is end of file reached?
   bool Eof() const;
+    // is an error occured?
+  bool Error() const { return m_error; }
     
   // dtor closes the file if opened
  ~wxFile();
@@ -117,6 +118,7 @@ private:
   wxFile& operator=(const wxFile&);
 
   int m_fd; // file descriptor or INVALID_FD if not opened
+  bool m_error; // error memory
 };
 
 // ----------------------------------------------------------------------------
index d41b9bc7351348556902716e990b0c7b98787c0b..384a614bc4c9402715d73f26d67d060e1c36872a 100644 (file)
 #ifndef __WXFSTREAM_H__
 #define __WXFSTREAM_H__
 
-#include <stdio.h>
 #include <wx/object.h>
 #include <wx/string.h>
 #include <wx/stream.h>
+#include <wx/file.h>
 
-class wxFileStreamBase: public wxStream {
-  DECLARE_CLASS(wxFileStreamBase)
+class wxFileInputStream: virtual public wxFile, public wxInputStream {
+  DECLARE_CLASS(wxFileInputStream)
  public:
-  wxFileStreamBase(const wxString& fileName, int iolimit);
-  virtual ~wxFileStreamBase();
+  wxFileInputStream(const wxString& fileName);
+  virtual ~wxFileInputStream();
 
   wxInputStream& Read(void *buffer, size_t size);
-  size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition);
-  size_t TellI() const;
+  off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
+  off_t TellI() const;
 
   bool Eof() const { return m_eof; }
   size_t LastRead() const { return m_lastread; }
 
+  bool Ok() const { return wxFile::IsOpened(); }
+
+ protected:
+  wxFileInputStream() {}
+
+ protected:
+  bool m_eof;
+  bool m_ok_i;
+  size_t m_lastread;
+};
+
+class wxFileOutputStream: virtual wxFile, public wxOutputStream {
+  DECLARE_CLASS(wxFileOutputStream)
+ public:
+  wxFileOutputStream(const wxString& fileName);
+  virtual ~wxFileOutputStream();
+
   wxOutputStream& Write(const void *buffer, size_t size);
-  size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition);
-  size_t TellO() const;
+  off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
+  off_t TellO() const;
 
   bool Bad() const { return m_bad; }
   size_t LastWrite() const { return m_lastwrite; }
 
   void Sync();
 
- protected:
-  size_t m_lastread, m_lastwrite;
-  bool m_eof, m_bad;
-  FILE *m_file;
-};
+  bool IsOpened() const { return wxFile::IsOpened(); }
 
-class wxFileInputStream: public wxFileStreamBase {
-  DECLARE_CLASS(wxFileInputStream)
- public:
-  wxFileInputStream(const wxString& fileName) : wxFileStreamBase(fileName, 1) {}
-  virtual ~wxFileInputStream() {}
-};
+ protected:
+  wxFileOutputStream() {}
 
-class wxFileOutputStream: public wxFileStreamBase {
-  DECLARE_CLASS(wxFileOutputStream)
- public:
-  wxFileOutputStream(const wxString& fileName) : wxFileStreamBase(fileName, 2) {}
-  virtual ~wxFileOutputStream() {}
+ protected:
+  bool m_bad;
+  size_t m_lastwrite;
 };
 
-class wxFileStream: public wxFileStreamBase {
+class wxFileStream: public wxFileInputStream, public wxFileOutputStream {
   DECLARE_CLASS(wxFileStream)
  public:
-  wxFileStream(const wxString& fileName) : wxFileStreamBase(fileName, 0) {}
-  virtual ~wxFileStream() {}
+  wxFileStream(const wxString& fileName);
+  virtual ~wxFileStream();
 };
 
 #endif
index 716c8099673a11bfb622d843d533a6f5255042ab..641c0d42447fd967e1e12fe0aa3667d3fbb1497d 100644 (file)
 #ifndef __WXMMSTREAM_H__
 #define __WXMMSTREAM_H__
 
-#include "wx/object.h"
-#include "wx/stream.h"
+#include <wx/stream.h>
 
-class wxMemoryStreamBase: public wxStream {
-  DECLARE_CLASS(wxMemoryStreamBase)
- public:
-  wxMemoryStreamBase(char *data, size_t length, int iolimit);
+class wxMemoryStreamBase {
+ protected:
+  wxMemoryStreamBase();
   virtual ~wxMemoryStreamBase();
 
-  // Input part
-  wxInputStream& Read(void *buffer, size_t size);
-  size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition);
-  size_t TellI() const { return m_position_i; }
-
-  bool Eof() const { return m_eof; }
-  size_t LastRead() const { return m_lastread; }
-
-  // Output part
-  wxOutputStream& Write(const void *buffer, size_t size);
-  size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition);
-  size_t TellO() const { return m_position_o; }
-
-  bool Bad() const { return m_bad; }
-  size_t LastWrite() const { return m_lastwrite; }
-  void Sync() {}
-
- protected:
   bool ChangeBufferSize(size_t new_length);
 
  protected:
-  bool m_bad, m_eof, m_persistent;
-  size_t m_lastread, m_lastwrite;
+  bool m_persistent;
   size_t m_length;
-  size_t m_position_i, m_position_o;
   char *m_buffer;
   int m_iolimit;
 };
 
-
-class wxMemoryInputStream: public wxMemoryStreamBase {
+class wxMemoryInputStream: virtual public wxMemoryStreamBase, public wxInputStream {
   DECLARE_CLASS(wxMemoryInputStream)
  public:
-  wxMemoryInputStream(char *data, size_t length)
-     : wxMemoryStreamBase(data, length, 1)
-    {}
+  wxMemoryInputStream(const char *data, size_t length);
+  virtual ~wxMemoryInputStream();
+  wxInputStream& Read(void *buffer, size_t size);
+  off_t SeekI(off_t pos, wxSeekMode mode);
+  off_t TellI() const { return m_position_i; }
+
+  bool Eof() const { return m_eof; }
+  size_t LastRead() const { return m_lastread; }
+
+ protected:
+  bool m_eof;
+  off_t m_position_i;
+  size_t m_lastread;
 };
 
-class wxMemoryOutputStream: public wxMemoryStreamBase {
-  DECLARE_DYNAMIC_CLASS(wxMemoryOutputStream)
+class wxMemoryOutputStream: virtual public wxMemoryStreamBase, public wxOutputStream {
+  DECLARE_CLASS(wxMemoryOutputStream)
  public:
-  wxMemoryOutputStream(char *data = NULL, size_t length = 0)
-     : wxMemoryStreamBase(data, length, 2)
-   {}
+  wxMemoryOutputStream(char *data = NULL, size_t length = 0);
+  virtual ~wxMemoryOutputStream();
+
+  wxOutputStream& Write(const void *buffer, size_t size);
+  off_t SeekO(off_t pos, wxSeekMode mode);
+  off_t TellO() const { return m_position_o; }
+
+  bool Bad() const { return m_bad; }
+  size_t LastWrite() const { return m_lastwrite; }
+
+  char *GetData() { return m_buffer; }
+  size_t GetLength() { return m_length; }
+
+ protected:
+  bool m_bad;
+  off_t m_position_o;
+  size_t m_lastwrite;
 };
 
-class wxMemoryStream: public wxMemoryStreamBase {
-  DECLARE_DYNAMIC_CLASS(wxMemoryStream)
+class wxMemoryStream: public wxMemoryInputStream, public wxMemoryOutputStream {
+  DECLARE_CLASS(wxMemoryStream)
  public:
-  wxMemoryStream(char *data = NULL, size_t length = 0)
-     : wxMemoryStreamBase(data, length, 0)
-   {}
+  wxMemoryStream(char *data = NULL, size_t length = 0);
+  virtual ~wxMemoryStream();
 };
 
 #endif
index 9acfab21338eb2e470f0c233bd08acd22bf6d566..3fef67ff565de01c22c42067394e14ebacaba04d 100644 (file)
@@ -13,7 +13,7 @@
 #define __WXSTREAM_H__
 
 #ifdef __GNUG__
-#pragma interface "stream.h"
+#pragma interface
 #endif
 
 #include <stdio.h>
  */
 
 typedef enum {
-  wxBeginPosition = 0, wxCurrentPosition = 1, wxEndPosition = 2
-} wxWhenceType;
+  wxFromStart, wxFromCurrent, wxFromEnd
+} wxSeekMode;
 
 class wxOutputStream;
-class wxInputStream: public wxObject {
+class wxInputStream: virtual public wxObject {
   DECLARE_ABSTRACT_CLASS(wxInputStream)
  public:
   wxInputStream();
@@ -38,14 +38,14 @@ class wxInputStream: public wxObject {
   virtual wxInputStream& Read(void *buffer, size_t size) = 0;
   wxInputStream& Read(wxOutputStream& stream_out);
 
-  virtual size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition) = 0;
-  virtual size_t TellI() const = 0;
+  virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart) = 0;
+  virtual off_t TellI() const = 0;
 
   virtual bool Eof() const = 0;
   virtual size_t LastRead() const = 0;
 };
 
-class wxOutputStream: public wxObject {
+class wxOutputStream: virtual public wxObject {
   DECLARE_ABSTRACT_CLASS(wxOutputStream)
  public:
   wxOutputStream();
@@ -54,8 +54,8 @@ class wxOutputStream: public wxObject {
   virtual wxOutputStream& Write(const void *buffer, size_t size) = 0;
   wxOutputStream& Write(wxInputStream& stream_in);
 
-  virtual size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition) = 0;
-  virtual size_t TellO() const = 0;
+  virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart) = 0;
+  virtual off_t TellO() const = 0;
 
   virtual bool Bad() const = 0;
   virtual size_t LastWrite() const = 0;
@@ -63,11 +63,10 @@ class wxOutputStream: public wxObject {
   virtual void Sync() {}
 };
 
-class wxStream: public wxInputStream, public wxOutputStream {
-  DECLARE_ABSTRACT_CLASS(wxStream)
+class wxStream: virtual public wxInputStream, virtual public wxOutputStream {
  public:
-  wxStream() : wxInputStream(), wxOutputStream() {}
-  virtual ~wxStream() {}
+  wxStream() {}
+  virtual ~wxStream() { }
 };
 
 /*
@@ -82,11 +81,12 @@ class wxFilterInputStream: public wxInputStream {
 
   virtual wxInputStream& Read(void *buffer, size_t size)
      { return m_parent_i_stream->Read(buffer, size); }
-  virtual size_t SeekI(int pos, wxWhenceType whence = wxBeginPosition)
-     { return m_parent_i_stream->SeekI(pos, whence); }
+  virtual off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart)
+     { return m_parent_i_stream->SeekI(pos, mode); }
 
   virtual bool Eof() const { return m_parent_i_stream->Eof(); } 
   virtual size_t LastRead() const { return m_parent_i_stream->LastRead(); } 
+
  protected:
   wxInputStream *m_parent_i_stream;
 };
@@ -99,8 +99,8 @@ class wxFilterOutputStream: public wxOutputStream {
 
   virtual wxOutputStream& Write(const void *buffer, size_t size)
      { return m_parent_o_stream->Write(buffer, size); }
-  virtual size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition)
-     { return m_parent_o_stream->SeekO(pos, whence); }
+  virtual off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart)
+     { return m_parent_o_stream->SeekO(pos, mode); }
 
   virtual bool Bad() const { return m_parent_o_stream->Bad(); }
   virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); }
diff --git a/include/wx/zstream.h b/include/wx/zstream.h
new file mode 100644 (file)
index 0000000..34bb20f
--- /dev/null
@@ -0,0 +1,63 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        zstream.h
+// Purpose:     Memory stream classes
+// Author:      Guilhem Lavaux
+// Modified by:
+// Created:     11/07/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Guilhem Lavaux
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+#ifndef __WXZSTREAM_H__
+#define __WXZSTREAM_H__
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <wx/stream.h>
+#include "zlib.h"
+
+class wxZlibInputStream: public wxFilterInputStream {
+  DECLARE_CLASS(wxZlibInputStream)
+ public:
+  wxZlibInputStream(wxInputStream& stream);
+  virtual ~wxZlibInputStream();
+
+  wxInputStream& Read(void *buffer, size_t size);
+  off_t SeekI(off_t pos, wxSeekMode mode = wxFromStart);
+  off_t TellI() const;
+
+  size_t LastRead() const { return m_lastread; }
+  bool Eof() const;
+
+ protected:
+  size_t m_lastread;
+  size_t m_z_size;
+  unsigned char *m_z_buffer;
+  bool m_eof;
+  struct z_stream_s m_inflate;
+};
+
+class wxZlibOutputStream: public wxFilterOutputStream {
+  DECLARE_CLASS(wxZlibOutputStream)
+ public:
+  wxZlibOutputStream(wxOutputStream& stream);
+  virtual ~wxZlibOutputStream();
+
+  wxOutputStream& Write(const void *buffer, size_t size);
+  off_t SeekO(off_t pos, wxSeekMode mode = wxFromStart);
+  off_t TellO() const;
+
+  size_t LastWrite() const { return m_lastwrite; }
+  bool Bad() const;
+
+ protected:
+  size_t m_lastwrite;
+  size_t m_z_size;
+  unsigned char *m_z_buffer;
+  bool m_bad;
+  struct z_stream_s m_deflate;
+};
+
+#endif
index 0731893a143f299161d20137f9c1db804e91d23a..b695ecfff26ea1626e0c5d7db4661a020e71a701 100644 (file)
@@ -58,6 +58,7 @@ LIB_CPP_SRC=\
  common/stream.cpp \
  common/fstream.cpp \
  common/mstream.cpp \
+ common/zstream.cpp \
  common/datstrm.cpp \
 \
  gtk/app.cpp \
index 52a39d4d348f5ad94a4a07d904c218d4cccfabbc..05e18e8866ae12e87d9a910effc6d7a5aa3cc356 100644 (file)
@@ -105,6 +105,7 @@ bool wxFile::Exists(const char *sz)
 wxFile::wxFile(const char *szFileName, OpenMode mode)
 {
   m_fd = fd_invalid;
+  m_error = FALSE;
 
   Open(szFileName, mode);
 }
@@ -202,17 +203,18 @@ off_t wxFile::Read(void *pBuf, off_t nCount)
 }
 
 // write
-bool wxFile::Write(const void *pBuf, uint nCount)
+uint wxFile::Write(const void *pBuf, uint nCount)
 {
   wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
 
   int iRc = ::write(m_fd, pBuf, nCount);
   if ( iRc == -1 ) {
     wxLogSysError("can't write to file descriptor %d", m_fd);
-    return FALSE;
+    m_error = TRUE;
+    return 0;
   }
   else
-    return TRUE;
+    return iRc;
 }
 
 // flush
@@ -235,21 +237,21 @@ bool wxFile::Flush()
 // ----------------------------------------------------------------------------
 
 // seek
-off_t wxFile::Seek(off_t ofs, SeekMode mode)
+off_t wxFile::Seek(off_t ofs, wxSeekMode mode)
 {
   wxASSERT( IsOpened() );
 
   int flag = -1;
   switch ( mode ) {
-    case FromStart:
+    case wxFromStart:
       flag = SEEK_SET;
       break;
 
-    case FromCurrent:
+    case wxFromCurrent:
       flag = SEEK_CUR;
       break;
 
-    case FromEnd:
+    case wxFromEnd:
       flag = SEEK_END;
       break;
 
index 6ebb2b1395c1ee0f907d79d8cdcbb10755d30fa4..ea50fee90a8f6f1915c4e4525c3ab8dea8f66b3f 100644 (file)
 #pragma implementation "fstream.h"
 #endif
 
-#include <wx/object.h>
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
 #include <stdio.h>
 #include <wx/stream.h>
 #include <wx/fstream.h>
 
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+
 #define BUF_TEMP_SIZE 10000
 
 #if !USE_SHARED_LIBRARY
-IMPLEMENT_CLASS(wxFileStreamBase, wxStream)
-IMPLEMENT_CLASS(wxFileInputStream, wxFileStreamBase)
-IMPLEMENT_CLASS(wxFileOutputStream, wxFileStreamBase)
-IMPLEMENT_CLASS(wxFileStream, wxFileStreamBase)
+IMPLEMENT_CLASS(wxFileInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxFileStream, wxInputStream, wxOutputStream)
 #endif
 
-wxFileStreamBase::wxFileStreamBase(const wxString& fileName, int iolimit)
-  : wxStream()
+// ----------------------------------------------------------------------------
+// wxFileInputStream
+// ----------------------------------------------------------------------------
+
+wxFileInputStream::wxFileInputStream(const wxString& fileName)
+  : wxFile(fileName, read)
 {
-  char *open_mode;
-
-  switch (iolimit) {
-  case 0:
-    open_mode = "a+";
-    break;
-  case 1:
-    open_mode = "rb";
-    break;
-  case 2: 
-    open_mode = "wb";
-    break;
-  }
-  m_file = fopen(fileName, open_mode);
-  fseek(m_file, 0, SEEK_SET);
-
-  m_eof = FALSE;
-  m_bad = FALSE;
+  m_lastread = 0;
 }
 
-wxFileStreamBase::~wxFileStreamBase()
+wxFileInputStream::~wxFileInputStream()
 {
-  fclose(m_file);
 }
 
-wxInputStream& wxFileStreamBase::Read(void *buffer, size_t size)
+wxInputStream& wxFileInputStream::Read(void *buffer, size_t size)
 {
-  m_lastread = fread(buffer, 1, size, m_file);
-  m_eof = feof(m_file);
+  m_lastread = wxFile::Read(buffer, size);
   return *this;
 }
 
-wxOutputStream& wxFileStreamBase::Write(const void *buffer, size_t size)
+off_t wxFileInputStream::SeekI(off_t pos, wxSeekMode mode)
 {
-  m_lastwrite = fwrite(buffer, 1, size, m_file);
-  m_bad = ferror(m_file) != 0;
-  return *this;
+  return wxFile::Seek(pos, mode);
+}
+
+off_t wxFileInputStream::TellI() const
+{
+  return wxFile::Tell();
+}
+
+// ----------------------------------------------------------------------------
+// wxFileOutputStream
+// ----------------------------------------------------------------------------
+
+wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
+ : wxFile(fileName, write)
+{
+  m_lastwrite = 0;
 }
 
-size_t wxFileStreamBase::SeekI(int pos, wxWhenceType whence)
+wxFileOutputStream::~wxFileOutputStream()
 {
-  int real_whence;
+}
 
-  if (whence == wxBeginPosition)
-    real_whence = SEEK_SET;
-  else if (whence == wxCurrentPosition)
-    real_whence = SEEK_CUR;
-  else if (whence == wxEndPosition)
-    real_whence = SEEK_END;
+wxOutputStream& wxFileOutputStream::Write(const void *buffer, size_t size)
+{
+  m_lastwrite = wxFile::Write(buffer, size);
+  m_bad = wxFile::Error();
+  return *this;
+}
 
-  fseek(m_file, pos, real_whence);
-  return ftell(m_file);
+off_t wxFileOutputStream::TellO() const
+{
+  return wxFile::Tell();
 }
 
-size_t wxFileStreamBase::TellI() const
+off_t wxFileOutputStream::SeekO(off_t pos, wxSeekMode mode)
 {
-  return ftell(m_file);
+  return wxFile::Seek(pos, mode);
 }
 
-size_t wxFileStreamBase::TellO() const
+void wxFileOutputStream::Sync()
 {
-  return ftell(m_file);
+  wxFile::Flush();
 }
 
-size_t wxFileStreamBase::SeekO(int pos, wxWhenceType whence)
+// ----------------------------------------------------------------------------
+// wxFileStream
+// ----------------------------------------------------------------------------
+
+wxFileStream::wxFileStream(const wxString& fileName)
+  : wxFile(fileName, read_write)
 {
-  return SeekI(pos, whence);
 }
 
-void wxFileStreamBase::Sync()
+wxFileStream::~wxFileStream()
 {
-  fflush(m_file);
 }
index 2bfa364e1ea80409943ddad0e0d766d5f03a634c..d37a9ddaa3bd2daa3eafcddc26cc4350ef605cd1 100644 (file)
 #pragma implementation "mstream.h"
 #endif
 
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
 #include <stdlib.h>
-#include "wx/stream.h"
-#include "wx/mstream.h"
+#include <wx/stream.h>
+#include <wx/mstream.h>
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
 
 #if !USE_SHARED_LIBRARY
-IMPLEMENT_CLASS(wxMemoryStreamBase, wxStream)
-IMPLEMENT_CLASS(wxMemoryInputStream, wxMemoryStreamBase)
-//IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxMemoryStreamBase)
-//IMPLEMENT_DYNAMIC_CLASS(wxMemoryStream, wxMemoryStreamBase)
+IMPLEMENT_CLASS(wxMemoryInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxMemoryOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxMemoryStream, wxInputStream, wxOutputStream)
 #endif
 
-wxMemoryStreamBase::wxMemoryStreamBase(char *data, size_t length, int iolimit)
+// ----------------------------------------------------------------------------
+// wxMemoryStreamBase
+// ----------------------------------------------------------------------------
+wxMemoryStreamBase::wxMemoryStreamBase()
 {
-  m_buffer = data;
-  m_iolimit = iolimit;
+  m_buffer = NULL;
+  m_iolimit = 0;
   m_persistent = FALSE;
-  m_length = length;
-  m_position_i = m_position_o = 0;
+  m_length = 0;
 }
 
 wxMemoryStreamBase::~wxMemoryStreamBase()
 {
-  free(m_buffer);
+  if (!m_persistent && m_buffer)
+   free(m_buffer);
+}
+
+bool wxMemoryStreamBase::ChangeBufferSize(size_t new_size)
+{
+  if (m_iolimit == 1)
+    return FALSE;
+
+  m_length = new_size;
+  if (!m_buffer)
+    m_buffer = (char *)malloc(m_length);
+  else
+    m_buffer = (char *)realloc(m_buffer, m_length);
+
+  return (m_buffer != NULL);
+}
+
+// ----------------------------------------------------------------------------
+// wxMemoryInputStream
+// ----------------------------------------------------------------------------
+
+wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len)
+{
+  m_persistent = TRUE;
+  m_length = len;
+  m_buffer = (char *)data; // It's bad.
+  m_position_i = 0;
+  m_lastread = 0;
+  m_eof = FALSE;
+  m_iolimit = 1;
 }
 
-wxInputStream& wxMemoryStreamBase::Read(void *buffer, size_t size)
+wxInputStream& wxMemoryInputStream::Read(void *buffer, size_t size)
 {
   if (m_iolimit == 2) {
     m_eof = TRUE;
@@ -54,24 +91,24 @@ wxInputStream& wxMemoryStreamBase::Read(void *buffer, size_t size)
   return *this;
 }
 
-size_t wxMemoryStreamBase::SeekI(int pos, wxWhenceType whence)
+off_t wxMemoryInputStream::SeekI(off_t pos, wxSeekMode mode)
 {
   if (m_iolimit == 2)
     return 0;
 
-  switch (whence) {
-  case wxBeginPosition:
+  switch (mode) {
+  case wxFromStart:
     if ((size_t)pos > m_length)
       return m_position_i;
     return (m_position_i = pos);
 
-  case wxCurrentPosition:
+  case wxFromCurrent:
     if ((size_t)(m_position_i+pos) > m_length)
       return m_position_i;
 
     return (m_position_i += pos);
 
-  case wxEndPosition:
+  case wxFromEnd:
     if ((size_t)(m_length-pos) > m_length)
       return m_position_i;
 
@@ -81,7 +118,22 @@ size_t wxMemoryStreamBase::SeekI(int pos, wxWhenceType whence)
   return m_position_i;
 }
 
-wxOutputStream& wxMemoryStreamBase::Write(const void *buffer, size_t size)
+// ----------------------------------------------------------------------------
+// wxMemoryOutputStream
+// ----------------------------------------------------------------------------
+
+wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len)
+{
+  m_persistent = FALSE;
+  m_buffer = data;
+  m_length = len;
+  m_position_o = 0;
+  m_lastwrite = 0;
+  m_bad = FALSE;
+  m_iolimit = 2;
+}
+
+wxOutputStream& wxMemoryOutputStream::Write(const void *buffer, size_t size)
 {
   if (m_iolimit == 1) {
     m_bad = TRUE;
@@ -101,24 +153,24 @@ wxOutputStream& wxMemoryStreamBase::Write(const void *buffer, size_t size)
   return *this;
 }
 
-size_t wxMemoryStreamBase::SeekO(int pos, wxWhenceType whence)
+off_t wxMemoryOutputStream::SeekO(off_t pos, wxSeekMode mode)
 {
-  if (m_iolimit == 2)
+  if (m_iolimit == 1)
     return 0;
 
-  switch (whence) {
-  case wxBeginPosition:
+  switch (mode) {
+  case wxFromStart:
     if ((size_t)pos > m_length)
       return m_position_o;
     return (m_position_o = pos);
 
-  case wxCurrentPosition:
+  case wxFromCurrent:
     if ((size_t)(m_position_o+pos) > m_length)
       return m_position_o;
 
     return (m_position_o += pos);
 
-  case wxEndPosition:
+  case wxFromEnd:
     if ((size_t)(m_length-pos) > m_length)
       return m_position_o;
 
@@ -128,13 +180,19 @@ size_t wxMemoryStreamBase::SeekO(int pos, wxWhenceType whence)
   return m_position_o;
 }
 
-bool wxMemoryStreamBase::ChangeBufferSize(size_t new_size)
+// ----------------------------------------------------------------------------
+// wxMemoryStream
+// ----------------------------------------------------------------------------
+
+wxMemoryStream::wxMemoryStream(char *data, size_t len)
+  : wxMemoryInputStream(NULL, 0), wxMemoryOutputStream(NULL, 0)
 {
-  m_length = new_size;
-  if (!m_buffer)
-    m_buffer = (char *)malloc(m_length);
-  else
-    m_buffer = (char *)realloc(m_buffer, m_length);
+  m_persistent = FALSE;
+  m_buffer = data;
+  m_length = len;
+  m_iolimit = 0;
+}
 
-  return (m_buffer != NULL);
+wxMemoryStream::~wxMemoryStream()
+{
 }
index 2d9b313bb9393b2c0d6111597d03d6b49b133143..a9c76aff5bb3a2bcb0cb6d758e4087c7c67f511d 100644 (file)
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
+#include <wx/stream.h>
 
 #ifdef __BORLANDC__
 #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-#include "wx/setup.h"
-#endif
-
-#include "wx/object.h"
-#include "wx/stream.h"
-
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
-IMPLEMENT_ABSTRACT_CLASS2(wxStream, wxInputStream, wxOutputStream)
 IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
 IMPLEMENT_CLASS(wxFilterOutputStream, wxOutputStream)
 #endif
diff --git a/src/common/zstream.cpp b/src/common/zstream.cpp
new file mode 100644 (file)
index 0000000..de38cad
--- /dev/null
@@ -0,0 +1,200 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        zstream.cpp
+// Purpose:     Compressed stream classes
+// Author:      Guilhem Lavaux
+// Modified by:
+// Created:     11/07/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Guilhem Lavaux
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+#ifdef __GNUG__
+#pragma implementation "zstream.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+#include <wx/stream.h>
+#include <wx/zstream.h>
+#include <wx/utils.h>
+#include "zlib.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#if !USE_SHARED_LIBRARY
+IMPLEMENT_CLASS(wxZlibInputStream, wxFilterInputStream)
+IMPLEMENT_CLASS(wxZlibOutputStream, wxFilterOutputStream)
+#endif
+
+//////////////////////
+// wxZlibInputStream
+//////////////////////
+
+wxZlibInputStream::wxZlibInputStream(wxInputStream& stream)
+  : wxFilterInputStream(stream)
+{
+  int err;
+
+  m_inflate.zalloc = (alloc_func)0;
+  m_inflate.zfree = (free_func)0;
+  m_inflate.opaque = (voidpf)0;
+
+  err = inflateInit(&m_inflate);
+  if (err != Z_OK) {
+    inflateEnd(&m_inflate);
+    return;
+  }
+
+  m_inflate.avail_in = 0;
+}
+
+wxZlibInputStream::~wxZlibInputStream()
+{
+  inflateEnd(&m_inflate);
+}
+
+wxInputStream& wxZlibInputStream::Read(void *buffer, size_t size)
+{
+  int err;
+
+  m_inflate.next_out = (unsigned char *)buffer;
+  m_inflate.avail_out = size;
+  m_eof = FALSE;
+
+  while (m_inflate.avail_out > 0) {
+    if (m_inflate.avail_in == 0) {
+      wxFilterInputStream::Read(m_z_buffer, m_z_size);
+      m_inflate.next_in = m_z_buffer;
+      m_inflate.avail_in = wxFilterInputStream::LastRead();
+      if (wxFilterInputStream::Eof()) {
+        m_lastread = size - m_inflate.avail_out;
+        return *this;
+      }
+    }
+    err = inflate(&m_inflate, Z_FINISH);
+    if (err == Z_STREAM_END) {
+      m_lastread = size - m_inflate.avail_out;
+      m_eof = TRUE;
+      return *this;
+    }
+  }
+
+  m_lastread = size;
+  return *this;
+}
+
+off_t wxZlibInputStream::SeekI(off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode))
+{
+  return 0;
+}
+
+off_t wxZlibInputStream::TellI() const
+{
+  return 0;
+}
+
+bool wxZlibInputStream::Eof() const
+{
+  if (!m_eof)
+    return wxFilterInputStream::Eof();
+  return m_eof;
+}
+
+//////////////////////
+// wxZlibOutputStream
+//////////////////////
+
+wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream)
+ : wxFilterOutputStream(stream)
+{
+  int err;
+
+  m_deflate.zalloc = (alloc_func)0;
+  m_deflate.zfree = (free_func)0;
+  m_deflate.opaque = (voidpf)0;
+
+  err = deflateInit(&m_deflate, Z_DEFAULT_COMPRESSION);
+  if (err != Z_OK) {
+    deflateEnd(&m_deflate);
+    return;
+  }
+  m_deflate.avail_in = 0;
+  m_deflate.next_out = m_z_buffer;
+  m_deflate.avail_out = m_z_size;
+}
+
+wxZlibOutputStream::~wxZlibOutputStream()
+{
+  int err;
+
+  while (1) {
+    err = deflate(&m_deflate, Z_FINISH);
+    if (err == Z_STREAM_END)
+      break;
+    if (err < 0) {
+      wxDebugMsg("wxZlibOutputStream: error during final deflate");
+      break;
+    }
+    if (m_deflate.avail_out == 0) {
+      wxFilterOutputStream::Write(m_z_buffer, m_z_size);
+      if (wxFilterOutputStream::Bad()) {
+        wxDebugMsg("wxZlibOutputStream: error during final write");
+        break;
+      }
+      m_deflate.next_out = m_z_buffer;
+      m_deflate.avail_out = m_z_size;
+    }
+  }
+  wxFilterOutputStream::Write(m_z_buffer, m_z_size-m_deflate.avail_out);
+
+  deflateEnd(&m_deflate);
+}
+
+wxOutputStream& wxZlibOutputStream::Write(const void *buffer, size_t size)
+{
+  int err;
+
+  m_deflate.next_in = (unsigned char *)buffer;
+  m_deflate.avail_in = size;
+
+  m_bad = FALSE;
+  while (m_deflate.avail_in > 0) {
+    if (m_deflate.avail_out == 0) {
+      wxFilterOutputStream::Write(m_z_buffer, m_z_size);
+      if (wxFilterOutputStream::Bad()) {
+        m_lastwrite = size - m_deflate.avail_in;
+        return *this;
+      }
+            
+      m_deflate.next_out = m_z_buffer;
+      m_deflate.avail_out = m_z_size;
+    }
+    err = deflate(&m_deflate, Z_NO_FLUSH);
+    if (err < 0) {
+      m_bad = TRUE;
+      m_lastwrite = size - m_deflate.avail_in;
+      return *this;
+    }
+  }
+  m_lastwrite = size;
+  return *this;
+}
+
+off_t wxZlibOutputStream::SeekO(off_t WXUNUSED(pos), wxSeekMode WXUNUSED(mode))
+{
+  return 0;
+}
+
+off_t wxZlibOutputStream::TellO() const
+{
+  return 0;
+}
+
+bool wxZlibOutputStream::Bad() const
+{
+  if (!m_bad)
+    return wxFilterOutputStream::Bad();
+  return m_bad;
+}
index 416bdd9474dc1fd812e66035037fbfb0d4ebe9b9..1431dd4dc0c1293fa0cfc13f3bc821ca4fcd85db 100644 (file)
@@ -348,21 +348,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
 #include "wx/stream.h"
 #include "wx/fstream.h"
 #include "wx/mstream.h"
+#include "wx/zstream.h"
 #include "wx/datstrm.h"
 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
-IMPLEMENT_ABSTRACT_CLASS2(wxStream, wxInputStream, wxOutputStream)
 IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
 IMPLEMENT_CLASS(wxFilterOutputStream, wxOutputStream)
 
-IMPLEMENT_CLASS(wxFileStreamBase, wxStream)
-IMPLEMENT_CLASS(wxFileInputStream, wxFileStreamBase)
-IMPLEMENT_CLASS(wxFileOutputStream, wxFileStreamBase)
+IMPLEMENT_CLASS(wxFileInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxFileStream, wxFileInputStream, wxFileOutputStream)
 
-IMPLEMENT_CLASS(wxMemoryStreamBase, wxStream)
-IMPLEMENT_CLASS(wxMemoryInputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryStream, wxMemoryStreamBase)
+IMPLEMENT_CLASS(wxMemoryInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxMemoryOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxMemoryStream, wxMemoryInputStream, wxMemoryOutputStream)
+
+IMPLEMENT_CLASS(wxZlibInputStream, wxFilterInputStream)
+IMPLEMENT_CLASS(wxZlibOutputStream, wxFilterOutputStream)
 
 IMPLEMENT_CLASS(wxDataInputStream, wxFilterInputStream)
 IMPLEMENT_CLASS(wxDataOutputStream, wxFilterInputStream)
index 416bdd9474dc1fd812e66035037fbfb0d4ebe9b9..1431dd4dc0c1293fa0cfc13f3bc821ca4fcd85db 100644 (file)
@@ -348,21 +348,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
 #include "wx/stream.h"
 #include "wx/fstream.h"
 #include "wx/mstream.h"
+#include "wx/zstream.h"
 #include "wx/datstrm.h"
 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
-IMPLEMENT_ABSTRACT_CLASS2(wxStream, wxInputStream, wxOutputStream)
 IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
 IMPLEMENT_CLASS(wxFilterOutputStream, wxOutputStream)
 
-IMPLEMENT_CLASS(wxFileStreamBase, wxStream)
-IMPLEMENT_CLASS(wxFileInputStream, wxFileStreamBase)
-IMPLEMENT_CLASS(wxFileOutputStream, wxFileStreamBase)
+IMPLEMENT_CLASS(wxFileInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxFileStream, wxFileInputStream, wxFileOutputStream)
 
-IMPLEMENT_CLASS(wxMemoryStreamBase, wxStream)
-IMPLEMENT_CLASS(wxMemoryInputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryStream, wxMemoryStreamBase)
+IMPLEMENT_CLASS(wxMemoryInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxMemoryOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxMemoryStream, wxMemoryInputStream, wxMemoryOutputStream)
+
+IMPLEMENT_CLASS(wxZlibInputStream, wxFilterInputStream)
+IMPLEMENT_CLASS(wxZlibOutputStream, wxFilterOutputStream)
 
 IMPLEMENT_CLASS(wxDataInputStream, wxFilterInputStream)
 IMPLEMENT_CLASS(wxDataOutputStream, wxFilterInputStream)
index 7354a35f1ac6650a575a83e6d03c17844015c753..55e92191a33d119a5e44498c46ab00c48939045d 100644 (file)
@@ -365,18 +365,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
 #include "wx/datstrm.h"
 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
 IMPLEMENT_ABSTRACT_CLASS(wxOutputStream, wxObject)
-IMPLEMENT_ABSTRACT_CLASS2(wxStream, wxInputStream, wxOutputStream)
 IMPLEMENT_CLASS(wxFilterInputStream, wxInputStream)
 IMPLEMENT_CLASS(wxFilterOutputStream, wxOutputStream)
 
-IMPLEMENT_CLASS(wxFileStreamBase, wxStream)
-IMPLEMENT_CLASS(wxFileInputStream, wxFileStreamBase)
-IMPLEMENT_CLASS(wxFileOutputStream, wxFileStreamBase)
+IMPLEMENT_CLASS(wxFileInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxFileOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxFileStream, wxFileInputStream, wxFileOutputStream)
 
-IMPLEMENT_CLASS(wxMemoryStreamBase, wxStream)
-IMPLEMENT_CLASS(wxMemoryInputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryStream, wxMemoryStreamBase)
+IMPLEMENT_CLASS(wxMemoryInputStream, wxInputStream)
+IMPLEMENT_CLASS(wxMemoryOutputStream, wxOutputStream)
+IMPLEMENT_CLASS2(wxMemoryStream, wxMemoryInputStream, wxMemoryOutputStream)
+
+IMPLEMENT_CLASS(wxZlibInputStream, wxFilterInputStream)
+IMPLEMENT_CLASS(wxZlibOutputStream, wxFilterOutputStream)
 
 IMPLEMENT_CLASS(wxDataInputStream, wxFilterInputStream)
 IMPLEMENT_CLASS(wxDataOutputStream, wxFilterInputStream)
index d3fff4e0cc600ab963272523b60ff81c68c28520..c9f885f26a19f7e0ab80812fd5ec0922e7546215 100644 (file)
@@ -108,6 +108,7 @@ COMMONOBJS = \
   $(MSWDIR)\stream.obj \
   $(MSWDIR)\fstream.obj \
   $(MSWDIR)\mstream.obj \
+  $(MSWDIR)\zstream.obj \
   $(MSWDIR)\datstrm.obj \
   $(MSWDIR)\extended.obj
 
@@ -470,6 +471,8 @@ $(MSWDIR)\datstrm.obj:      $(COMMDIR)\datstrm.$(SRCSUFF)
 
 $(MSWDIR)\mstream.obj: $(COMMDIR)\mstream.$(SRCSUFF)
 
+$(MSWDIR)\zstream.obj: $(COMMDIR)\zstream.$(SRCSUFF)
+
 $(MSWDIR)\fstream.obj: $(COMMDIR)\fstream.$(SRCSUFF)
 
 $(MSWDIR)\stream.obj:  $(COMMDIR)\stream.$(SRCSUFF)
index a5b5c3b10efccb8dcbdd363c6277479e056b16d2..4ce5637491ddedcb0005c91559d2d4ce4395129c 100644 (file)
@@ -109,6 +109,7 @@ COMMONOBJS = \
   $(COMMDIR)\stream.obj \
   $(COMMDIR)\fstream.obj \
   $(COMMDIR)\mstream.obj \
+  $(COMMDIR)\zstream.obj \
   $(COMMDIR)\datstrm.obj \
   $(COMMDIR)\extended.obj
 
index 5f7ff564359a0ad381e14204efcb15821fb53858..f3a34442d6bfd44462940a72aa59f4cdc2811699 100644 (file)
@@ -114,6 +114,7 @@ COMMONOBJS = \
   $(COMMDIR)/stream.$(OBJSUFF) \
   $(COMMDIR)/fstream.$(OBJSUFF) \
   $(COMMDIR)/mstream.$(OBJSUFF) \
+  $(COMMDIR)/zstream.$(OBJSUFF) \
   $(COMMDIR)/datstrm.$(OBJSUFF) \
   $(COMMDIR)/extended.$(OBJSUFF)
 
index 1e2e750054e5aae73207d369ce0fae6c14c5bb1d..b4c7e6f8d63ce6e51ae9295c2e1ff74014582783 100644 (file)
@@ -109,11 +109,11 @@ COMMONOBJS = \
   $(COMMDIR)\y_tab.obj \
   $(COMMDIR)\extended.obj \
   $(COMMDIR)\process.obj
-
-# $(COMMDIR)\fstream.obj \
-#  $(COMMDIR)\mstream.obj \
-#  $(COMMDIR)\datstrm.obj \
-#  $(COMMDIR)\stream.obj \
+  $(COMMDIR)\fstream.obj \
+  $(COMMDIR)\mstream.obj \
+  $(COMMDIR)\zstream.obj \
+  $(COMMDIR)\stream.obj \
+  $(COMMDIR)\datstrm.obj
 
 MSWOBJS = \
   $(MSWDIR)\app.obj \
@@ -889,6 +889,26 @@ $(COMMDIR)/time.obj:     $*.$(SRCSUFF)
 $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
 <<
 
+$(COMMDIR)\stream.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)\fstream.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)\mstream.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
+$(COMMDIR)\zstream.obj:     $*.$(SRCSUFF)
+        cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
 $(COMMDIR)\datstrm.obj:     $*.$(SRCSUFF)
         cl @<<
 $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@