Panda3D
bioStreamBuf.h
1 // Filename: bioStreamBuf.h
2 // Created by: drose (25Sep02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BIOSTREAMBUF_H
16 #define BIOSTREAMBUF_H
17 
18 #include "pandabase.h"
19 
20 // This module is not compiled if OpenSSL is not available.
21 #ifdef HAVE_OPENSSL
22 #define OPENSSL_NO_KRB5
23 
24 #include "bioPtr.h"
25 #include "pointerTo.h"
26 #include "openSSLWrapper.h" // must be included before any other openssl.
27 #include "openssl/ssl.h"
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : BioStreamBuf
31 // Description : The streambuf object that implements
32 // IBioStream.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDAEXPRESS BioStreamBuf : public streambuf {
35 public:
36  BioStreamBuf();
37  virtual ~BioStreamBuf();
38 
39  void open(BioPtr *source);
40  void close();
41 
42 protected:
43  virtual int overflow(int c);
44  virtual int sync();
45  virtual int underflow();
46 
47 private:
48  size_t write_chars(const char *start, size_t length);
49 
50  PT(BioPtr) _source;
51  bool _read_open;
52  bool _write_open;
53  char *_buffer;
54 
55  friend class IBioStream;
56  friend class OBioStream;
57  friend class BioStream;
58 };
59 
60 #endif // HAVE_OPENSSL
61 
62 #endif