summaryrefslogtreecommitdiff
path: root/hhvm/streambuf.cpp
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-04-09 11:00:05 +0600
committervalmat <ufabiz@gmail.com>2014-04-09 11:00:05 +0600
commit6c7c846edd5b74450b76532da33c25e6cc6a10a4 (patch)
tree51b0e0be5c43ddba6ca9351026fc94bf8ae7bc07 /hhvm/streambuf.cpp
parent08ed8866a5bba0b23a8d5587116a968512df2568 (diff)
parent33760c3efba4207eac826ff080b5f9b9672fc60e (diff)
Merge branch 'master' into ini-master
Conflicts: include/namespace.h zend/extensionimpl.cpp
Diffstat (limited to 'hhvm/streambuf.cpp')
-rw-r--r--hhvm/streambuf.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/hhvm/streambuf.cpp b/hhvm/streambuf.cpp
new file mode 100644
index 0000000..805fc0f
--- /dev/null
+++ b/hhvm/streambuf.cpp
@@ -0,0 +1,59 @@
+/**
+ * StreamBuf.cpp
+ *
+ * Implementation file for the StreamBuf class
+ *
+ * @see http://www.mr-edd.co.uk/blog/beginners_guide_streambuf
+ *
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ * @copyright 2014 Copernica BV
+ */
+#include "includes.h"
+
+/**
+ * Set up namespace
+ */
+namespace Php {
+
+/**
+ * Called when the internal buffer should be synchronized
+ * @return int
+ */
+int StreamBuf::sync()
+{
+ // current buffer size
+ size_t size = pptr() - pbase();
+
+ // is this the error stream or the regular output stream?
+ if (_error)
+ {
+ // write to error (the zend_error() method is a varargs function,
+ // which means that we have to include a printf() like format as first
+ // parameter. We can not specify pbase() directly, because (1) it is
+ // not null terminated and (2) it could contain % signs and allow all
+ // sorts of buffer overflows.
+
+ // @todo hhvm implementation
+
+// zend_error(_error, "%.*s", (int)size, pbase());
+
+ }
+ else
+ {
+ // @todo hhvm implementation
+
+ // write to zend
+// zend_write(pbase(), size);
+ }
+
+ // reset the buffer
+ pbump(-size);
+
+ // done
+ return 0;
+}
+
+/**
+ * End namespace
+ */
+}