From 77e9a8bb42285c118a8a0d51fa166d838cc9f473 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Fri, 20 Dec 2013 20:23:03 -0800 Subject: Switching off_t to off64_t. --- src/BStream.cc | 2 +- src/Buffer.cc | 14 +++++++------- src/Handle.cc | 22 +++++++++++----------- src/HttpServer.cc | 3 ++- src/Input.cc | 8 ++++---- src/Output.cc | 6 +++--- 6 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/BStream.cc b/src/BStream.cc index 2fe75c7..3a3f972 100644 --- a/src/BStream.cc +++ b/src/BStream.cc @@ -22,7 +22,7 @@ bool Balau::BStream::isClosed() { return m_closed || m_h->isClosed(); } bool Balau::BStream::isEOF() { return (m_availBytes == 0) && m_h->isEOF(); } bool Balau::BStream::canRead() { return true; } const char * Balau::BStream::getName() { return m_name.to_charp(); } -off_t Balau::BStream::getSize() { return m_h->getSize(); } +off64_t Balau::BStream::getSize() { return m_h->getSize(); } ssize_t Balau::BStream::read(void * _buf, size_t count) throw (Balau::GeneralException) { if (m_passThru) diff --git a/src/Buffer.cc b/src/Buffer.cc index 25639b7..42dbd52 100644 --- a/src/Buffer.cc +++ b/src/Buffer.cc @@ -19,10 +19,10 @@ void Balau::Buffer::close() throw (GeneralException) { } ssize_t Balau::Buffer::read(void * buf, size_t count) throw (GeneralException) { - off_t cursor = rtell(); + off64_t cursor = rtell(); if (cursor >= m_bufSize) return 0; - off_t avail = m_bufSize - cursor; + off64_t avail = m_bufSize - cursor; if (count > avail) count = avail; @@ -38,10 +38,10 @@ ssize_t Balau::Buffer::write(const void * buf, size_t count) throw (GeneralExcep if (m_fromConst) throw GeneralException("Buffer is read only and can't be written to."); - off_t cursor = wtell(); - off_t end = cursor + count; - off_t endBlock = (end / s_blockSize) + ((end % s_blockSize) ? 1 : 0); - off_t oldEndBlock = m_numBlocks; + off64_t cursor = wtell(); + off64_t end = cursor + count; + off64_t endBlock = (end / s_blockSize) + ((end % s_blockSize) ? 1 : 0); + off64_t oldEndBlock = m_numBlocks; if (endBlock > oldEndBlock) { m_buffer = (uint8_t *) realloc(m_buffer, endBlock * s_blockSize); @@ -71,6 +71,6 @@ void Balau::Buffer::reset() { bool Balau::Buffer::isClosed() { return false; } bool Balau::Buffer::isEOF() { return rtell() == m_bufSize; } const char * Balau::Buffer::getName() { return "Buffer"; } -off_t Balau::Buffer::getSize() { return m_bufSize; } +off64_t Balau::Buffer::getSize() { return m_bufSize; } bool Balau::Buffer::canRead() { return true; } bool Balau::Buffer::canWrite() { return !m_fromConst; } diff --git a/src/Handle.cc b/src/Handle.cc index c1542ac..79b81c8 100644 --- a/src/Handle.cc +++ b/src/Handle.cc @@ -27,7 +27,7 @@ static const char * strerror_r(int errorno, char * buf, size_t bufsize) { bool Balau::Handle::canSeek() { return false; } bool Balau::Handle::canRead() { return false; } bool Balau::Handle::canWrite() { return false; } -off_t Balau::Handle::getSize() { return -1; } +off64_t Balau::Handle::getSize() { return -1; } time_t Balau::Handle::getMTime() { return -1; } ssize_t Balau::Handle::read(void * buf, size_t count) throw (GeneralException) { @@ -168,33 +168,33 @@ Balau::Future Balau::Handle::writeI16(int16_t v) { return genericWrite Balau::Handle::writeI32(int32_t v) { return genericWrite(this, v); } Balau::Future Balau::Handle::writeI64(int64_t v) { return genericWrite(this, v); } -void Balau::Handle::rseek(off_t offset, int whence) throw (GeneralException) { +void Balau::Handle::rseek(off64_t offset, int whence) throw (GeneralException) { if (canSeek()) throw GeneralException(String("Handle ") + getName() + " can seek, but rseek() not implemented (missing in class " + ClassName(this).c_str() + ")"); else throw GeneralException("Handle can't seek"); } -void Balau::Handle::wseek(off_t offset, int whence) throw (GeneralException) { +void Balau::Handle::wseek(off64_t offset, int whence) throw (GeneralException) { rseek(offset, whence); } -off_t Balau::Handle::rtell() throw (GeneralException) { +off64_t Balau::Handle::rtell() throw (GeneralException) { if (canSeek()) throw GeneralException(String("Handle ") + getName() + " can seek, but rtell() not implemented (missing in class " + ClassName(this).c_str() + ")"); else throw GeneralException("Handle can't seek"); } -off_t Balau::Handle::wtell() throw (GeneralException) { +off64_t Balau::Handle::wtell() throw (GeneralException) { return rtell(); } bool Balau::SeekableHandle::canSeek() { return true; } -void Balau::SeekableHandle::rseek(off_t offset, int whence) throw (GeneralException) { +void Balau::SeekableHandle::rseek(off64_t offset, int whence) throw (GeneralException) { AAssert(canRead() || canWrite(), "Can't use a SeekableHandle with a Handle that can neither read or write..."); - off_t size; + off64_t size; if (!canRead()) wseek(offset, whence); switch (whence) { @@ -215,9 +215,9 @@ void Balau::SeekableHandle::rseek(off_t offset, int whence) throw (GeneralExcept m_rOffset = 0; } -void Balau::SeekableHandle::wseek(off_t offset, int whence) throw (GeneralException) { +void Balau::SeekableHandle::wseek(off64_t offset, int whence) throw (GeneralException) { AAssert(canRead() || canWrite(), "Can't use a SeekableHandle with a Handle that can neither read or write..."); - off_t size; + off64_t size; if (!canWrite()) rseek(offset, whence); switch (whence) { @@ -238,14 +238,14 @@ void Balau::SeekableHandle::wseek(off_t offset, int whence) throw (GeneralExcept m_wOffset = 0; } -off_t Balau::SeekableHandle::rtell() throw (GeneralException) { +off64_t Balau::SeekableHandle::rtell() throw (GeneralException) { AAssert(canRead() || canWrite(), "Can't use a SeekableHandle with a Handle that can neither read or write..."); if (!canRead()) return wtell(); return m_rOffset; } -off_t Balau::SeekableHandle::wtell() throw (GeneralException) { +off64_t Balau::SeekableHandle::wtell() throw (GeneralException) { AAssert(canRead() || canWrite(), "Can't use a SeekableHandle with a Handle that can neither read or write..."); if (!canWrite()) return rtell(); diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 3abf776..4a3e086 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -225,7 +225,7 @@ void Balau::HttpWorker::sendError(int error, const char * msg, const char * deta } else { IO errorText(new Buffer); tpl->render(errorText, &ctx); - off_t length = errorText->getSize(); + off64_t length = errorText->getSize(); String headers; headers.set( "HTTP/1.1 %i %s\r\n" @@ -272,6 +272,7 @@ bool Balau::HttpWorker::handleClient() { yield(); continue; } + Printer::log(M_DEBUG, "HTTPIN: %s", line.to_charp()); // until we get a blank line if (line == "") break; diff --git a/src/Input.cc b/src/Input.cc index 64a05ec..87d9be3 100644 --- a/src/Input.cc +++ b/src/Input.cc @@ -217,10 +217,10 @@ namespace { class AsyncOpRead : public Balau::AsyncOperation { public: - AsyncOpRead(int fd, void * buf, size_t count, off_t offset, cbResults_t * results) : m_fd(fd), m_buf(buf), m_count(count), m_offset(offset), m_results(results) { } + AsyncOpRead(int fd, void * buf, size_t count, off64_t offset, cbResults_t * results) : m_fd(fd), m_buf(buf), m_count(count), m_offset(offset), m_results(results) { } virtual void run() { #ifdef _MSC_VER - off_t offset = lseek(m_fd, m_offset, SEEK_SET); + off64_t offset = lseek(m_fd, m_offset, SEEK_SET); if (offset < 0) { m_results->errorno = errno; return; @@ -239,7 +239,7 @@ class AsyncOpRead : public Balau::AsyncOperation { int m_fd; void * m_buf; size_t m_count; - off_t m_offset; + off64_t m_offset; cbResults_t * m_results; }; @@ -304,7 +304,7 @@ const char * Balau::Input::getName() { return m_name.to_charp(); } -off_t Balau::Input::getSize() { +off64_t Balau::Input::getSize() { return m_size; } diff --git a/src/Output.cc b/src/Output.cc index 0d5972d..0ace38e 100644 --- a/src/Output.cc +++ b/src/Output.cc @@ -217,7 +217,7 @@ namespace { class AsyncOpWrite : public Balau::AsyncOperation { public: - AsyncOpWrite(int fd, const void * buf, size_t count, off_t offset, cbResults_t * results) : m_fd(fd), m_buf(buf), m_count(count), m_offset(offset), m_results(results) { } + AsyncOpWrite(int fd, const void * buf, size_t count, off64_t offset, cbResults_t * results) : m_fd(fd), m_buf(buf), m_count(count), m_offset(offset), m_results(results) { } virtual void run() { #ifdef _MSC_VER IAssert(0, "Not yet implemented"); @@ -235,7 +235,7 @@ class AsyncOpWrite : public Balau::AsyncOperation { int m_fd; const void * m_buf; size_t m_count; - off_t m_offset; + off64_t m_offset; cbResults_t * m_results; }; @@ -300,7 +300,7 @@ const char * Balau::Output::getName() { return m_name.to_charp(); } -off_t Balau::Output::getSize() { +off64_t Balau::Output::getSize() { return m_size; } -- cgit v1.2.3