[SVN-NetXMS] revision 3293

From: NetXMS.org SVN Server <svn_at_DOMAIN_REMOVED>
Date: Wed, 4 Jun 2008 10:23:21 +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:3293
Author:victor

Date:2008-06-04 10:23:18 +0300 (Wed, 04 Jun 2008)

Comment:Scripts now can be used to form event's message (via %[..] macro)

Changes
U trunk/ChangeLog
U trunk/TODO
U trunk/include/unicode.h
U trunk/src/console/nxuilib/Makefile.am
A trunk/src/console/nxuilib/nxuilibw.def
U trunk/src/libnetxms/message.cpp
U trunk/src/server/core/dcithreshold.cpp
U trunk/src/server/core/events.cpp
U trunk/src/server/core/session.cpp

Diff
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/ChangeLog 2008-06-04 07:23:18 UTC (rev 3293)
@@ -2,6 +2,7 @@
 * 0.2.22
 *
 
+- Scripts now can be used to form event&#39;s message (via %[..] macro)
 - Implemented XML encoding for NXCP messages
 - Fixed issues: #201
 

Modified: trunk/TODO
===================================================================
--- trunk/TODO 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/TODO 2008-06-04 07:23:18 UTC (rev 3293)
@@ -5,7 +5,6 @@
 GENERAL:
 
 - Table DCI
-- Access to current node properties in NXSL scripts
 - Finish Linux subagent
 - Finish FreeBSD subagent
 - Finish Solaris subagent

Modified: trunk/include/unicode.h
===================================================================
--- trunk/include/unicode.h 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/include/unicode.h 2008-06-04 07:23:18 UTC (rev 3293)
@@ -48,11 +48,11 @@
 
 #include &lt;tchar.h&gt;
 
-#ifdef UNICODE
-
 // Windows always use UCS-2
 #define UNICODE_UCS2 1
 
+#ifdef UNICODE
+
 #define _tcstoll wcstoll
 #define _tcstoull wcstoull
 
@@ -264,11 +264,9 @@
 
 
 // Check that either UNICODE_UCS2 or UNICODE_UCS4 are defined
-#ifdef UNICODE
 #if !defined(UNICODE_UCS2) &amp;&amp; !defined(UNICODE_UCS4)
 #error Neither UNICODE_UCS2 nor UNICODE_UCS4 are defined
 #endif
-#endif
 
 #endif /* _unicode_h_ */
 

Modified: trunk/src/console/nxuilib/Makefile.am
===================================================================
--- trunk/src/console/nxuilib/Makefile.am 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/src/console/nxuilib/Makefile.am 2008-06-04 07:23:18 UTC (rev 3293)
@@ -20,7 +20,7 @@
         MemDC.h \
         nxuilib.clw \
         nxuilib.cpp \
- nxuilib.def \
+ nxuilib.def nxuilibw.def \
         nxuilib.dsp nxuilib.dsw \
         nxuilib.h \
         nxuilib.rc resource.h \

Added: trunk/src/console/nxuilib/nxuilibw.def
===================================================================
--- trunk/src/console/nxuilib/nxuilibw.def (rev 0)
+++ trunk/src/console/nxuilib/nxuilibw.def 2008-06-04 07:23:18 UTC (rev 3293)
@@ -0,0 +1,7 @@
+; nxuilibw.def : Declares the module parameters for the DLL.
+
+LIBRARY &quot;nxuilibw&quot;
+DESCRIPTION &#39;NetXMS Windows UI Dynamic Link Library (UNICODE)&#39;
+
+EXPORTS
+ ; Explicit exports can go here

Modified: trunk/src/libnetxms/message.cpp
===================================================================
--- trunk/src/libnetxms/message.cpp 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/src/libnetxms/message.cpp 2008-06-04 07:23:18 UTC (rev 3293)
@@ -860,7 +860,9 @@
         char *out, *bdata;
         size_t blen;
         TCHAR *tempStr;
+#if !defined(UNICODE) || defined(UNICODE_UCS4)
         int bytes;
+#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);

