]> git.saurik.com Git - wxWidgets.git/commitdiff
* Build IODBC on demand on unix.
authorGuilhem Lavaux <lavaux@easynet.fr>
Wed, 28 Oct 1998 18:29:51 +0000 (18:29 +0000)
committerGuilhem Lavaux <lavaux@easynet.fr>
Wed, 28 Oct 1998 18:29:51 +0000 (18:29 +0000)
* wxStream updates

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

configure
configure.in
include/wx/fstream.h
include/wx/stream.h
setup/maketmpl.in
setup/substit.in
src/Makefile.in
src/common/fstream.cpp
src/common/stream.cpp
src/gtk/dcscreen.cpp
src/gtk1/dcscreen.cpp

index 6973a521d1d000baf2725b08c2a31a77bab5faf8..93da230c0f8ecd3ecb1aa95e38f9bd584d383750 100755 (executable)
--- a/configure
+++ b/configure
@@ -6289,14 +6289,17 @@ EOF
  
 fi
 
+IODBC_C_SRC=""
 if test "$wxUSE_ODBC" = 1 ; then
   cat >> confdefs.h <<EOF
 #define wxUSE_ODBC $wxUSE_ODBC
 EOF
  
+  IODBC_C_SRC="\$(IODBC_C_SRC)"
 fi
 
 
+
 if test "$wxUSE_GAUGE" = 1 ; then
   cat >> confdefs.h <<EOF
 #define wxUSE_GAUGE $wxUSE_GAUGE
@@ -7274,6 +7277,7 @@ s%@WXDEBUG_DEFINE@%$WXDEBUG_DEFINE%g
 s%@EXTRA_LINK@%$EXTRA_LINK%g
 s%@PROFILE@%$PROFILE%g
 s%@OPTIMISE@%$OPTIMISE%g
+s%@IODBC_C_SRC@%$IODBC_C_SRC%g
 s%@METAFILE@%$METAFILE%g
 s%@HELP@%$HELP%g
 s%@WXGRAPH@%$WXGRAPH%g
index 9b6412d9639a516902521a54f9ad773eabe8c99c..ce06d5a83a44bf827983adddeb03c00623b9ac85 100644 (file)
@@ -1151,9 +1151,12 @@ if test "$wxUSE_LIBPNG" = 1 ; then
   AC_DEFINE_UNQUOTED(wxUSE_LIBPNG,$wxUSE_LIBPNG) 
 fi
 
+IODBC_C_SRC=""
 if test "$wxUSE_ODBC" = 1 ; then
   AC_DEFINE_UNQUOTED(wxUSE_ODBC,$wxUSE_ODBC) 
+  IODBC_C_SRC="\$(IODBC_C_SRC)"
 fi
+AC_SUBST(IODBC_C_SRC)
 
 dnl ----------------------------------------------------------------
 dnl Register GUI-control options for makefiles and setup.h
