summaryrefslogtreecommitdiff
path: root/lib/common/FdGetLine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common/FdGetLine.cpp')
-rw-r--r--lib/common/FdGetLine.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/common/FdGetLine.cpp b/lib/common/FdGetLine.cpp
index 9b53288b..2d2f7c6a 100644
--- a/lib/common/FdGetLine.cpp
+++ b/lib/common/FdGetLine.cpp
@@ -20,6 +20,7 @@
#include "MemLeakFindOn.h"
+<<<<<<< HEAD
// utility whitespace function
inline bool iw(int c)
{
@@ -27,6 +28,8 @@ inline bool iw(int c)
}
+=======
+>>>>>>> 0.12
// --------------------------------------------------------------------------
//
// Function
@@ -36,12 +39,16 @@ inline bool iw(int c)
//
// --------------------------------------------------------------------------
FdGetLine::FdGetLine(int fd)
+<<<<<<< HEAD
: mFileHandle(fd),
mLineNumber(0),
mBufferBegin(0),
mBytesInBuffer(0),
mPendingEOF(false),
mEOF(false)
+=======
+: mFileHandle(fd)
+>>>>>>> 0.12
{
if(mFileHandle < 0) {THROW_EXCEPTION(CommonException, BadArguments)}
//printf("FdGetLine buffer size = %d\n", sizeof(mBuffer));
@@ -74,6 +81,7 @@ FdGetLine::~FdGetLine()
std::string FdGetLine::GetLine(bool Preprocess)
{
if(mFileHandle == -1) {THROW_EXCEPTION(CommonException, GetLineNoHandle)}
+<<<<<<< HEAD
// EOF?
if(mEOF) {THROW_EXCEPTION(CommonException, GetLineEOF)}
@@ -194,6 +202,55 @@ std::string FdGetLine::GetLine(bool Preprocess)
// Return a sub string
return r.substr(begin, end - begin + 1);
}
+=======
+
+ std::string r;
+ bool result = GetLineInternal(r, Preprocess);
+
+ if(!result)
+ {
+ // should never fail for FdGetLine
+ THROW_EXCEPTION(CommonException, Internal);
+ }
+
+ return r;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Function
+// Name: FdGetLine::ReadMore()
+// Purpose: Read more bytes from the handle, possible the
+// console, into mBuffer and return the number of
+// bytes read, 0 on EOF or -1 on error.
+// Created: 2011/04/22
+//
+// --------------------------------------------------------------------------
+int FdGetLine::ReadMore(int Timeout)
+{
+ int bytes;
+
+#ifdef WIN32
+ if (mFileHandle == _fileno(stdin))
+ {
+ bytes = console_read(mBuffer, sizeof(mBuffer));
+ }
+ else
+ {
+ bytes = ::read(mFileHandle, mBuffer, sizeof(mBuffer));
+ }
+#else // !WIN32
+ bytes = ::read(mFileHandle, mBuffer, sizeof(mBuffer));
+#endif // WIN32
+
+ if(bytes == 0)
+ {
+ mPendingEOF = true;
+ }
+
+ return bytes;
+>>>>>>> 0.12
}
@@ -202,7 +259,11 @@ std::string FdGetLine::GetLine(bool Preprocess)
// Function
// Name: FdGetLine::DetachFile()
// Purpose: Detaches the file handle, setting the file pointer correctly.
+<<<<<<< HEAD
// Probably not good for sockets...
+=======
+// Probably not good for sockets...
+>>>>>>> 0.12
// Created: 2003/07/24
//
// --------------------------------------------------------------------------
@@ -225,4 +286,7 @@ void FdGetLine::DetachFile()
mFileHandle = -1;
}
+<<<<<<< HEAD
+=======
+>>>>>>> 0.12