[SVN-NetXMS] revision 3292

From: NetXMS.org SVN Server <svn_at_DOMAIN_REMOVED>
Date: Mon, 2 Jun 2008 16:09:05 +0300

* { font-family: Consolas, Lucida Console, Courier New; font-size: 100%; }
h1 { font-size: 150%; }
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 100%; width: 100%; }
.highlight span { width: 100%; display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline; }
body { background: #ffffff; }
body .c { color: #999988; font-style: italic } /* Comment */
body .err { color: #a61717; background-color: #e3d2d2 } /* Error */
body .k { font-weight: bold } /* Keyword */
body .o { font-weight: bold } /* Operator */
body .cm { color: #999988; font-style: italic } /* Comment.Multiline */
body .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
body .c1 { color: #999988; font-style: italic } /* Comment.Single */
body .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
body .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #aa0000 } /* Generic.Error */
body .gh { color: #999999 } /* Generic.Heading */
body .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
body .go { color: #888888 } /* Generic.Output */
body .gp { color: #555555 } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #aaaaaa } /* Generic.Subheading */
body .gt { color: #aa0000 } /* Generic.Traceback */
body .kc { font-weight: bold } /* Keyword.Constant */
body .kd { font-weight: bold } /* Keyword.Declaration */
body .kp { font-weight: bold } /* Keyword.Pseudo */
body .kr { font-weight: bold } /* Keyword.Reserved */
body .kt { color: #445588; font-weight: bold } /* Keyword.Type */
body .m { color: #009999 } /* Literal.Number */
body .s { color: #bb8844 } /* Literal.String */
body .na { color: #008080 } /* Name.Attribute */
body .nb { color: #999999 } /* Name.Builtin */
body .nc { color: #445588; font-weight: bold } /* Name.Class */
body .no { color: #008080 } /* Name.Constant */
body .ni { color: #800080 } /* Name.Entity */
body .ne { color: #990000; font-weight: bold } /* Name.Exception */
body .nf { color: #990000; font-weight: bold } /* Name.Function */
body .nn { color: #555555 } /* Name.Namespace */
body .nt { color: #000080 } /* Name.Tag */
body .nv { color: #008080 } /* Name.Variable */
body .ow { font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mf { color: #009999 } /* Literal.Number.Float */
body .mh { color: #009999 } /* Literal.Number.Hex */
body .mi { color: #009999 } /* Literal.Number.Integer */
body .mo { color: #009999 } /* Literal.Number.Oct */
body .sb { color: #bb8844 } /* Literal.String.Backtick */
body .sc { color: #bb8844 } /* Literal.String.Char */
body .sd { color: #bb8844 } /* Literal.String.Doc */
body .s2 { color: #bb8844 } /* Literal.String.Double */
body .se { color: #bb8844 } /* Literal.String.Escape */
body .sh { color: #bb8844 } /* Literal.String.Heredoc */
body .si { color: #bb8844 } /* Literal.String.Interpol */
body .sx { color: #bb8844 } /* Literal.String.Other */
body .sr { color: #808000 } /* Literal.String.Regex */
body .s1 { color: #bb8844 } /* Literal.String.Single */
body .ss { color: #bb8844 } /* Literal.String.Symbol */
body .bp { color: #999999 } /* Name.Builtin.Pseudo */
body .vc { color: #008080 } /* Name.Variable.Class */
body .vg { color: #008080 } /* Name.Variable.Global */
body .vi { color: #008080 } /* Name.Variable.Instance */
body .il { color: #009999 } /* Literal.Number.Integer.Long */

Info

Revision:3292
Author:victor

Date:2008-06-02 16:09:03 +0300 (Mon, 02 Jun 2008)

Comment:Minor changes and fixes in NXCP/XML

Changes
U trunk/configure.ac
U trunk/include/netxms-version.h
U trunk/include/nms_util.h
U trunk/src/Makefile.am
U trunk/src/libnetxms/message.cpp
U trunk/src/libnetxms/unicode.cpp
U trunk/src/libnetxms/xml.cpp
U trunk/src/nxcptest/nxcptest.cpp

Diff
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/configure.ac 2008-06-02 13:09:03 UTC (rev 3292)
@@ -4,7 +4,7 @@
 # Configure script
 #
 
-AC_INIT([NetXMS], [1.0.0-rc1], [NetXMS Team &lt;bugs_at_netxms.org&gt;])
+AC_INIT([NetXMS], [0.2.22], [NetXMS Team &lt;bugs_at_netxms.org&gt;])
 AC_CONFIG_AUX_DIR(config)
 AM_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE
@@ -1465,6 +1465,7 @@
         src/console/cmdline/Makefile
         src/console/PocketPC/Makefile
         src/console/PocketPC/res/Makefile
+ src/nxcptest/Makefile
         src/nxevent/Makefile
         src/nxpush/Makefile
         src/nxreport/Makefile

Modified: trunk/include/netxms-version.h
===================================================================
--- trunk/include/netxms-version.h 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/include/netxms-version.h 2008-06-02 13:09:03 UTC (rev 3292)
@@ -29,11 +29,11 @@
 // Version constants
 //
 
-#define NETXMS_VERSION_MAJOR 1
-#define NETXMS_VERSION_MINOR 0
-#define NETXMS_VERSION_BUILD 0
+#define NETXMS_VERSION_MAJOR 0
+#define NETXMS_VERSION_MINOR 2
+#define NETXMS_VERSION_BUILD 22
 #define NETXMS_VERSION_HOTFIX 0
-#define NETXMS_VERSION_STRING _T(&quot;1.0.0-rc1&quot;)
+#define NETXMS_VERSION_STRING _T(&quot;0.2.22&quot;)
 
 
 //

Modified: trunk/include/nms_util.h
===================================================================
--- trunk/include/nms_util.h 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/include/nms_util.h 2008-06-02 13:09:03 UTC (rev 3292)
@@ -544,6 +544,7 @@
 #ifdef UNICODE_UCS4
         size_t LIBNETXMS_EXPORTABLE ucs2_to_ucs4(const UCS2CHAR *src, size_t srcLen, WCHAR *dst, size_t dstLen);
         size_t LIBNETXMS_EXPORTABLE ucs4_to_ucs2(const WCHAR *src, size_t srcLen, UCS2CHAR *dst, size_t dstLen);
+ size_t LIBNETXMS_EXPORTABLE ucs2_to_utf8(const UCS2CHAR *src, size_t srcLen, char *dst, size_t dstLen);
         UCS2CHAR LIBNETXMS_EXPORTABLE *UCS2StringFromUCS4String(const WCHAR *pwszString);
         WCHAR LIBNETXMS_EXPORTABLE *UCS4StringFromUCS2String(const UCS2CHAR *pszString);
 #endif

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/src/Makefile.am 2008-06-02 13:09:03 UTC (rev 3292)
@@ -8,6 +8,6 @@
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-SUBDIRS = libnetxms install
+SUBDIRS = libnetxms install nxcptest
 SUBDIRS += @MODULES@
 EXTRA_DIST = PPC_libs.vcw

Modified: trunk/src/libnetxms/message.cpp
===================================================================
--- trunk/src/libnetxms/message.cpp 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/src/libnetxms/message.cpp 2008-06-02 13:09:03 UTC (rev 3292)
@@ -859,12 +859,8 @@
         DWORD i;
         char *out, *bdata;
         size_t blen;
-#ifdef UNICODE
- WCHAR *tempStr;
-#else
+ TCHAR *tempStr;
         int bytes;
- char *tempStr;
-#endif
         static const TCHAR *dtString[] = { _T(&quot;int32&quot;), _T(&quot;string&quot;), _T(&quot;int64&quot;), _T(&quot;int16&quot;), _T(&quot;binary&quot;), _T(&quot;float&quot;) };
 
         xml.AddFormattedString(_T(&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;\r\n&lt;nxcp version=\&quot;%d\&quot;&gt;\r\n &lt;message code=\&quot;%d\&quot; id=\&quot;%d\&quot;&gt;\r\n&quot;), m_nVersion, m_wCode, m_dwId);
@@ -885,8 +881,16 @@
                                 break;
                         case CSCP_DT_STRING:
 #ifdef UNICODE
- xml.AddDynamicString(EscapeStringForXML(m_ppVarList[i]-&gt;data.string.szValue, m_ppVarList[i]-&gt;data.string.dwLen));
+#ifdef UNICODE_UCS2
+ xml.AddDynamicString(EscapeStringForXML(m_ppVarList[i]-&gt;data.string.szValue, m_ppVarList[i]-&gt;data.string.dwLen / 2));
 #else
+ tempStr = (WCHAR *)malloc(m_ppVarList[i]-&gt;data.string.dwLen * 2);
+ bytes = ucs2_to_ucs4(m_ppVarList[i]-&gt;data.string.szValue, m_ppVarList[i]-&gt;data.string.dwLen / 2, tempStr, m_ppVarList[i]-&gt;data.string.dwLen / 2);
+ xml.AddDynamicString(EscapeStringForXML(tempStr, bytes));
+ free(tempStr);
+#endif
+#else /* not UNICODE */
+#ifdef UNICODE_UCS2
                                 bytes = WideCharToMultiByte(CP_UTF8, 0, m_ppVarList[i]-&gt;data.string.szValue,
                                                             m_ppVarList[i]-&gt;data.string.dwLen / 2, NULL, 0, NULL, NULL);
                                 tempStr = (char *)malloc(bytes + 1);
@@ -894,7 +898,13 @@
                                                             m_ppVarList[i]-&gt;data.string.dwLen / 2, tempStr, bytes + 1, NULL, NULL);
                                 xml.AddDynamicString(EscapeStringForXML(tempStr, bytes));
                                 free(tempStr);
+#else
+ tempStr = (char *)malloc(m_ppVarList[i]-&gt;data.string.dwLen);
+ bytes = ucs2_to_utf8(m_ppVarList[i]-&gt;data.string.szValue, m_ppVarList[i]-&gt;data.string.dwLen / 2, tempStr, m_ppVarList[i]-&gt;data.string.dwLen);
+ xml.AddDynamicString(EscapeStringForXML(tempStr, bytes));
+ free(tempStr);
 #endif
+#endif /* UNICODE */
                                 break;
                         case CSCP_DT_BINARY:
                                 blen = base64_encode_alloc((char *)m_ppVarList[i]-&gt;data.string.szValue,

Modified: trunk/src/libnetxms/unicode.cpp
===================================================================
--- trunk/src/libnetxms/unicode.cpp 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/src/libnetxms/unicode.cpp 2008-06-02 13:09:03 UTC (rev 3292)
@@ -447,8 +447,10 @@
 #endif
 
 
-#if defined(UNICODE_UCS4) &amp;&amp; !defined(__DISABLE_ICONV)
+#ifdef UNICODE_UCS4
 
+#ifndef __DISABLE_ICONV
+
 //
 // Convert UCS-2 to UCS-4
 //
@@ -584,6 +586,73 @@
    return pwszOut;
 }
 
+#endif /* __DISABLE_ICONV */
+
+
+//
+// Convert UCS-2 to UTF-8
+//
+
+size_t LIBNETXMS_EXPORTABLE ucs2_to_utf8(const UCS2CHAR *src, size_t srcLen, char *dst, size_t dstLen)
+{
+#if HAVE_ICONV &amp;&amp; !defined(__DISABLE_ICONV)
+ iconv_t cd;
+ const char *inbuf;
+ char *outbuf;
+ size_t count, inbytes, outbytes;
+
+ cd = iconv_open(&quot;UTF-8&quot;, UCS2_CODEPAGE_NAME);
+ if (cd != (iconv_t)(-1))
+ {
+ inbuf = (const char *)src;
+ inbytes = ((srcLen == -1) ? ucs2_strlen(src) + 1 : srcLen) * sizeof(UCS2CHAR);
+ outbuf = (char *)dst;
+ outbytes = dstLen;
+ count = iconv(cd, (ICONV_CONST char **)&amp;inbuf, &amp;inbytes, &amp;outbuf, &amp;outbytes);
+ iconv_close(cd);
+ if (count == -1)
+ {
+ if (errno == EILSEQ)
+ {
+ count = (dstLen * sizeof(char) - outbytes) / sizeof(char);
+ }
+ else
+ {
+ count = 0;
+ }
+ }
+ else
+ {
+ count = dstLen - outbytes;
+ }
+ if ((srcLen == -1) &amp;&amp; (outbytes &gt;= sizeof(char)))
+ {
+ *((char *)outbuf) = 0;
+ }
+ }
+ else
+ {
+ *dst = 0;
+ count = 0;
+ }
+ return count;
+
+#else
+
+ const UCS2CHAR *psrc;
+ char *pdst;
+ int pos, size;
+
+ size = (srcLen == -1) ? ucs2_strlen(src) : srcLen;
+ if (size &gt;= dstLen)
+ size = dstLen - 1;
+ for(psrc = src, pos = 0, pdst = dst; pos &lt; size; pos++, psrc++, pdst++)
+ *pdst = (*psrc &lt; 256) ? (char)(*psrc) : &#39;?&#39;;
+ *pdst = 0;
+ return size;
+#endif
+}
+
 #endif /* UNICODE_UCS4 */
 
 

Modified: trunk/src/libnetxms/xml.cpp
===================================================================
--- trunk/src/libnetxms/xml.cpp 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/src/libnetxms/xml.cpp 2008-06-02 13:09:03 UTC (rev 3292)
@@ -73,7 +73,7 @@
                         default:
                                 if (*in &lt; 32)
                                 {
- _stprintf(&amp;out[pos], _T(&quot;&amp;#x%02d;&quot;), *in);
+ _sntprintf(&amp;out[pos], 8, _T(&quot;&amp;#x%02d;&quot;), *in);
                                         pos += 6;
                                 }
                                 else

Modified: trunk/src/nxcptest/nxcptest.cpp
===================================================================
--- trunk/src/nxcptest/nxcptest.cpp 2008-06-02 07:39:30 UTC (rev 3291)
+++ trunk/src/nxcptest/nxcptest.cpp 2008-06-02 13:09:03 UTC (rev 3292)
@@ -119,6 +119,8 @@
    }
    if (iErr &lt; 0)
       printf(&quot;Session terminated (socket error %d)\n&quot;, WSAGetLastError());
+ else
+ printf(&quot;Session closed\n&quot;);
         free(pMsgBuffer);
         free(pRawMsg);
 #ifdef _WITH_ENCRYPTION
@@ -170,7 +172,12 @@
                 msg = new CSCPMessage(xml);
                 rawMsg = msg-&gt;CreateMessage();
                 delete msg;
- SendEx(hSocket, rawMsg, ntohl(rawMsg-&gt;dwSize), 0);
+ if (SendEx(hSocket, rawMsg, ntohl(rawMsg-&gt;dwSize), 0) != ntohl(rawMsg-&gt;dwSize))
+ {
+ printf(&quot;Error sending message\n&quot;);
+ free(rawMsg);
+ break;
+ }
                 free(rawMsg);
         }
         shutdown(hSocket, 2);
Received on Mon Jun 02 2008 - 16:09:05 EEST

This archive was generated by hypermail 2.2.0 : Mon Jun 02 2008 - 16:06:48 EEST