index 76a78cf227618ce39daef22ffbf075a239889e9c..b67ba0800e3000df2a5adcfd9529cbbdea15e95a 100644 (file)
@@ -26,9 +26,10 @@ class wxFileInputStream: public wxInputStream {
   wxFileInputStream(const wxString& ifileName);
   wxFileInputStream(wxFile& file);
   wxFileInputStream(int fd);
-  virtual ~wxFileInputStream();
+  ~wxFileInputStream();
 
-  virtual char Peek();
+  char Peek();
+  size_t StreamSize() const;
 
   bool Ok() const { return m_file->IsOpened(); }
 
@@ -56,6 +57,7 @@ class wxFileOutputStream: public wxOutputStream {
      { return wxOutputStream::Write(buffer, size); }
 
   void Sync();
+  size_t StreamSize() const;
 
   bool Ok() const { return m_file->IsOpened(); }
 
@@ -71,4 +73,9 @@ class wxFileOutputStream: public wxOutputStream {
   bool m_file_destroy;
 };
 
+class wxFileStream: public wxFileInputStream, public wxFileOutputStream {
+ public:
+  wxFileStream(const wxString& fileName);
+};
+
 #endif
index 1e6e6fad85859a111bf076f24914f7bd16c39e73..df2cf2efe0fd4a46ced730d2e7c9480e891daf36 100644 (file)
@@ -37,13 +37,15 @@ wxOutputStream& WXDLLEXPORT wxEndL(wxOutputStream& o_stream);
 class WXDLLEXPORT wxStreamBuffer {
  public:
   typedef enum {
-    read, write
+    read, write, read_write
   } BufMode;
 
   // -----------
   // ctor & dtor
   // -----------
   wxStreamBuffer(wxStreamBase& stream, BufMode mode);
+  wxStreamBuffer(BufMode mode);
+  wxStreamBuffer(const wxStreamBuffer& buf);
   ~wxStreamBuffer();
 
   // -----------
@@ -53,6 +55,8 @@ class WXDLLEXPORT wxStreamBuffer {
   void Write(const void *buffer, size_t size);
   bool WriteBack(const char *buffer, size_t size);
   bool WriteBack(char c);
+  char GetChar();
+  void PutChar(char c);
   off_t Tell() const;
   off_t Seek(off_t pos, wxSeekMode mode);
 
@@ -68,7 +72,9 @@ class WXDLLEXPORT wxStreamBuffer {
   off_t GetIntPosition() const { return m_buffer_pos-m_buffer_start; }
   void SetIntPosition(off_t pos) { m_buffer_pos = m_buffer_start+pos; }
   size_t GetLastAccess() const { return m_buffer_end-m_buffer_start; }
+
   void Fixed(bool fixed) { m_fixed = fixed; }
+  void Flushable(bool f) { m_flushable = f; }
 
   bool FlushBuffer();
   bool FillBuffer();
@@ -88,10 +94,11 @@ class WXDLLEXPORT wxStreamBuffer {
   char *m_wback;
   size_t m_wbacksize, m_wbackcur;
 
-  bool m_fixed;
+  bool m_fixed, m_flushable;
 
   wxStreamBase *m_stream;
   BufMode m_mode;
+  bool m_destroybuf;
 };
 
 // ---------------------------------------------------------------------------
@@ -108,7 +115,8 @@ class WXDLLEXPORT wxStreamBase {
   wxStreamBase();
   virtual ~wxStreamBase();
 
-  wxStreamError LastError() { return m_lasterror; }
+  wxStreamError LastError() const { return m_lasterror; }
+  virtual size_t StreamSize() const { return ~((size_t)0); }
 
  protected:
   friend class wxStreamBuffer;
@@ -116,7 +124,7 @@ class WXDLLEXPORT wxStreamBase {
   virtual size_t OnSysRead(void *buffer, size_t bufsize);
   virtual size_t OnSysWrite(const void *buffer, size_t bufsize);
   virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
-  virtual off_t OnSysTell();
+  virtual off_t OnSysTell() const;
 
  protected:
   size_t m_lastcount;
@@ -220,6 +228,9 @@ class WXDLLEXPORT wxFilterInputStream: public wxInputStream {
 
   char Peek() { return m_parent_i_stream->Peek(); }
 
+  wxStreamError LastError() const { return m_parent_i_stream->LastError(); }
+  size_t StreamSize() const { return m_parent_i_stream->StreamSize(); }
+
  protected:
   wxInputStream *m_parent_i_stream;
 };
@@ -230,6 +241,9 @@ class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream {
   wxFilterOutputStream(wxOutputStream& stream);
   ~wxFilterOutputStream();
 
+  wxStreamError LastError() const { return m_parent_o_stream->LastError(); }
+  size_t StreamSize() const { return m_parent_o_stream->StreamSize(); }
+
  protected:
   wxOutputStream *m_parent_o_stream;
 };
index 1c9a405bfbccc24a4bf565caf855a689450e624d..2f8913b548739712944a8023fc38473bdb35edbe 100644 (file)
@@ -98,6 +98,7 @@ $(TOOLKIT_DEF) \
 -I.. \
 -I$(WXBASEDIR)/include \
 -I$(WXBASEDIR)/src/zlib \
+-I$(WXBASEDIR)/src/iodbc \
 $(GUI_TK_INCLUDE) \
 $(OPENGL_INCLUDE) \
 $(X_CFLAGS)
index 5cd1cc24a27183f7e9c92b661244af2a2d8e9b98..5431110ed9407d8ca888a08858f6f14530a7f7b8 100644 (file)
@@ -47,3 +47,4 @@ s|*THREADS_LINK*|@THREADS_LINK@|g
 s|*EXTRA_LINK*|@EXTRA_LINK@|g
 s|*GTK_JOYSTICK*|@GTK_JOYSTICK@|g
 s|*UNIX_THREAD*|@UNIX_THREAD@|g
+s|*IOBC_C_SRC*|@IODBC_C_SRC@|g
index 7ec517ec58b052fbd310a618dfdfbc8017f363ab..a9aa36a0e23fe9704d811f72ddb337fbbcecd6e9 100644 (file)
@@ -14,6 +14,23 @@ OS=@OS@
 RULE=gslib
 
 # define common stuff
+IODBC_C_SRC=\
+  iodbc/catalog.c \
+  iodbc/connect.c \
+  iodbc/dlf.c \
+  iodbc/dlproc.c \
+  iodbc/execute.c \
+  iodbc/fetch.c \
+  iodbc/hdbc.c \
+  iodbc/henv.c \
+  iodbc/herr.c \
+  iodbc/hstmt.c \
+  iodbc/info.c \
+  iodbc/itrace.c \
+  iodbc/main.c \
+  iodbc/misc.c \
+  iodbc/prepare.c \
+  iodbc/result.c
 
 # include gtk.inc, qt.inc or motif.inc here
 include @MAKEINCLUDE@
@@ -24,7 +41,7 @@ SHARED_LIBRARY=lib$(LIB_TARGET).so.$(LIB_MAJOR).$(LIB_MINOR)
 
 LIB_CPP_ALL_SRC=$(LIB_CPP_SRC) @GTK_JOYSTICK@ @UNIX_THREAD@
 
-LIB_C_ALL_SRC=$(LIB_C_SRC) parser.c
+LIB_C_ALL_SRC=$(LIB_C_SRC) @IOBC_C_SRC@ parser.c
 
 #define library objects
 LIB_OBJ=\
index 7012e2b20a5fbd222f3fc22330b4f1ce03432962..e631cde60df3e42f635dd662b7f48177b7f69c45 100644 (file)
@@ -53,6 +53,11 @@ char wxFileInputStream::Peek()
   return 0;
 }
 
+size_t wxFileInputStream::StreamSize() const
+{
+  return m_file->Length();
+}
+
 size_t wxFileInputStream::OnSysRead(void *buffer, size_t size)
 {
   return m_file->Read(buffer, size);
@@ -79,6 +84,13 @@ wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
   m_o_streambuf->SetBufferIO(1024);
 }
 
+wxFileOutputStream::wxFileOutputStream(wxFile& file)
+{
+  m_file = &file;
+  m_file_destroy = FALSE;
+  m_o_streambuf->SetBufferIO(1024);
+}
+
 wxFileOutputStream::wxFileOutputStream()
   : wxOutputStream()
 {
@@ -117,3 +129,16 @@ void wxFileOutputStream::Sync()
   wxOutputStream::Sync();
   m_file->Flush();
 }
+
+size_t wxFileOutputStream::StreamSize() const
+{
+  return m_file->Length();
+}
+
+// ----------------------------------------------------------------------------
+// wxFileStream
+// ----------------------------------------------------------------------------
+wxFileStream::wxFileStream(const wxString& fileName)
+ : wxFileInputStream(fileName), wxFileOutputStream(*wxFileInputStream::m_file)
+{
+}
index ecedf6b10608ee7398ecf4ec1bde547faa1851b1..2bce4c881e6bfd085de81883273030d009c72d16 100644 (file)
 
 wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode)
   : m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
-    m_buffer_size(0), m_stream(&stream), m_mode(mode)
+    m_buffer_size(0), m_fixed(TRUE), m_flushable(TRUE), m_stream(&stream),
+    m_mode(mode), m_destroybuf(FALSE)
 {
 }
 
+wxStreamBuffer::wxStreamBuffer(BufMode mode)
+  : m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
+    m_buffer_size(0), m_fixed(TRUE), m_flushable(FALSE), m_stream(NULL),
+    m_mode(mode), m_destroybuf(FALSE)
+{
+}
+
+wxStreamBuffer::wxStreamBuffer(const wxStreamBuffer& buffer)
+{
+  m_buffer_start = buffer.m_buffer_start;
+  m_buffer_end = buffer.m_buffer_end;
+  m_buffer_pos = buffer.m_buffer_pos;
+  m_buffer_size = buffer.m_buffer_size;
+  m_fixed = buffer.m_fixed;
+  m_flushable = buffer.m_flushable;
+  m_stream = buffer.m_stream;
+  m_mode = buffer.m_mode;
+  m_destroybuf = FALSE;
+}
+
 wxStreamBuffer::~wxStreamBuffer()
 {
-  wxDELETEA(m_buffer_start);
+  if (m_destroybuf)
+    wxDELETEA(m_buffer_start);
 }
 
 bool wxStreamBuffer::WriteBack(const char *buf, size_t bufsize)
@@ -65,10 +87,13 @@ bool wxStreamBuffer::WriteBack(char c)
 
 void wxStreamBuffer::SetBufferIO(char *buffer_start, char *buffer_end)
 {
+  if (m_destroybuf)
+    wxDELETEA(m_buffer_start);
   m_buffer_start = buffer_start;
   m_buffer_end   = buffer_end;
 
   m_buffer_size = m_buffer_end-m_buffer_start;
+  m_destroybuf = FALSE;
   ResetBuffer();
 }
 
@@ -87,8 +112,8 @@ void wxStreamBuffer::SetBufferIO(size_t bufsize)
   }
 
   b_start = new char[bufsize];
-
   SetBufferIO(b_start, b_start + bufsize);
+  m_destroybuf = TRUE;
 }
 
 void wxStreamBuffer::ResetBuffer()
@@ -152,7 +177,7 @@ bool wxStreamBuffer::FlushBuffer()
 {
   size_t count, current;
 
-  if (m_buffer_pos == m_buffer_start)
+  if (m_buffer_pos == m_buffer_start || !m_flushable)
     return FALSE;
 
   current = m_buffer_pos-m_buffer_start;
@@ -182,6 +207,7 @@ void wxStreamBuffer::PutToBuffer(const void *buffer, size_t size)
   if (s_toput < size && !m_fixed) {
     m_buffer_start = (char *)realloc(m_buffer_start, m_buffer_size+size);
     // I round a bit
+    m_buffer_size += size;
     m_buffer_end = m_buffer_start+m_buffer_size;
     s_toput = size;
   }
@@ -191,6 +217,41 @@ void wxStreamBuffer::PutToBuffer(const void *buffer, size_t size)
   m_buffer_pos += s_toput;
 }
 
+void wxStreamBuffer::PutChar(char c)
+{
+  wxASSERT(m_stream != NULL);
+
+  if (!m_buffer_size) {
+    m_stream->OnSysWrite(&c, 1);
+    return;
+  }
+
+  if (!GetDataLeft() && !FlushBuffer())
+    return;
+
+  PutToBuffer(&c, 1);
+  m_stream->m_lastcount = 1;
+}
+
+char wxStreamBuffer::GetChar()
+{
+  char c;
+
+  wxASSERT(m_stream != NULL);
+
+  if (!m_buffer_size) {
+    m_stream->OnSysRead(&c, 1);
+    return c;
+  }
+
+  if (!GetDataLeft() && !FillBuffer())
+    return 0;
+
+  GetFromBuffer(&c, 1);
+  m_stream->m_lastcount = 1;
+  return c;
+}
+
 void wxStreamBuffer::Read(void *buffer, size_t size)
 {
   wxASSERT(m_stream != NULL);
@@ -220,7 +281,7 @@ void wxStreamBuffer::Read(void *buffer, size_t size)
     buf_left = GetDataLeft(); 
 
     // First case: the requested buffer is larger than the stream buffer,
-    //             we split
+    //             we split it.
     if (size > buf_left) {
       GetFromBuffer(buffer, buf_left);
       size  -= buf_left;
@@ -291,6 +352,14 @@ off_t wxStreamBuffer::Seek(off_t pos, wxSeekMode mode)
 
   last_access = GetLastAccess();
 
+  if (m_fixed) {
+    diff = pos + GetIntPosition();
+    if (diff < 0 || diff > last_access)
+      return wxInvalidOffset;
+    SetIntPosition(diff);
+    return diff;
+  }
+
   switch (mode) {
   case wxFromStart: {
     // We'll try to compute an internal position later ...
@@ -323,11 +392,13 @@ off_t wxStreamBuffer::Tell() const
 {
   off_t pos;
 
-  pos = m_stream->OnSysTell();
-  if (pos == wxInvalidOffset)
-    return wxInvalidOffset;
-
-  return pos - GetLastAccess() + GetIntPosition();
+  if (!m_fixed) {
+    pos = m_stream->OnSysTell();
+    if (pos == wxInvalidOffset)
+      return wxInvalidOffset;
+    return pos - GetLastAccess() + GetIntPosition();
+  } else
+    return GetIntPosition();
 }
 
 size_t wxStreamBuffer::GetDataLeft() const
@@ -364,7 +435,7 @@ off_t wxStreamBase::OnSysSeek(off_t seek, wxSeekMode mode)
   return wxInvalidOffset;
 }
 
-off_t wxStreamBase::OnSysTell()
+off_t wxStreamBase::OnSysTell() const
 {
   return wxInvalidOffset;
 }
index ed085d15d77c2170a375c10e86ffb8e867ee6661..3159c410c07f45cbfb4cf21d769abd3b39ba8083 100644 (file)
@@ -209,7 +209,11 @@ gdk_window_transparent_new ( GdkWindow     *parent,
   if (attributes_mask & GDK_WA_TITLE)
     title = attributes->title;
   else
+#if (GTK_MINOR_VERSION == 1)
+    title = "Unknown"; // GLH: Well I don't know for the moment what to write here.
+#else
     title = gdk_progname;
+#endif
 
   XmbSetWMProperties (gprivate->xdisplay, gprivate->xwindow,
                       title, title,
index ed085d15d77c2170a375c10e86ffb8e867ee6661..3159c410c07f45cbfb4cf21d769abd3b39ba8083 100644 (file)
@@ -209,7 +209,11 @@ gdk_window_transparent_new ( GdkWindow     *parent,
   if (attributes_mask & GDK_WA_TITLE)
     title = attributes->title;
   else
+#if (GTK_MINOR_VERSION == 1)
+    title = "Unknown"; // GLH: Well I don't know for the moment what to write here.
+#else
     title = gdk_progname;
+#endif
 
   XmbSetWMProperties (gprivate->xdisplay, gprivate->xwindow,
                       title, title,