|
From: <bni...@us...> - 2006-12-08 22:43:44
|
Revision: 417
http://svn.sourceforge.net/omc/?rev=417&view=rev
Author: bnicholes
Date: 2006-12-08 14:43:44 -0800 (Fri, 08 Dec 2006)
Log Message:
-----------
Make sure that the command terminator is recognized as a LF, CR or CRLF
Modified Paths:
--------------
clp/trunk/src/omcclpdsvrconnection.cpp
clp/trunk/src/omcclpdsvrconnection.h
Modified: clp/trunk/src/omcclpdsvrconnection.cpp
===================================================================
--- clp/trunk/src/omcclpdsvrconnection.cpp 2006-12-08 22:41:31 UTC (rev 416)
+++ clp/trunk/src/omcclpdsvrconnection.cpp 2006-12-08 22:43:44 UTC (rev 417)
@@ -36,6 +36,7 @@
#include <openwbem/OW_SortedVectorMap.hpp>
#include <openwbem/OW_StringBuffer.hpp>
#include <openwbem/OW_ThreadCancelledException.hpp>
+#include <iostream>
#if defined(BAD)
#undef BAD
@@ -92,7 +93,44 @@
OW_LOG_DEBUG(m_pServer->getEnv()->getLogger(COMPONENT_NAME),
"OMCClpdSvrConnection object destroyed");
}
+
//////////////////////////////////////////////////////////////////////////////
+// Get one line from an input stream. This StringBuffer object will be
+// reset (cleared) before an attempt is made to retrieve the line.
+const String OMCClpdSvrConnection::getLine(std::istream& is)
+{
+ String bfr;
+
+ if (is)
+ {
+ size_t count = 0;
+ std::streambuf *sb = is.rdbuf();
+
+ while (1)
+ {
+ int ch = sb->sbumpc();
+ if (ch == EOF)
+ {
+ is.setstate(count == 0
+ ? (std::ios::failbit | std::ios::eofbit) : std::ios::eofbit);
+ break;
+ }
+
+ ++count;
+
+ if ((ch == '\n') || (ch == '\r'))
+ {
+ break;
+ }
+
+ bfr += String((char)ch);
+ }
+ }
+
+ return bfr;
+}
+
+//////////////////////////////////////////////////////////////////////////////
void
OMCClpdSvrConnection::run()
{
@@ -128,7 +166,7 @@
{
if (!firstLine)
{
- String line = String::getLine(sistr);
+ String line = getLine(sistr);
OW_LOG_DEBUG(logger,
Format("OMCClpdSvrConnection received line: %1", line));
Modified: clp/trunk/src/omcclpdsvrconnection.h
===================================================================
--- clp/trunk/src/omcclpdsvrconnection.h 2006-12-08 22:41:31 UTC (rev 416)
+++ clp/trunk/src/omcclpdsvrconnection.h 2006-12-08 22:43:44 UTC (rev 417)
@@ -76,6 +76,8 @@
protected:
+ const String getLine(std::istream& is);
+
private:
OMCClpdServer* m_pServer;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|