Modified: trunk/src/server/core/dcithreshold.cpp
===================================================================
--- trunk/src/server/core/dcithreshold.cpp 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/src/server/core/dcithreshold.cpp 2008-06-04 07:23:18 UTC (rev 3293)
@@ -472,7 +472,7 @@
 
 void Threshold::UpdateFromMessage(DCI_THRESHOLD *pData)
 {
-#ifndef UNICODE_UCS2
+#if !defined(UNICODE) || defined(UNICODE_UCS4)
    TCHAR szBuffer[MAX_DCI_STRING_VALUE];
 #endif
 
@@ -509,7 +509,7 @@
 #else
          m_value = pData-&gt;value.szString;
 #endif
-#else
+#else /* UNICODE */
          ucs2_to_mb(pData-&gt;value.szString, -1, szBuffer, MAX_DCI_STRING_VALUE);
          m_value = szBuffer;
 #endif

Modified: trunk/src/server/core/events.cpp
===================================================================
--- trunk/src/server/core/events.cpp 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/src/server/core/events.cpp 2008-06-04 07:23:18 UTC (rev 3293)
@@ -181,7 +181,8 @@
    DWORD dwPos, dwSize, dwParam;
    NetObj *pObject;
    struct tm *lt;
- char *pText, szBuffer[4];
+ char *pText, szBuffer[4], scriptName[256];
+ int i;
 
    pObject = FindObjectById(m_dwSource);
    if (pObject == NULL) // Normally shouldn&#39;t happen
@@ -328,6 +329,57 @@
                      dwPos += (DWORD)_tcslen(m_ppszParameters[dwParam]);
                   }
                   break;
+ case &#39;[&#39;: // Script
+ for(i = 0, pCurr++; (*pCurr != &#39;]&#39;) &amp;&amp; (*pCurr != 0) &amp;&amp; (i &lt; 255); pCurr++)
+ {
+ scriptName[i++] = *pCurr;
+ }
+ if (*pCurr == 0) // no terminating ]
+ {
+ pCurr--;
+ }
+ else
+ {
+ NXSL_Program *script;
+ NXSL_Environment *pEnv;
+
+ scriptName[i] = 0;
+ StrStrip(scriptName);
+
+ g_pScriptLibrary-&gt;Lock();
+ script = g_pScriptLibrary-&gt;FindScript(scriptName);
+ if (script != NULL)
+ {
+ pEnv = new NXSL_Environment;
+ pEnv-&gt;SetLibrary(g_pScriptLibrary);
+// if (m_pNode != NULL)
+// script-&gt;SetGlobalVariable(_T(&quot;$node&quot;), new NXSL_Value(new NXSL_Object(&amp;m_nxslNodeClass, m_pNode)));
+
+ if (script-&gt;Run(pEnv) == 0)
+ {
+ TCHAR *temp = script-&gt;GetResult()-&gt;GetValueAsCString();
+ dwSize += (DWORD)_tcslen(temp);
+ pText = (char *)realloc(pText, dwSize);
+ _tcscpy(&amp;pText[dwPos], temp);
+ dwPos += (DWORD)_tcslen(temp);
+ DbgPrintf(4, &quot;Event::ExpandText(%d, \&quot;%s\&quot;): Script %s executed successfully&quot;,
+ m_dwCode, pszTemplate, scriptName);
+ }
+ else
+ {
+ DbgPrintf(4, &quot;Event::ExpandText(%d, \&quot;%s\&quot;): Script %s execution error: %s&quot;,
+ m_dwCode, pszTemplate, scriptName, script-&gt;GetErrorText());
+ PostEvent(EVENT_SCRIPT_ERROR, g_dwMgmtNode, _T(&quot;ssd&quot;), scriptName,
+ script-&gt;GetErrorText(), 0);
+ }
+ }
+ else
+ {
+ DbgPrintf(4, &quot;Event::ExpandText(%d, \&quot;%s\&quot;): Cannot find script %s&quot;, m_dwCode, pszTemplate, scriptName);
+ }
+ g_pScriptLibrary-&gt;Unlock();
+ }
+ break;
                default: // All other characters are invalid, ignore
                   break;
             }

Modified: trunk/src/server/core/session.cpp
===================================================================
--- trunk/src/server/core/session.cpp 2008-06-02 13:09:03 UTC (rev 3292)
+++ trunk/src/server/core/session.cpp 2008-06-04 07:23:18 UTC (rev 3293)
@@ -2990,7 +2990,7 @@
    NetObj *pObject;
    BOOL bSuccess = FALSE;
    static DWORD m_dwRowSize[] = { 8, 8, 12, 12, 260, 12 };
-#ifndef UNICODE_UCS2
+#if !defined(UNICODE) || defined(UNICODE_UCS4)
    TCHAR szBuffer[MAX_DCI_STRING_VALUE];
 #endif
 
Received on Wed Jun 04 2008 - 10:23:21 EEST

This archive was generated by hypermail 2.2.0 : Wed Jun 04 2008 - 10:20:57 EEST