synced: libnetxms; libnxcl; libnxlp; libnxmb; libnxmap
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 1 May 2009 08:48:32 +0000 (08:48 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 1 May 2009 08:48:32 +0000 (08:48 +0000)
39 files changed:
.gitattributes
src/libnetxms/Makefile.am
src/libnetxms/config.cpp
src/libnetxms/crypto.cpp
src/libnetxms/libnetxms.dsp [deleted file]
src/libnetxms/libnetxms.vcproj
src/libnetxms/libnetxmsw.vcproj
src/libnetxms/log.cpp
src/libnetxms/message.cpp
src/libnetxms/nxcp.cpp
src/libnetxms/seh.cpp
src/libnetxms/table.cpp
src/libnetxms/tools.cpp
src/libnetxms/unicode.cpp
src/libnetxms/wcstoll.c
src/libnetxms/wcstoull.c
src/libnetxms/xml.cpp
src/libnxcl/Makefile.am
src/libnxcl/datacoll.cpp
src/libnxcl/libnxcl.dsp [deleted file]
src/libnxcl/libnxcl.h
src/libnxcl/map.cpp
src/libnxcl/objects.cpp
src/libnxcl/session.cpp
src/libnxlp/Makefile.am
src/libnxlp/libnxlp.dsp [deleted file]
src/libnxlp/parser.cpp
src/libnxlp/rule.cpp
src/libnxlp/unixfile.cpp
src/libnxlp/winfile.cpp
src/libnxmap/Makefile.am
src/libnxmap/libnxmap.dsp [deleted file]
src/libnxmb/dispatcher.cpp [new file with mode: 0644]
src/libnxmb/filter.cpp [new file with mode: 0644]
src/libnxmb/libnxmb.h [new file with mode: 0644]
src/libnxmb/libnxmb.vcproj [copied from src/libnetxms/libnetxms.vcproj with 61% similarity]
src/libnxmb/main.cpp [new file with mode: 0644]
src/libnxmb/message.cpp [new file with mode: 0644]
src/libnxmb/subscriber.cpp [new file with mode: 0644]

index 2db7254..4809ae8 100644 (file)
@@ -413,25 +413,22 @@ src/libexpat/conftools/mkinstalldirs -text
 src/libexpat/libexpat/libexpat.vcproj -text
 src/libexpat/libexpat/libexpatw.vcproj -text
 src/libexpat/vms/descrip.mms -text
-src/libnetxms/libnetxms.dsp eol=crlf
 src/libnetxms/libnetxms.vcp eol=crlf
 src/libnetxms/libnetxms.vcproj -text
 src/libnetxms/libnetxms.vcw eol=crlf
 src/libnetxms/libnetxmsw.vcproj -text
-src/libnxcl/libnxcl.dsp eol=crlf
 src/libnxcl/libnxcl.vcp eol=crlf
 src/libnxcl/libnxcl.vcproj -text
 src/libnxcl/libnxcl.vcw eol=crlf
 src/libnxcl/libnxclw.vcproj -text
-src/libnxlp/libnxlp.dsp eol=crlf
 src/libnxlp/libnxlp.h -text
 src/libnxlp/libnxlp.vcproj -text
 src/libnxlp/main.cpp -text
 src/libnxlp/sample.xml -text
 src/libnxlp/unixfile.cpp -text
-src/libnxmap/libnxmap.dsp eol=crlf
 src/libnxmap/libnxmap.vcproj -text
 src/libnxmap/libnxmapw.vcproj -text
+src/libnxmb/libnxmb.vcproj -text
 src/libnxsl/libnxsl.dsp eol=crlf
 src/libnxsl/libnxsl.vcproj -text
 src/libnxsl/parser.l -text
index ee9904b..9910728 100644 (file)
@@ -19,7 +19,7 @@ libnetxmsw_la_CPPFLAGS = -DUNICODE
 libnetxmsw_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
 
 EXTRA_DIST = \
-       libnetxms.vcproj libnetxmsw.vcproj libnetxms.dsp \
+       libnetxms.vcproj libnetxmsw.vcproj \
        libnetxms.vcp libnetxms.vcw \
        Makefile.nw netxms.def \
        libnetxms.h md5.h sha1.h uuidP.h \
index afcd7c3..9bb3ff2 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Foundation Library
-** Copyright (C) 2003, 2004, 2005, 2006 Victor Kirhenshtein
+** Copyright (C) 2003-2009 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: config.cpp
+** File: config.cpp
 **
 **/
 
 #include "libnetxms.h"
 
-/**
- * @defgroup libnetxms NetXMS utility library
- * @ingroup  libnetxms
- * @brief Provides config-file manipulation functions
- *
- * @{
- */
 
+//
+// Constructor
+//
 
-/**
- * Loads config file in format name = value, complete or one section.
- * Comments started with '#', sections - with '*'
- *
- * @param pszFileName  Config file name.
- * @param pszSection   Section name, can be NULL.
- * @param pTemplateList        Array of template structures describing each config item to be read. NX_CFG_TEMPLATE.iType of last element should be set to CT_END_OF_LIST
- * @param bPrint       Enable/disable debug output.
- *
- * @return Error code (NXCFG_ERR_OK/NXCFG_ERR_NOFILE/NXCFG_ERR_SYNTAX)
- */
-
-DWORD LIBNETXMS_EXPORTABLE NxLoadConfig(const TCHAR *pszFileName, const TCHAR *pszSection,
-                                        NX_CFG_TEMPLATE *pTemplateList, BOOL bPrint)
+Config::Config()
 {
-   FILE *cfg;
-   TCHAR *ptr, *eptr, szBuffer[4096];
-   int i, iSourceLine = 0, iErrors = 0, iLength;
-   BOOL bActiveSection = (pszSection[0] == 0);
-
-   cfg = _tfopen(pszFileName, _T("r"));
-   if (cfg == NULL)
-   {
-      if (bPrint)
-#ifndef UNDER_CE
-#ifdef UNICODE
-         wprintf(L"Unable to open configuration file (%s)\n", pszFileName);
-#else
-         printf("Unable to open configuration file (%s): %s\n", pszFileName, strerror(errno));
-#endif   /* UNICODE */
-#endif   /* UNDER_CE */
-      return NXCFG_ERR_NOFILE;
-   }
-
-   while(!feof(cfg))
-   {
-      // Read line from file
-      szBuffer[0] = 0;
-      _fgetts(szBuffer, 4095, cfg);
-      iSourceLine++;
-      ptr = _tcschr(szBuffer, _T('\n'));
-      if (ptr != NULL)
-         *ptr = 0;
-      ptr = _tcschr(szBuffer, _T('#'));
-      if (ptr != NULL)
-         *ptr = 0;
-
-      StrStrip(szBuffer);
-      if (szBuffer[0] == 0)
-         continue;
-
-      // Check if it's a section name
-      if (szBuffer[0] == _T('*'))
-      {
-         bActiveSection = !_tcsicmp(&szBuffer[1], pszSection);
-      }
-      else
-      {
-         if (!bActiveSection)
-            continue;
+}
 
-         // Divide on two parts at = sign
-         ptr = _tcschr(szBuffer, '=');
-         if (ptr == NULL)
-         {
-            iErrors++;
-            if (bPrint)
-               _tprintf(_T("Syntax error in configuration file at line %d\n"), iSourceLine);
-            continue;
-         }
-         *ptr = 0;
-         ptr++;
-         StrStrip(szBuffer);
-         StrStrip(ptr);
 
-         // Find corresponding token in template list
-         for(i = 0; pTemplateList[i].iType != CT_END_OF_LIST; i++)
-            if (!_tcsicmp(pTemplateList[i].szToken, szBuffer))
-            {
-               switch(pTemplateList[i].iType)
-               {
-                  case CT_LONG:
-                     *((LONG *)pTemplateList[i].pBuffer) = _tcstol(ptr, &eptr, 0);
-                     if (*eptr != 0)
-                     {
-                        iErrors++;
-                        if (bPrint)
-                           _tprintf(_T("Invalid number '%s' in configuration file at line %d\n"), ptr, iSourceLine);
-                     }
-                     break;
-                  case CT_WORD:
-                     *((WORD *)pTemplateList[i].pBuffer) = (WORD)_tcstoul(ptr, &eptr, 0);
-                     if (*eptr != 0)
-                     {
-                        iErrors++;
-                        if (bPrint)
-                           _tprintf(_T("Invalid number '%s' in configuration file at line %d\n"),
-                                                             ptr, iSourceLine);
-                     }
-                     break;
-                  case CT_BOOLEAN:
-                     if (!_tcsicmp(ptr, _T("yes")) || !_tcsicmp(ptr, _T("true")) ||
-                         !_tcsicmp(ptr, _T("on")) || !_tcsicmp(ptr, _T("1")))
-                     {
-                        *((DWORD *)pTemplateList[i].pBuffer) |= pTemplateList[i].dwBufferSize;
-                     }
-                     else
-                     {
-                        *((DWORD *)pTemplateList[i].pBuffer) &= ~(pTemplateList[i].dwBufferSize);
-                     }
-                     break;
-                  case CT_STRING:
-                     nx_strncpy((TCHAR *)pTemplateList[i].pBuffer, ptr, pTemplateList[i].dwBufferSize);
-                     break;
-                  case CT_STRING_LIST:
-                     iLength = (int)_tcslen(ptr) + 2;
-                     if (pTemplateList[i].dwBufferPos + iLength >= pTemplateList[i].dwBufferSize)
-                     {
-                        pTemplateList[i].dwBufferSize += max(1024, iLength);
-                        *((TCHAR **)pTemplateList[i].pBuffer) = 
-                           (TCHAR *)realloc(*((TCHAR **)pTemplateList[i].pBuffer), pTemplateList[i].dwBufferSize);
-                     }
+//
+// Destructor
+//
 
-                     _tcscpy((*((TCHAR **)pTemplateList[i].pBuffer)) + pTemplateList[i].dwBufferPos, ptr);
-                     pTemplateList[i].dwBufferPos += iLength - 1;
-                     (*((TCHAR **)pTemplateList[i].pBuffer))[pTemplateList[i].dwBufferPos - 1] = pTemplateList[i].cSeparator;
-                     (*((TCHAR **)pTemplateList[i].pBuffer))[pTemplateList[i].dwBufferPos] = 0;
-                     break;
-                  case CT_IGNORE:
-                     break;
-                  default:
-                     break;
-               }
-               break;
-            }
+Config::~Config()
+{
+}
 
-         // Invalid keyword
-         if (pTemplateList[i].iType == CT_END_OF_LIST)
-         {
-            iErrors++;
-            if (bPrint)
-               _tprintf(_T("Invalid keyword %s in configuration file at line %d\n"), szBuffer, iSourceLine);
-         }
-      }
-   }
-   fclose(cfg);
 
-   if ((!iErrors) && (bPrint))
-      _tprintf(_T("Configuration file OK\n"));
+//
+// Load INI-style config
+//
 
-   return (iErrors > 0) ? NXCFG_ERR_SYNTAX : NXCFG_ERR_OK;
+bool Config::loadIniConfig(const TCHAR *file)
+{
 }
-
-/** @} */ /* End of public API */
index 7fb21fb..5f7e988 100644 (file)
@@ -464,7 +464,7 @@ RSA LIBNETXMS_EXPORTABLE *LoadRSAKeys(const TCHAR *pszKeyFile)
    fp = _tfopen(pszKeyFile, _T("rb"));
    if (fp != NULL)
    {
-      if (fread(&dwLen, 1, sizeof(DWORD), fp) == sizeof(DWORD))
+      if (fread(&dwLen, 1, sizeof(DWORD), fp) == sizeof(DWORD) && dwLen < 10 * 1024)
       {
          pKeyBuffer = (BYTE *)malloc(dwLen);
          pBufPos = pKeyBuffer;
diff --git a/src/libnetxms/libnetxms.dsp b/src/libnetxms/libnetxms.dsp
deleted file mode 100644 (file)
index 2ecb6c2..0000000
+++ /dev/null
@@ -1,474 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libnetxms" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libnetxms - Win32 Debug UNICODE
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libnetxms.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libnetxms.mak" CFG="libnetxms - Win32 Debug UNICODE"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libnetxms - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnetxms - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnetxms - Win32 Debug AMD64" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnetxms - Win32 Release AMD64" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnetxms - Win32 Debug UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnetxms - Win32 Release UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libnetxms - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpat.lib /nologo /version:0.2 /dll /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release\libnetxms.dll C:\NetXMS\bin        copy Release\libnetxms.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnetxms - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpat.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Debug\libnetxms.dll ..\..\bin      copy Debug\libnetxms.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnetxms - Win32 Debug AMD64"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libnetxms___Win32_Debug_AMD64"
-# PROP BASE Intermediate_Dir "libnetxms___Win32_Debug_AMD64"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug64"
-# PROP Intermediate_Dir "Debug64"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /D "__64BIT__" /D "_M_X64" /FD /Wp64 /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 bufferoverflowU.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib /nologo /version:0.1 /dll /debug /machine:IX86 /pdbtype:sept /machine:AMD64
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Debug64\libnetxms.dll ..\..\bin64  copy Debug64\libnetxms.pdb ..\..\bin64
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnetxms - Win32 Release AMD64"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libnetxms___Win32_Release_AMD64"
-# PROP BASE Intermediate_Dir "libnetxms___Win32_Release_AMD64"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release64"
-# PROP Intermediate_Dir "Release64"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /D "__64BIT__" /D "_M_X64" /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /version:0.1 /dll /machine:I386
-# ADD LINK32 bufferoverflowU.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpat.lib /nologo /version:0.1 /dll /debug /machine:IX86 /pdbtype:sept /machine:AMD64
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release64\libnetxms.dll C:\NetXMS\bin64    copy Release64\libnetxms.pdb C:\NetXMS\bin64
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnetxms - Win32 Debug UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libnetxms___Win32_Debug_UNICODE"
-# PROP BASE Intermediate_Dir "libnetxms___Win32_Debug_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_UNICODE"
-# PROP Intermediate_Dir "Debug_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "UNICODE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept
-# SUBTRACT BASE LINK32 /pdb:none
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpatw.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Debug_UNICODE/libnetxmsw.dll" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Debug_UNICODE\libnetxmsw.dll ..\..\bin     copy Debug_UNICODE\libnetxmsw.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnetxms - Win32 Release UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libnetxms___Win32_Release_UNICODE"
-# PROP BASE Intermediate_Dir "libnetxms___Win32_Release_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_UNICODE"
-# PROP Intermediate_Dir "Release_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "UNICODE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNETXMS_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib ntdll.lib /nologo /version:0.1 /dll /machine:I386
-# ADD LINK32 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpatw.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Release_UNICODE/libnetxmsw.dll" /pdbtype:sept
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release_UNICODE\libnetxmsw.dll C:\NetXMS\bin       copy Release_UNICODE\libnetxmsw.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libnetxms - Win32 Release"
-# Name "libnetxms - Win32 Debug"
-# Name "libnetxms - Win32 Debug AMD64"
-# Name "libnetxms - Win32 Release AMD64"
-# Name "libnetxms - Win32 Debug UNICODE"
-# Name "libnetxms - Win32 Release UNICODE"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\base64.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\config.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\crypto.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\dir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\dload.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\gen_uuid.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\getopt.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\hash.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\icmp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\inline.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\log.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\md5.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\message.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\msgwq.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\nxcp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\qsort.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\queue.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\regex.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\rwlock.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\scandir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\seh.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\serial.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\sha1.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\StackWalker.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\string.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\strmap.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\strtoll.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\strtoull.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\table.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\tools.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\unicode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\uuid.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\wcstoll.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\wcstoull.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\xml.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\..\include\base64.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\libnetxms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\md5.h
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\include\netxms-regex.h"
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\include\netxms-version.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\netxms_getopt.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_agent.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_common.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_cscp.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_threads.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_util.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxcpapi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxqueue.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\rwlock.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\sha1.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StackWalker.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\unicode.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\uuid.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\uuidP.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
index 3b3708a..44e87b6 100644 (file)
@@ -64,7 +64,7 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                RelativePath="..\..\include\nms_util.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\include\nxconfig.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\include\nxcpapi.h"\r
                                >\r
index a34dde6..08eae5a 100644 (file)
@@ -67,7 +67,7 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)_UNICODE"\r
+                       Name="Debug|Pocket PC 2003 (ARMV4)"\r
+                       OutputDirectory="$(SolutionDir)Pocket PC 2003 (ARMV4)\$(ConfigurationName)"\r
+                       IntermediateDirectory="Pocket PC 2003 (ARMV4)\$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="1"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               ExecutionBucket="7"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\libexpat\libexpat"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBNETXMS_EXPORTS;_CRT_SECURE_NO_DEPRECATE"\r
-                               RuntimeLibrary="2"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBNETXMS_EXPORTS;_CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="false"\r
-                               DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
-                               LinkIncremental="1"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="0"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
-                       <Tool\r
-                               Name="VCManifestTool"\r
-                       />\r
                        <Tool\r
                                Name="VCXDCMakeTool"\r
                        />\r
                                Name="VCBscMakeTool"\r
                        />\r
                        <Tool\r
-                               Name="VCFxCopTool"\r
+                               Name="VCCodeSignTool"\r
                        />\r
                        <Tool\r
-                               Name="VCAppVerifierTool"\r
+                               Name="VCPostBuildEventTool"\r
                        />\r
-                       <Tool\r
-                               Name="VCWebDeploymentTool"\r
+                       <DeploymentTool\r
+                               ForceDirty="-1"\r
+                               RemoteDirectory=""\r
+                               RegisterOutput="0"\r
+                               AdditionalFiles=""\r
                        />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
+                       <DebuggerTool\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)_UNICODE"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)_UNICODE"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
                        WholeProgramOptimization="1"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                                OptimizeReferences="2"\r
                                EnableCOMDATFolding="2"\r
-                               TargetMachine="17"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|Pocket PC 2003 (ARMV4)"\r
-                       OutputDirectory="$(SolutionDir)Pocket PC 2003 (ARMV4)\$(ConfigurationName)"\r
-                       IntermediateDirectory="Pocket PC 2003 (ARMV4)\$(ConfigurationName)"\r
+                       Name="Release|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)_UNICODE"\r
                        ConfigurationType="2"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="1"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               ExecutionBucket="7"\r
-                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\..\include;..\libexpat\libexpat"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBNETXMS_EXPORTS;_CRT_SECURE_NO_DEPRECATE"\r
-                               MinimalRebuild="true"\r
-                               RuntimeLibrary="3"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBNETXMS_EXPORTS;_CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               DebugInformationFormat="4"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
-                               LinkIncremental="2"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               TargetMachine="0"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
                        <Tool\r
                                Name="VCXDCMakeTool"\r
                        />\r
                                Name="VCBscMakeTool"\r
                        />\r
                        <Tool\r
-                               Name="VCCodeSignTool"\r
+                               Name="VCFxCopTool"\r
                        />\r
                        <Tool\r
-                               Name="VCPostBuildEventTool"\r
+                               Name="VCAppVerifierTool"\r
                        />\r
-                       <DeploymentTool\r
-                               ForceDirty="-1"\r
-                               RemoteDirectory=""\r
-                               RegisterOutput="0"\r
-                               AdditionalFiles=""\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
                        />\r
-                       <DebuggerTool\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
+                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib dbghelp.lib"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
index 612ffa3..da17e58 100644 (file)
@@ -43,7 +43,7 @@ static TCHAR m_logFileName[MAX_PATH] = _T("");
 static FILE *m_logFileHandle = NULL;
 static MUTEX m_mutexLogAccess = INVALID_MUTEX_HANDLE;
 static DWORD m_flags = 0;
-static int m_maxLogSize = 16384 * 1024;        // 16 MB
+static int m_maxLogSize = 4096 * 1024; // 4 MB
 static int m_logHistorySize = 4;               // Keep up 4 previous log files
 
 
@@ -366,6 +366,9 @@ void LIBNETXMS_EXPORTABLE nxlog_write(DWORD msg, WORD wType, const char *format,
        char *mbMsg;
 #endif
 
+       if (!(m_flags & NXLOG_IS_OPEN))
+               return;
+
    memset(strings, 0, sizeof(char *) * 16);
 
    if (format != NULL)
index 9f4e97a..d38aaaa 100644 (file)
@@ -367,7 +367,7 @@ void CSCPMessage::ProcessXMLData(void *state)
        switch(ps->varType)
        {
                case CSCP_DT_INTEGER:
-                       SetVariable(ps->varId, strtoul(ps->value, NULL, 0));
+                       SetVariable(ps->varId, (DWORD)strtoul(ps->value, NULL, 0));
                        break;
                case CSCP_DT_INT16:
                        SetVariable(ps->varId, (WORD)strtoul(ps->value, NULL, 0));
index 5bbae1e..4b0d898 100644 (file)
@@ -97,7 +97,7 @@ TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(WORD wCode, TCHAR *pszBuffer)
       _T("CMD_DCI_DATA"),
       _T("CMD_GET_MIB_TIMESTAMP"),
       _T("CMD_GET_MIB"),
-      _T("CMD_REQUEST_NEW_LPP_ID"),
+      _T("CMD_TEST_DCI_TRANSFORMATION"),
       _T("CMD_OPEN_LPP"),
       _T("CMD_CREATE_OBJECT"),
       _T("CMD_GET_EVENT_NAMES"),
index a428317..4d5d1bb 100644 (file)
@@ -49,8 +49,12 @@ public:
 //
 
 static BOOL (*m_pfExceptionHandler)(EXCEPTION_POINTERS *) = NULL;
-static void (*m_pfWriter)(char *pszText) = NULL;
+static void (*m_pfWriter)(const TCHAR *pszText) = NULL;
 static HANDLE m_hExceptionLock = INVALID_HANDLE_VALUE;
+static TCHAR m_szBaseProcessName[64] = _T("netxms");
+static TCHAR m_szDumpDir[MAX_PATH] = _T("C:\\");
+static DWORD m_dwLogMessageCode = 0;
+static BOOL m_bPrintToScreen = FALSE;
 
 
 //
@@ -61,8 +65,14 @@ void NxStackWalker::OnOutput(LPCSTR pszText)
 {
        if (m_pfWriter != NULL)
        {
-               m_pfWriter("  ");
-               m_pfWriter((char *)pszText);
+               m_pfWriter(_T("  "));
+#ifdef UNICODE
+               WCHAR *wtext = WideStringFromMBString(pszText);
+               m_pfWriter(wtext);
+               free(wtext);
+#else
+               m_pfWriter(pszText);
+#endif
        }
        else
        {
@@ -87,10 +97,18 @@ void SEHInit(void)
 //
 
 void LIBNETXMS_EXPORTABLE SetExceptionHandler(BOOL (*pfHandler)(EXCEPTION_POINTERS *),
-                                                                                                                        void (*pfWriter)(char *))
+                                                                                                                        void (*pfWriter)(const TCHAR *), const TCHAR *pszDumpDir,
+                                                                                                                        const TCHAR *pszBaseProcessName,
+                                                                                                                        DWORD dwLogMsgCode, BOOL bPrintToScreen)
 {
        m_pfExceptionHandler = pfHandler;
        m_pfWriter = pfWriter;
+       if (pszBaseProcessName != NULL)
+               nx_strncpy(m_szBaseProcessName, pszBaseProcessName, 64);
+       if (pszDumpDir != NULL)
+               nx_strncpy(m_szDumpDir, pszDumpDir, MAX_PATH);
+       m_dwLogMessageCode = dwLogMsgCode;
+       m_bPrintToScreen = bPrintToScreen;
 }
 
 
@@ -220,3 +238,147 @@ THREAD_RESULT LIBNETXMS_EXPORTABLE THREAD_CALL SEHThreadStarter(void *pArg)
        }
        return THREAD_OK;
 }
+
+
+/*
+ * Windows service exception handling
+ * ****************************************************
+ */
+
+
+//
+// Static data
+//
+
+static FILE *m_pExInfoFile = NULL;
+
+
+//
+// Writer for SEHShowCallStack()
+//
+
+void LIBNETXMS_EXPORTABLE SEHServiceExceptionDataWriter(const TCHAR *pszText)
+{
+       if (m_pExInfoFile != NULL)
+               _fputts(pszText, m_pExInfoFile);
+}
+
+
+//
+// Exception handler
+//
+
+BOOL LIBNETXMS_EXPORTABLE SEHServiceExceptionHandler(EXCEPTION_POINTERS *pInfo)
+{
+       TCHAR szWindowsVersion[256] = _T("ERROR"), szInfoFile[MAX_PATH], szDumpFile[MAX_PATH], szProcNameUppercase[64];
+       HANDLE hFile;
+       time_t t;
+       MINIDUMP_EXCEPTION_INFORMATION mei;
+   SYSTEM_INFO sysInfo;
+
+       t = time(NULL);
+       _tcscpy(szProcNameUppercase, m_szBaseProcessName);
+       _tcsupr(szProcNameUppercase);
+
+       // Create info file
+       _sntprintf(szInfoFile, MAX_PATH, _T("%s\\%s-%d-%u.info"),
+                  m_szDumpDir, m_szBaseProcessName, GetCurrentProcessId(), (DWORD)t);
+       m_pExInfoFile = _tfopen(szInfoFile, _T("w"));
+       if (m_pExInfoFile != NULL)
+       {
+               _ftprintf(m_pExInfoFile, _T("%s CRASH DUMP\n%s\n"), szProcNameUppercase, ctime(&t));
+               _ftprintf(m_pExInfoFile, _T("EXCEPTION: %08X (%s) at %08X\n"),
+                         pInfo->ExceptionRecord->ExceptionCode,
+                         SEHExceptionName(pInfo->ExceptionRecord->ExceptionCode),
+                         pInfo->ExceptionRecord->ExceptionAddress);
+
+               // NetXMS and OS version
+               GetWindowsVersionString(szWindowsVersion, 256);
+               _ftprintf(m_pExInfoFile, _T("\nNetXMS Version: ") NETXMS_VERSION_STRING _T("\n")
+                                        _T("OS Version: %s\n"), szWindowsVersion);
+
+               // Processor architecture
+               _ftprintf(m_pExInfoFile, _T("Processor architecture: "));
+               GetSystemInfo(&sysInfo);
+               switch(sysInfo.wProcessorArchitecture)
+               {
+                       case PROCESSOR_ARCHITECTURE_INTEL:
+                               _ftprintf(m_pExInfoFile, _T("Intel x86\n"));
+                               break;
+                       case PROCESSOR_ARCHITECTURE_MIPS:
+                               _ftprintf(m_pExInfoFile, _T("MIPS\n"));
+                               break;
+                       case PROCESSOR_ARCHITECTURE_ALPHA:
+                               _ftprintf(m_pExInfoFile, _T("ALPHA\n"));
+                               break;
+                       case PROCESSOR_ARCHITECTURE_PPC:
+                               _ftprintf(m_pExInfoFile, _T("PowerPC\n"));
+                               break;
+                       case PROCESSOR_ARCHITECTURE_IA64:
+                               _ftprintf(m_pExInfoFile, _T("Intel IA-64\n"));
+                               break;
+                       case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+                               _ftprintf(m_pExInfoFile, _T("Intel x86 on Win64\n"));
+                               break;
+                       case PROCESSOR_ARCHITECTURE_AMD64:
+                               _ftprintf(m_pExInfoFile, _T("AMD64 (Intel EM64T)\n"));
+                               break;
+                       default:
+                               _ftprintf(m_pExInfoFile, _T("UNKNOWN\n"));
+                               break;
+               }
+
+#ifdef _X86_
+               _ftprintf(m_pExInfoFile, _T("\nRegister information:\n")
+                         _T("  eax=%08X  ebx=%08X  ecx=%08X  edx=%08X\n")
+                         _T("  esi=%08X  edi=%08X  ebp=%08X  esp=%08X\n")
+                         _T("  cs=%04X  ds=%04X  es=%04X  ss=%04X  fs=%04X  gs=%04X  flags=%08X\n"),
+                         pInfo->ContextRecord->Eax, pInfo->ContextRecord->Ebx,
+                         pInfo->ContextRecord->Ecx, pInfo->ContextRecord->Edx,
+                         pInfo->ContextRecord->Esi, pInfo->ContextRecord->Edi,
+                         pInfo->ContextRecord->Ebp, pInfo->ContextRecord->Esp,
+                         pInfo->ContextRecord->SegCs, pInfo->ContextRecord->SegDs,
+                         pInfo->ContextRecord->SegEs, pInfo->ContextRecord->SegSs,
+                         pInfo->ContextRecord->SegFs, pInfo->ContextRecord->SegGs,
+                         pInfo->ContextRecord->EFlags);
+#endif
+
+               _ftprintf(m_pExInfoFile, _T("\nCall stack:\n"));
+               SEHShowCallStack(pInfo->ContextRecord);
+
+               fclose(m_pExInfoFile);
+       }
+
+       // Create minidump
+       _sntprintf(szDumpFile, MAX_PATH, _T("%s\\%s-%d-%u.mdmp"),
+                  m_szDumpDir, m_szBaseProcessName, GetCurrentProcessId(), (DWORD)t);
+   hFile = CreateFile(szDumpFile, GENERIC_WRITE, 0, NULL,
+                      CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+   if (hFile != INVALID_HANDLE_VALUE)
+   {
+               mei.ThreadId = GetCurrentThreadId();
+               mei.ExceptionPointers = pInfo;
+               mei.ClientPointers = FALSE;
+      MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile,
+                        MiniDumpNormal, &mei, NULL, NULL);
+      CloseHandle(hFile);
+   }
+
+       // Write event log
+       nxlog_write(m_dwLogMessageCode, EVENTLOG_ERROR_TYPE, "xsxss",
+               pInfo->ExceptionRecord->ExceptionCode,
+               SEHExceptionName(pInfo->ExceptionRecord->ExceptionCode),
+                   pInfo->ExceptionRecord->ExceptionAddress,
+                   szInfoFile, szDumpFile);
+
+       if (m_bPrintToScreen)
+       {
+               _tprintf(_T("\n\n*************************************************************\n")
+                        _T("EXCEPTION: %08X (%s) at %08X\nPROCESS TERMINATED"),
+               pInfo->ExceptionRecord->ExceptionCode,
+               SEHExceptionName(pInfo->ExceptionRecord->ExceptionCode),
+               pInfo->ExceptionRecord->ExceptionAddress);
+       }
+
+       return TRUE;    // Terminate process
+}
index b6523a0..4e9968d 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id$ */
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003, 2004, 2005, 2006 Victor Kirhenshtein
+** Copyright (C) 2003-2009 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -37,6 +37,28 @@ Table::Table()
 }
 
 
+//
+// Create table from NXCP message
+//
+
+Table::Table(CSCPMessage *msg)
+{
+       int i;
+       DWORD dwId;
+
+       m_nNumRows = msg->GetVariableLong(VID_TABLE_NUM_ROWS);
+       m_nNumCols = msg->GetVariableLong(VID_TABLE_NUM_COLS);
+
+       m_ppColNames = (TCHAR **)malloc(sizeof(TCHAR *) * m_nNumCols);
+       for(i = 0, dwId = VID_TABLE_COLUMN_INFO_BASE; i < m_nNumCols; i++, dwId += 9)
+               m_ppColNames[i] = msg->GetVariableStr(dwId++);
+
+       m_ppData = (TCHAR **)malloc(sizeof(TCHAR *) * m_nNumCols * m_nNumRows);
+       for(i = 0, dwId = VID_TABLE_DATA_BASE; i < m_nNumCols * m_nNumRows; i++)
+               m_ppData[i] = msg->GetVariableStr(dwId++);
+}
+
+
 //
 // Table destructor
 //
@@ -55,6 +77,26 @@ Table::~Table()
 }
 
 
+//
+// Fill NXCP message with table data
+//
+
+void Table::FillMessage(CSCPMessage &msg)
+{
+       int i;
+       DWORD id;
+
+       msg.SetVariable(VID_TABLE_NUM_ROWS, (DWORD)m_nNumRows);
+       msg.SetVariable(VID_TABLE_NUM_COLS, (DWORD)m_nNumCols);
+
+       for(i = 0, id = VID_TABLE_COLUMN_INFO_BASE; i < m_nNumCols; i++, id += 9)
+               msg.SetVariable(id++, CHECK_NULL_EX(m_ppColNames[i]));
+
+       for(i = 0, id = VID_TABLE_DATA_BASE; i < m_nNumCols * m_nNumRows; i++)
+               msg.SetVariable(id++, CHECK_NULL_EX(m_ppData[i]));
+}
+
+
 //
 // Add new column
 //
index 3381842..2e34e52 100644 (file)
@@ -948,6 +948,10 @@ DWORD LIBNETXMS_EXPORTABLE ResolveHostName(const TCHAR *pszName)
 #ifndef VER_PLATFORM_WIN32_CE
 #define VER_PLATFORM_WIN32_CE 3
 #endif
+#ifndef SM_SERVERR2
+#define SM_SERVERR2             89
+#endif
+
 
 //
 // Get OS name and version
@@ -1010,6 +1014,67 @@ void LIBNETXMS_EXPORTABLE GetOSVersionString(TCHAR *pszBuffer, int nBufSize)
 }
 
 
+//
+// Get more specific Windows version string
+//
+
+#ifdef _WIN32
+
+BOOL LIBNETXMS_EXPORTABLE GetWindowsVersionString(TCHAR *versionString, int strSize)
+{
+       OSVERSIONINFOEX ver;
+       TCHAR buffer[256];
+
+       ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+       if (!GetVersionEx((OSVERSIONINFO *)&ver))
+               return FALSE;
+
+       switch(ver.dwMajorVersion)
+       {
+               case 5:
+                       switch(ver.dwMinorVersion)
+                       {
+                               case 0:
+                                       _tcscpy(buffer, _T("2000"));
+                                       break;
+                               case 1:
+                                       _tcscpy(buffer, _T("XP"));
+                                       break;
+                               case 2:
+                                       _tcscpy(buffer, (GetSystemMetrics(SM_SERVERR2) != 0) ? _T("Server 2003 R2") : _T("Server 2003"));
+                                       break;
+                               default:
+                                       _sntprintf(buffer, 256, _T("NT %d.%d"), ver.dwMajorVersion, ver.dwMinorVersion);
+                                       break;
+                       }
+                       break;
+               case 6:
+                       switch(ver.dwMinorVersion)
+                       {
+                               case 0:
+                                       _tcscpy(buffer, (ver.wProductType == VER_NT_WORKSTATION) ? _T("Vista") : _T("Server 2008"));
+                                       break;
+                               case 1:
+                                       _tcscpy(buffer, (ver.wProductType == VER_NT_WORKSTATION) ? _T("7") : _T("Server 2008 R2"));
+                                       break;
+                               default:
+                                       _sntprintf(buffer, 256, _T("NT %d.%d"), ver.dwMajorVersion, ver.dwMinorVersion);
+                                       break;
+                       }
+                       break;
+               default:
+                       _sntprintf(buffer, 256, _T("NT %d.%d"), ver.dwMajorVersion, ver.dwMinorVersion);
+                       break;
+       }
+
+       _sntprintf(versionString, strSize, _T("Windows %s Build %d %s"), buffer, ver.dwBuildNumber, ver.szCSDVersion);
+       StrStrip(versionString);
+       return TRUE;
+}
+
+#endif
+
+
 //
 // Count number of characters in string
 //
index 277b8fe..023c5de 100644 (file)
@@ -857,6 +857,34 @@ int wstat(const WCHAR *_path, struct stat *_sbuf)
 
 #endif
 
+#if !HAVE_WUNLINK
+
+int wunlink(const WCHAR *_path)
+{
+       char path[MAX_PATH];
+       
+       WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR,
+                           _path, -1, path, MAX_PATH, NULL, NULL);
+       return unlink(path);
+}
+
+#endif
+
+#if !HAVE_WRENAME
+
+int wrename(const WCHAR *_oldpath, const WCHAR *_newpath)
+{
+       char oldpath[MAX_PATH], newpath[MAX_PATH];
+       
+       WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR,
+                           _oldpath, -1, oldpath, MAX_PATH, NULL, NULL);
+       WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR,
+                           _newpath, -1, newpath, MAX_PATH, NULL, NULL);
+       return rename(oldpath, newpath);
+}
+
+#endif
+
 #if !HAVE_WGETENV
 
 WCHAR *wgetenv(const WCHAR *_string)
index e19a00c..629dcd2 100644 (file)
 #define iswupper(c) isupper(c)
 #endif
 
+#if !HAVE_WINT_T && !defined(_WIN32)
+typedef int wint_t;
+#endif
+
+
 /*
  * Convert a string to a long long.
  *
index ae55657..9df6966 100644 (file)
 #define iswupper(c) isupper(c)
 #endif
 
+#if !HAVE_WINT_T && !defined(_WIN32)  
+typedef int wint_t;
+#endif
+
+
 /*
  * Convert a string to an 64 bit unsigned integer.
  *
index c990101..fda79f6 100644 (file)
@@ -121,7 +121,7 @@ int LIBNETXMS_EXPORTABLE XMLGetAttrDWORD(const char **attrs, const char *name, D
        return (value != NULL) ? strtoul(value, NULL, 0) : defVal;
 }
 
-BOOL LIBNETXMS_EXPORTABLE XMLGetAttrBoolean(const char **attrs, const char *name, BOOL defVal)
+bool LIBNETXMS_EXPORTABLE XMLGetAttrBoolean(const char **attrs, const char *name, bool defVal)
 {
        const char *value;
        int ival;
@@ -132,7 +132,7 @@ BOOL LIBNETXMS_EXPORTABLE XMLGetAttrBoolean(const char **attrs, const char *name
        {
                ival = strtol(value, &eptr, 0);
                if (*eptr == 0)
-                       return (ival != 0) ? TRUE : FALSE;
+                       return (ival != 0) ? true : false;
                return !stricmp(value, "yes") || !stricmp(value, "true");
        }
        return defVal;
index 1b7cc7d..5e21c40 100644 (file)
@@ -23,6 +23,6 @@ libnxclw_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
 libnxclw_la_LIBADD = ../libnetxms/libnetxmsw.la ../libnxmap/libnxmapw.la
 
 EXTRA_DIST = \
-       libnxcl.vcproj libnxclw.vcproj libnxcl.dsp \
+       libnxcl.vcproj libnxclw.vcproj \
        libnxcl.vcp libnxcl.vcw \
        libnxcl.h
index 5eb08c2..1829a48 100644 (file)
@@ -63,6 +63,8 @@ DWORD LIBNXCL_EXPORTABLE NXCCloseNodeDCIList(NXC_SESSION hSession, NXC_DCI_LIST
          safe_free(pItemList->pItems[i].ppScheduleList);
          safe_free(pItemList->pItems[i].pThresholdList);
          safe_free(pItemList->pItems[i].pszFormula);
+                       safe_free(pItemList->pItems[i].pszCustomUnitName);
+                       safe_free(pItemList->pItems[i].pszPerfTabSettings);
       }
       safe_free(pItemList->pItems);
       free(pItemList);
@@ -109,6 +111,8 @@ DWORD LIBNXCL_EXPORTABLE NXCCreateNewDCI(NXC_SESSION hSession, NXC_DCI_LIST *pIt
          pItemList->pItems[pItemList->dwNumItems].dwNumSchedules = 0;
          pItemList->pItems[pItemList->dwNumItems].ppScheduleList = NULL;
          pItemList->pItems[pItemList->dwNumItems].iProcessAllThresholds = 0;
+                       pItemList->pItems[pItemList->dwNumItems].nBaseUnits = DCI_BASEUNITS_OTHER;
+                       pItemList->pItems[pItemList->dwNumItems].nMultiplier = 1;
          pItemList->dwNumItems++;
       }
       delete pResponse;
@@ -152,6 +156,12 @@ DWORD LIBNXCL_EXPORTABLE NXCUpdateDCI(NXC_SESSION hSession, DWORD dwNodeId, NXC_
    msg.SetVariable(VID_ADV_SCHEDULE, (WORD)pItem->iAdvSchedule);
        msg.SetVariable(VID_RESOURCE_ID, pItem->dwResourceId);
        msg.SetVariable(VID_PROXY_NODE, pItem->dwProxyNode);
+       msg.SetVariable(VID_BASE_UNITS, (WORD)pItem->nBaseUnits);
+       msg.SetVariable(VID_MULTIPLIER, (DWORD)pItem->nMultiplier);
+       if (pItem->pszCustomUnitName != NULL)
+               msg.SetVariable(VID_CUSTOM_UNITS_NAME, pItem->pszCustomUnitName);
+       if (pItem->pszPerfTabSettings)
+               msg.SetVariable(VID_PERFTAB_SETTINGS, pItem->pszPerfTabSettings);
    if (pItem->iAdvSchedule)
    {
       msg.SetVariable(VID_NUM_SCHEDULES, pItem->dwNumSchedules);
@@ -269,6 +279,8 @@ DWORD LIBNXCL_EXPORTABLE NXCDeleteDCI(NXC_SESSION hSession, NXC_DCI_LIST *pItemL
             safe_free(pItemList->pItems[i].ppScheduleList);
             safe_free(pItemList->pItems[i].pThresholdList);
             safe_free(pItemList->pItems[i].pszFormula);
+                               safe_free(pItemList->pItems[i].pszCustomUnitName);
+                               safe_free(pItemList->pItems[i].pszPerfTabSettings);
             pItemList->dwNumItems--;
             memmove(&pItemList->pItems[i], &pItemList->pItems[i + 1], 
                     sizeof(NXC_DCI) * (pItemList->dwNumItems - i));
@@ -860,8 +872,6 @@ DWORD LIBNXCL_EXPORTABLE NXCGetSystemDCIList(NXC_SESSION hSession, DWORD dwNodeI
 }
 
 
-
-
 //
 // Clear collected data for DCI
 //
@@ -881,3 +891,43 @@ DWORD LIBNXCL_EXPORTABLE NXCClearDCIData(NXC_SESSION hSession, DWORD dwNodeId, D
 
    return ((NXCL_Session *)hSession)->WaitForRCC(dwRqId);
 }
+
+
+//
+// Test DCI's transformation script
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCTestDCITransformation(NXC_SESSION hSession, DWORD dwNodeId, DWORD dwItemId,
+                                                                                                                                 const TCHAR *script, const TCHAR *value, BOOL *execStatus,
+                                                                                                                                 TCHAR *execResult, size_t resultBufSize)
+{
+   DWORD dwRqId, dwResult;
+   CSCPMessage msg, *pResponse;
+
+   dwRqId = ((NXCL_Session *)hSession)->CreateRqId();
+
+   msg.SetCode(CMD_TEST_DCI_TRANSFORMATION);
+   msg.SetId(dwRqId);
+   msg.SetVariable(VID_OBJECT_ID, dwNodeId);
+   msg.SetVariable(VID_DCI_ID, dwItemId);
+       msg.SetVariable(VID_SCRIPT, script);
+       msg.SetVariable(VID_VALUE, value);
+   ((NXCL_Session *)hSession)->SendMsg(&msg);
+
+       pResponse = ((NXCL_Session *)hSession)->WaitForMessage(CMD_REQUEST_COMPLETED, dwRqId);
+   if (pResponse != NULL)
+   {
+      dwResult = pResponse->GetVariableLong(VID_RCC);
+      if (dwResult == RCC_SUCCESS)
+      {
+                       *execStatus = pResponse->GetVariableShort(VID_EXECUTION_STATUS);
+                       pResponse->GetVariableStr(VID_EXECUTION_RESULT, execResult, resultBufSize);
+      }
+      delete pResponse;
+   }
+   else
+   {
+      dwResult = RCC_TIMEOUT;
+   }
+   return dwResult;
+}
diff --git a/src/libnxcl/libnxcl.dsp b/src/libnxcl/libnxcl.dsp
deleted file mode 100644 (file)
index 993bb2a..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libnxcl" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libnxcl - Win32 Debug UNICODE
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libnxcl.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libnxcl.mak" CFG="libnxcl - Win32 Debug UNICODE"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libnxcl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxcl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxcl - Win32 Debug UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxcl - Win32 Release UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libnxcl - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 libnetxms.lib libnxmap.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\libnetxms\Release" /libpath:"..\libnxmap\Release"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release\libnxcl.dll C:\NetXMS\bin  copy Release\libnxcl.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxcl - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 libnetxms.lib libnxmap.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\libnetxms\Debug" /libpath:"..\libnxmap\Debug"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=copy Debug\libnxcl.dll ..\..\bin        copy Debug\libnxcl.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxcl - Win32 Debug UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libnxcl___Win32_Debug_UNICODE"
-# PROP BASE Intermediate_Dir "libnxcl___Win32_Debug_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_UNICODE"
-# PROP Intermediate_Dir "Debug_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "UNICODE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib libnxcscp.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\libnetxms\Debug" /libpath:"..\libnxcscp\Debug"
-# ADD LINK32 libnetxmsw.lib libnxmapw.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Debug_UNICODE/libnxclw.dll" /pdbtype:sept /libpath:"..\libnetxms\Debug_UNICODE" /libpath:"..\libnxmap\Debug_UNICODE"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=copy Debug_UNICODE\libnxclw.dll ..\..\bin       copy Debug_UNICODE\libnxclw.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxcl - Win32 Release UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libnxcl___Win32_Release_UNICODE"
-# PROP BASE Intermediate_Dir "libnxcl___Win32_Release_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_UNICODE"
-# PROP Intermediate_Dir "Release_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "UNICODE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXCL_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib libnxcscp.lib /nologo /version:0.1 /dll /machine:I386 /libpath:"..\libnetxms\Release" /libpath:"..\libnxcscp\Release"
-# ADD LINK32 libnetxmsw.lib libnxmapw.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Release_UNICODE/libnxclw.dll" /pdbtype:sept /libpath:"..\libnetxms\Release_UNICODE" /libpath:"..\libnxmap\Release_UNICODE"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release_UNICODE\libnxclw.dll C:\NetXMS\bin copy Release_UNICODE\libnxclw.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libnxcl - Win32 Release"
-# Name "libnxcl - Win32 Debug"
-# Name "libnxcl - Win32 Debug UNICODE"
-# Name "libnxcl - Win32 Release UNICODE"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\actions.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\agentcfg.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\alarms.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\cert.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\comm.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\datacoll.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\epp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\eventdb.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\events.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\graph.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\image.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\layer2.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\lpp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\map.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mib.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\objects.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\objtools.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\package.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\script.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\server.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\session.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\situation.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\snmp.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\snmptrap.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\users.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\libnxcl.h
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\include\netxms-version.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\netxms_maps.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_common.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_cscp.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_threads.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_util.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxclapi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxcscpapi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxevent.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxtools.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\unicode.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
index 1c9f6ba..497e88a 100644 (file)
@@ -38,7 +38,7 @@
 // Constants
 //
 
-#define OBJECT_CACHE_MAGIC 0x2008F0F0
+#define OBJECT_CACHE_MAGIC 0x20090321
 
 #define MAX_SERVER_NAME    64
 #define MAX_LOGIN_NAME     64
index f59c3a3..5d79fa4 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** Client Library
-** Copyright (C) 2006 Victor Kirhenshtein
+** Copyright (C) 2006-2009 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
index 1d74353..4b72f0c 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** Client Library
-** Copyright (C) 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
+** Copyright (C) 2004-2009 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -52,6 +52,12 @@ void DestroyObject(NXC_OBJECT *pObject)
          safe_free(pObject->cluster.pSyncNetList);
                        safe_free(pObject->cluster.pResourceList);
          break;
+               case OBJECT_TEMPLATE:
+                       safe_free(pObject->dct.pszAutoApplyFilter);
+                       break;
+               case OBJECT_CONTAINER:
+                       safe_free(pObject->container.pszAutoBindFilter);
+                       break;
    }
    safe_free(pObject->pdwChildList);
    safe_free(pObject->pdwParentList);
@@ -157,6 +163,12 @@ static void ReplaceObject(NXC_OBJECT *pObject, NXC_OBJECT *pNewObject)
          safe_free(pObject->cluster.pSyncNetList);
                        safe_free(pObject->cluster.pResourceList);
          break;
+               case OBJECT_TEMPLATE:
+                       safe_free(pObject->dct.pszAutoApplyFilter);
+                       break;
+               case OBJECT_CONTAINER:
+                       safe_free(pObject->container.pszAutoBindFilter);
+                       break;
    }
    safe_free(pObject->pdwChildList);
    safe_free(pObject->pdwParentList);
@@ -277,9 +289,13 @@ static NXC_OBJECT *NewObjectFromMsg(CSCPMessage *pMsg)
          break;
       case OBJECT_CONTAINER:
          pObject->container.dwCategory = pMsg->GetVariableLong(VID_CATEGORY);
+                       pObject->container.isAutoBindEnabled = pMsg->GetVariableShort(VID_ENABLE_AUTO_BIND);
+                       pObject->container.pszAutoBindFilter = pMsg->GetVariableStr(VID_AUTO_BIND_FILTER);
          break;
       case OBJECT_TEMPLATE:
          pObject->dct.dwVersion = pMsg->GetVariableLong(VID_TEMPLATE_VERSION);
+                       pObject->dct.isAutoApplyEnabled = pMsg->GetVariableShort(VID_AUTO_APPLY);
+                       pObject->dct.pszAutoApplyFilter = pMsg->GetVariableStr(VID_APPLY_FILTER);
          break;
       case OBJECT_NETWORKSERVICE:
          pObject->netsrv.iServiceType = (int)pMsg->GetVariableShort(VID_SERVICE_TYPE);
@@ -880,6 +896,16 @@ DWORD LIBNXCL_EXPORTABLE NXCModifyObject(NXC_SESSION hSession, NXC_OBJECT_UPDATE
          msg.SetVariable(dwId1++, pUpdate->pCustomAttrs->GetValueByIndex(i));
       }
    }
+   if (pUpdate->qwFlags & OBJ_UPDATE_AUTO_APPLY)
+   {
+      msg.SetVariable(VID_AUTO_APPLY, (WORD)pUpdate->isAutoApplyEnabled);
+               msg.SetVariable(VID_APPLY_FILTER, CHECK_NULL_EX(pUpdate->pszAutoApplyFilter));
+   }
+   if (pUpdate->qwFlags & OBJ_UPDATE_AUTO_BIND)
+   {
+      msg.SetVariable(VID_ENABLE_AUTO_BIND, (WORD)pUpdate->isAutoBindEnabled);
+               msg.SetVariable(VID_AUTO_BIND_FILTER, CHECK_NULL_EX(pUpdate->pszAutoBindFilter));
+   }
 
    // Send request
    ((NXCL_Session *)hSession)->SendMsg(&msg);
index 3b78f51..8ebca91 100644 (file)
@@ -410,6 +410,10 @@ void NXCL_Session::ProcessDCI(CSCPMessage *pMsg)
                                  MAX_DB_STRING);
             pMsg->GetVariableStr(VID_INSTANCE, m_pItemList->pItems[i].szInstance,
                                  MAX_DB_STRING);
+                               m_pItemList->pItems[i].nBaseUnits = (int)pMsg->GetVariableShort(VID_BASE_UNITS);
+                               m_pItemList->pItems[i].nMultiplier = (int)pMsg->GetVariableLong(VID_MULTIPLIER);
+                               m_pItemList->pItems[i].pszCustomUnitName = pMsg->GetVariableStr(VID_CUSTOM_UNITS_NAME);
+                               m_pItemList->pItems[i].pszPerfTabSettings = pMsg->GetVariableStr(VID_PERFTAB_SETTINGS);
             m_pItemList->pItems[i].dwNumSchedules = pMsg->GetVariableLong(VID_NUM_SCHEDULES);
             m_pItemList->pItems[i].ppScheduleList = (TCHAR **)malloc(sizeof(TCHAR *) * m_pItemList->pItems[i].dwNumSchedules);
             for(j = 0, dwId = VID_DCI_SCHEDULE_BASE; j < m_pItemList->pItems[i].dwNumSchedules; j++, dwId++)
index 3cb8f7e..a798096 100644 (file)
@@ -6,10 +6,10 @@ lib_LTLIBRARIES = libnxlp.la
 
 libnxlp_la_SOURCES = $(SOURCES)
 libnxlp_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
-libnxlp_la_LIBADD = ../libnetxms/libnetxms.la
+libnxlp_la_LIBADD = @top_srcdir@/src/libnetxms/libnetxms.la
 
 EXTRA_DIST = \
-       libnxlp.vcproj libnxlp.dsp \
+       libnxlp.vcproj \
        libnxlp.h \
        winfile.cpp \
        libnxlp.def Makefile.nw
diff --git a/src/libnxlp/libnxlp.dsp b/src/libnxlp/libnxlp.dsp
deleted file mode 100644 (file)
index 3dafbf9..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libnxlp" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libnxlp - Win32 Debug UNICODE
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libnxlp.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libnxlp.mak" CFG="libnxlp - Win32 Debug UNICODE"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libnxlp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxlp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxlp - Win32 Debug AMD64" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxlp - Win32 Release AMD64" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxlp - Win32 Debug UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxlp - Win32 Release UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libnxlp - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpat.lib /nologo /version:0.2 /dll /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release\libnxlp.dll C:\NetXMS\bin  copy Release\libnxlp.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxlp - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpat.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Debug\libnxlp.dll ..\..\bin        copy Debug\libnxlp.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxlp - Win32 Debug AMD64"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libnxlp___Win32_Debug_AMD64"
-# PROP BASE Intermediate_Dir "libnxlp___Win32_Debug_AMD64"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug64"
-# PROP Intermediate_Dir "Debug64"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /D "__64BIT__" /D "_M_X64" /FD /Wp64 /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 bufferoverflowU.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib /nologo /version:0.1 /dll /debug /machine:IX86 /pdbtype:sept /machine:AMD64
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Debug64\libnxlp.dll ..\..\bin64    copy Debug64\libnxlp.pdb ..\..\bin64
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxlp - Win32 Release AMD64"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libnxlp___Win32_Release_AMD64"
-# PROP BASE Intermediate_Dir "libnxlp___Win32_Release_AMD64"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release64"
-# PROP Intermediate_Dir "Release64"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /D "__64BIT__" /D "_M_X64" /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /version:0.1 /dll /machine:I386
-# ADD LINK32 bufferoverflowU.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpat.lib /nologo /version:0.1 /dll /debug /machine:IX86 /pdbtype:sept /machine:AMD64
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release64\libnxlp.dll C:\NetXMS\bin64      copy Release64\libnxlp.pdb C:\NetXMS\bin64
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxlp - Win32 Debug UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libnxlp___Win32_Debug_UNICODE"
-# PROP BASE Intermediate_Dir "libnxlp___Win32_Debug_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_UNICODE"
-# PROP Intermediate_Dir "Debug_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "UNICODE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept
-# SUBTRACT BASE LINK32 /pdb:none
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpatw.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Debug_UNICODE/libnxlpw.dll" /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Debug_UNICODE\libnxlpw.dll ..\..\bin       copy Debug_UNICODE\libnxlpw.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxlp - Win32 Release UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libnxlp___Win32_Release_UNICODE"
-# PROP BASE Intermediate_Dir "libnxlp___Win32_Release_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_UNICODE"
-# PROP Intermediate_Dir "Release_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "UNICODE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXLP_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib ntdll.lib /nologo /version:0.1 /dll /machine:I386
-# ADD LINK32 gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib libeay32.lib dbghelp.lib crypt32.lib libexpatw.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Release_UNICODE/libnxlpw.dll" /pdbtype:sept
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release_UNICODE\libnxlpw.dll C:\NetXMS\bin copy Release_UNICODE\libnxlpw.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libnxlp - Win32 Release"
-# Name "libnxlp - Win32 Debug"
-# Name "libnxlp - Win32 Debug AMD64"
-# Name "libnxlp - Win32 Release AMD64"
-# Name "libnxlp - Win32 Debug UNICODE"
-# Name "libnxlp - Win32 Release UNICODE"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\parser.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\rule.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\winfile.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\libnxlp.h
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\include\netxms-regex.h"
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\include\netxms-version.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_common.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_threads.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_util.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxlpapi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\unicode.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
index f791494..b04a4d2 100644 (file)
@@ -32,7 +32,7 @@
 // Context state texts
 //
 
-static const TCHAR *m_states[] = { _T("MANUAL"), _T("AUTO"), _T("INACTIVE") };
+static const TCHAR *s_states[] = { _T("MANUAL"), _T("AUTO"), _T("INACTIVE") };
 
 
 //
@@ -75,8 +75,8 @@ typedef struct
        String errorText;
        String macroName;
        String macro;
-       BOOL invertedRule;
-       BOOL breakFlag;
+       bool invertedRule;
+       bool breakFlag;
 } XML_PARSER_STATE;
 
 
@@ -121,7 +121,7 @@ LogParser::~LogParser()
 // Trace
 //
 
-void LogParser::Trace(int level, const TCHAR *format, ...)
+void LogParser::trace(int level, const TCHAR *format, ...)
 {
        va_list args;
 
@@ -138,11 +138,11 @@ void LogParser::Trace(int level, const TCHAR *format, ...)
 // Add rule
 //
 
-BOOL LogParser::AddRule(LogParserRule *rule)
+bool LogParser::addRule(LogParserRule *rule)
 {
-       BOOL isOK;
+       bool isOK;
 
-       isOK = rule->IsValid();
+       isOK = rule->isValid();
        if (isOK)
        {
                m_rules = (LogParserRule **)realloc(m_rules, sizeof(LogParserRule *) * (m_numRules + 1));
@@ -155,9 +155,9 @@ BOOL LogParser::AddRule(LogParserRule *rule)
        return isOK;
 }
 
-BOOL LogParser::AddRule(const char *regexp, DWORD event, int numParams)
+bool LogParser::addRule(const char *regexp, DWORD event, int numParams)
 {
-       return AddRule(new LogParserRule(this, regexp, event, numParams));
+       return addRule(new LogParserRule(this, regexp, event, numParams));
 }
 
 
@@ -165,90 +165,118 @@ BOOL LogParser::AddRule(const char *regexp, DWORD event, int numParams)
 // Check context
 //
 
-const TCHAR *LogParser::CheckContext(LogParserRule *rule)
+const TCHAR *LogParser::checkContext(LogParserRule *rule)
 {
        const TCHAR *state;
        
-       if (rule->GetContext() == NULL)
+       if (rule->getContext() == NULL)
        {
-               Trace(5, _T("  rule has no context"));
-               return m_states[CONTEXT_SET_MANUAL];
+               trace(5, _T("  rule has no context"));
+               return s_states[CONTEXT_SET_MANUAL];
        }
                
-       state = m_contexts.Get(rule->GetContext());
+       state = m_contexts.Get(rule->getContext());
        if (state == NULL)
        {
-               Trace(5, _T("  context '%s' inactive, rule should be skipped"), rule->GetContext());
+               trace(5, _T("  context '%s' inactive, rule should be skipped"), rule->getContext());
                return NULL;    // Context inactive, don't use this rule                
        }
        
-       if (!_tcscmp(state, m_states[CONTEXT_CLEAR]))
+       if (!_tcscmp(state, s_states[CONTEXT_CLEAR]))
        {
-               Trace(5, _T("  context '%s' inactive, rule should be skipped"), rule->GetContext());
+               trace(5, _T("  context '%s' inactive, rule should be skipped"), rule->getContext());
                return NULL;
        }
        else
        {
-               Trace(5, _T("  context '%s' active (mode=%s)"), rule->GetContext(), state);
+               trace(5, _T("  context '%s' active (mode=%s)"), rule->getContext(), state);
                return state;
        }
 }
 
 
 //
-// Match log line
+// Match log record
 //
 
-BOOL LogParser::MatchLine(const char *line, DWORD objectId)
+bool LogParser::matchLogRecord(bool hasAttributes, const char *source, DWORD eventId,
+                                                                                DWORD level, const char *line, DWORD objectId)
 {
        int i;
        const TCHAR *state;
-       BOOL matched = FALSE;
+       bool matched = false;
+
+       if (hasAttributes)
+               trace(2, _T("Match event: source=\"%s\" id=%u level=%d text=\"%s\""), source, eventId, level, line);
+       else
+               trace(2, _T("Match line: \"%s\""), line);
 
-       Trace(2, _T("Match line: \"%s\""), line);
        m_recordsProcessed++;
        for(i = 0; i < m_numRules; i++)
        {
-               Trace(4, _T("checking rule %d \"%s\""), i + 1, m_rules[i]->GetDescription());
-               if (((state = CheckContext(m_rules[i])) != NULL) && m_rules[i]->Match(line, m_cb, objectId, m_userArg))
+               trace(4, _T("checking rule %d \"%s\""), i + 1, m_rules[i]->getDescription());
+               bool ruleMatched = hasAttributes ? 
+                       m_rules[i]->matchEx(source, eventId, level, line, m_cb, objectId, m_userArg) : 
+                       m_rules[i]->match(line, m_cb, objectId, m_userArg);
+               if (((state = checkContext(m_rules[i])) != NULL) && ruleMatched)
                {
-                       Trace(1, _T("rule %d \"%s\" matched"), i + 1, m_rules[i]->GetDescription());
+                       trace(1, _T("rule %d \"%s\" matched"), i + 1, m_rules[i]->getDescription());
                        if (!matched)
                                m_recordsMatched++;
                        
                        // Update context
-                       if (m_rules[i]->GetContextToChange() != NULL)
+                       if (m_rules[i]->getContextToChange() != NULL)
                        {
-                               m_contexts.Set(m_rules[i]->GetContextToChange(), m_states[m_rules[i]->GetContextAction()]);
-                               Trace(2, _T("rule %d \"%s\": context %s set to %s"), i + 1, m_rules[i]->GetDescription(), m_rules[i]->GetContextToChange(), m_states[m_rules[i]->GetContextAction()]);
+                               m_contexts.Set(m_rules[i]->getContextToChange(), s_states[m_rules[i]->getContextAction()]);
+                               trace(2, _T("rule %d \"%s\": context %s set to %s"), i + 1, m_rules[i]->getDescription(), m_rules[i]->getContextToChange(), s_states[m_rules[i]->getContextAction()]);
                        }
                        
                        // Set context of this rule to inactive if rule context mode is "automatic reset"
-                       if (!_tcscmp(state, m_states[CONTEXT_SET_AUTOMATIC]))
+                       if (!_tcscmp(state, s_states[CONTEXT_SET_AUTOMATIC]))
                        {
-                               m_contexts.Set(m_rules[i]->GetContext(), m_states[CONTEXT_CLEAR]);
-                               Trace(2, _T("rule %d \"%s\": context %s cleared because it was set to automatic reset mode"),
-                                     i + 1, m_rules[i]->GetDescription(), m_rules[i]->GetContext());
+                               m_contexts.Set(m_rules[i]->getContext(), s_states[CONTEXT_CLEAR]);
+                               trace(2, _T("rule %d \"%s\": context %s cleared because it was set to automatic reset mode"),
+                                     i + 1, m_rules[i]->getDescription(), m_rules[i]->getContext());
                        }
-                       matched = TRUE;
-                       if (!m_processAllRules || m_rules[i]->GetBreakFlag())
+                       matched = true;
+                       if (!m_processAllRules || m_rules[i]->getBreakFlag())
                                break;
                }
        }
        if (i < m_numRules)
-               Trace(2, _T("processing stopped at rule %d \"%s\"; result = %s"), i + 1,
-                               m_rules[i]->GetDescription(), matched ? _T("true") : _T("false"));
+               trace(2, _T("processing stopped at rule %d \"%s\"; result = %s"), i + 1,
+                               m_rules[i]->getDescription(), matched ? _T("true") : _T("false"));
        else
-               Trace(2, _T("Processing stopped at end of rules list; result = %s"), matched ? _T("true") : _T("false"));
+               trace(2, _T("Processing stopped at end of rules list; result = %s"), matched ? _T("true") : _T("false"));
        return matched;
 }
 
 
+//
+// Match simple log line
+//
+
+bool LogParser::matchLine(const char *line, DWORD objectId)
+{
+       return matchLogRecord(false, NULL, 0, 0, line, objectId);
+}
+
+
+//
+// Match log event (text with additional attributes - source, severity, event id)
+//
+
+bool LogParser::matchEvent(const char *source, DWORD eventId, DWORD level, const char *line, DWORD objectId)
+{
+       return matchLogRecord(true, source, eventId, level, line, objectId);
+}
+
+
 //
 // Set associated file name
 //
 
-void LogParser::SetFileName(const TCHAR *name)
+void LogParser::setFileName(const TCHAR *name)
 {
        safe_free(m_fileName);
        m_fileName = (name != NULL) ? _tcsdup(name) : NULL;
@@ -259,7 +287,7 @@ void LogParser::SetFileName(const TCHAR *name)
 // Add macro
 //
 
-void LogParser::AddMacro(const TCHAR *name, const TCHAR *value)
+void LogParser::addMacro(const TCHAR *name, const TCHAR *value)
 {
        m_macros.Set(name, value);
 }
@@ -269,7 +297,7 @@ void LogParser::AddMacro(const TCHAR *name, const TCHAR *value)
 // Get macro
 //
 
-const TCHAR *LogParser::GetMacro(const TCHAR *name)
+const TCHAR *LogParser::getMacro(const TCHAR *name)
 {
        const TCHAR *value;
 
@@ -291,8 +319,8 @@ static void StartElement(void *userData, const char *name, const char **attrs)
        if (!strcmp(name, "parser"))
        {
                ps->state = XML_STATE_PARSER;
-               ps->parser->SetProcessAllFlag(XMLGetAttrBoolean(attrs, "processAll", FALSE));
-               ps->parser->SetTraceLevel(XMLGetAttrInt(attrs, "trace", 0));
+               ps->parser->setProcessAllFlag(XMLGetAttrBoolean(attrs, "processAll", false));
+               ps->parser->setTraceLevel(XMLGetAttrInt(attrs, "trace", 0));
        }
        else if (!strcmp(name, "file"))
        {
@@ -318,18 +346,22 @@ static void StartElement(void *userData, const char *name, const char **attrs)
        else if (!strcmp(name, "rule"))
        {
                ps->regexp = NULL;
+               ps->invertedRule = false;
                ps->event = NULL;
                ps->context = NULL;
                ps->contextAction = CONTEXT_SET_AUTOMATIC;
                ps->description = NULL;
+               ps->id = NULL;
+               ps->source = NULL;
+               ps->level = NULL;
                ps->ruleContext = XMLGetAttr(attrs, "context");
-               ps->breakFlag = XMLGetAttrBoolean(attrs, "break", FALSE);
+               ps->breakFlag = XMLGetAttrBoolean(attrs, "break", false);
                ps->state = XML_STATE_RULE;
        }
        else if (!strcmp(name, "match"))
        {
                ps->state = XML_STATE_MATCH;
-               ps->invertedRule = XMLGetAttrBoolean(attrs, "invert", FALSE);
+               ps->invertedRule = XMLGetAttrBoolean(attrs, "invert", false);
        }
        else if (!strcmp(name, "id"))
        {
@@ -410,7 +442,7 @@ static void EndElement(void *userData, const char *name)
        }
        else if (!strcmp(name, "file"))
        {
-               ps->parser->SetFileName(ps->file);
+               ps->parser->setFileName(ps->file);
                ps->state = XML_STATE_PARSER;
        }
        else if (!strcmp(name, "macros"))
@@ -419,7 +451,7 @@ static void EndElement(void *userData, const char *name)
        }
        else if (!strcmp(name, "macro"))
        {
-               ps->parser->AddMacro(ps->macroName, ps->macro);
+               ps->parser->addMacro(ps->macroName, ps->macro);
                ps->state = XML_STATE_MACROS;
        }
        else if (!strcmp(name, "rules"))
@@ -435,20 +467,48 @@ static void EndElement(void *userData, const char *name)
                ps->event.Strip();
                event = strtoul(ps->event, &eptr, 0);
                if (*eptr != 0)
-                       event = ps->parser->ResolveEventName(ps->event);
+                       event = ps->parser->resolveEventName(ps->event);
                rule = new LogParserRule(ps->parser, (const char *)ps->regexp, event, ps->numEventParams);
                if (!ps->ruleContext.IsEmpty())
-                       rule->SetContext(ps->ruleContext);
+                       rule->setContext(ps->ruleContext);
                if (!ps->context.IsEmpty())
                {
-                       rule->SetContextToChange(ps->context);
-                       rule->SetContextAction(ps->contextAction);
+                       rule->setContextToChange(ps->context);
+                       rule->setContextAction(ps->contextAction);
                }
+
                if (!ps->description.IsEmpty())
-                       rule->SetDescription(ps->description);
-               rule->SetInverted(ps->invertedRule);
-               rule->SetBreakFlag(ps->breakFlag);
-               ps->parser->AddRule(rule);
+                       rule->setDescription(ps->description);
+               
+               if (!ps->source.IsEmpty())
+                       rule->setSource(ps->source);
+
+               if (!ps->level.IsEmpty())
+                       rule->setLevel(_tcstoul(ps->level, NULL, 0));
+
+               if (!ps->id.IsEmpty())
+               {
+                       DWORD start, end;
+                       TCHAR *eptr;
+
+                       start = strtoul(ps->id, &eptr, 0);
+                       if (*eptr == 0)
+                       {
+                               end = start;
+                       }
+                       else    /* TODO: add better error handling */
+                       {
+                               while(!_istdigit(*eptr))
+                                       eptr++;
+                               end = strtoul(eptr, NULL, 0);
+                       }
+                       rule->setIdRange(start, end);
+               }
+
+               rule->setInverted(ps->invertedRule);
+               rule->setBreakFlag(ps->breakFlag);
+
+               ps->parser->addRule(rule);
                ps->state = XML_STATE_RULES;
        }
        else if (!strcmp(name, "match"))
@@ -521,12 +581,12 @@ static void CharData(void *userData, const XML_Char *s, int len)
 
 #endif
 
-BOOL LogParser::CreateFromXML(const char *xml, int xmlLen, char *errorText, int errBufSize)
+bool LogParser::createFromXml(const char *xml, int xmlLen, char *errorText, int errBufSize)
 {
 #if HAVE_LIBEXPAT
        XML_Parser parser = XML_ParserCreate(NULL);
        XML_PARSER_STATE state;
-       BOOL success;
+       bool success;
 
        // Parse XML
        state.parser = this;
@@ -546,7 +606,7 @@ BOOL LogParser::CreateFromXML(const char *xml, int xmlLen, char *errorText, int
 
        if (success && (state.state == XML_STATE_ERROR))
        {
-               success = FALSE;
+               success = false;
                if (errorText != NULL)
                        strncpy(errorText, state.errorText, errBufSize);
        }
@@ -556,7 +616,7 @@ BOOL LogParser::CreateFromXML(const char *xml, int xmlLen, char *errorText, int
 
        if (errorText != NULL)
                strncpy(errorText, "Compiled without XML support", errBufSize);
-       return FALSE;
+       return false;
 #endif
 }
 
@@ -565,7 +625,7 @@ BOOL LogParser::CreateFromXML(const char *xml, int xmlLen, char *errorText, int
 // Resolve event name
 //
 
-DWORD LogParser::ResolveEventName(const TCHAR *name, DWORD defVal)
+DWORD LogParser::resolveEventName(const TCHAR *name, DWORD defVal)
 {
        if (m_eventNameList != NULL)
        {
index 76562fe..4d5b1ba 100644 (file)
@@ -42,7 +42,7 @@ LogParserRule::LogParserRule(LogParser *parser,
        String expandedRegexp;
 
        m_parser = parser;
-       ExpandMacros(regexp, expandedRegexp);
+       expandMacros(regexp, expandedRegexp);
        m_regexp = _tcsdup(expandedRegexp);
        m_isValid = (regcomp(&m_preg, expandedRegexp, REG_EXTENDED | REG_ICASE) == 0);
        m_event = event;
@@ -80,31 +80,31 @@ LogParserRule::~LogParserRule()
 // Match line
 //
 
-BOOL LogParserRule::Match(const char *line, LOG_PARSER_CALLBACK cb, DWORD objectId, void *userArg)
+bool LogParserRule::match(const char *line, LogParserCallback cb, DWORD objectId, void *userArg)
 {
        if (!m_isValid)
-               return FALSE;
+               return false;
 
        if (m_isInverted)
        {
-               m_parser->Trace(6, _T("  negated matching against regexp %s"), m_regexp);
+               m_parser->trace(6, _T("  negated matching against regexp %s"), m_regexp);
                if (regexec(&m_preg, line, 0, NULL, 0) != 0)
                {
-                       m_parser->Trace(6, _T("  matched"));
+                       m_parser->trace(6, _T("  matched"));
                        if ((cb != NULL) && (m_event != 0))
                                cb(m_event, line, 0, NULL, objectId, userArg);
-                       return TRUE;
+                       return true;
                }
        }
        else
        {
-               m_parser->Trace(6, _T("  matching against regexp %s"), m_regexp);
+               m_parser->trace(6, _T("  matching against regexp %s"), m_regexp);
                if (regexec(&m_preg, line, (m_numParams > 0) ? m_numParams + 1 : 0, m_pmatch, 0) == 0)
                {
-                       m_parser->Trace(6, _T("  matched"));
+                       m_parser->trace(6, _T("  matched"));
                        if ((cb != NULL) && (m_event != 0))
                        {
-                               char **params;
+                               char **params = NULL;
                                int i, len;
 
                                if (m_numParams > 0)
@@ -131,12 +131,45 @@ BOOL LogParserRule::Match(const char *line, LOG_PARSER_CALLBACK cb, DWORD object
                                for(i = 0; i < m_numParams; i++)
                                        safe_free(params[i]);
                        }               
-                       return TRUE;
+                       return true;
                }
        }
 
-       m_parser->Trace(6, _T("  no match"));
-       return FALSE;   // no match
+       m_parser->trace(6, _T("  no match"));
+       return false;   // no match
+}
+
+
+//
+// Match event
+//
+
+bool LogParserRule::matchEx(const TCHAR *source, DWORD eventId, DWORD level,
+                                                                 const char *line, LogParserCallback cb, DWORD objectId, void *userArg)
+{
+       if (m_source != NULL)
+       {
+               m_parser->trace(6, _T("  matching source \"%s\" against pattern \"%s\""), source, m_source);
+               if (!MatchString(m_source, source, FALSE))
+               {
+                       m_parser->trace(6, _T("  source: no match"));
+                       return false;
+               }
+       }
+
+       if ((eventId < m_idStart) || (eventId > m_idEnd))
+       {
+               m_parser->trace(6, _T("  event id 0x%08x not in range 0x%08x - 0x%08x"), eventId, m_idStart, m_idEnd);
+               return false;
+       }
+
+       if (!(m_level & level))
+       {
+               m_parser->trace(6, _T("  severity level 0x%04x not match mask 0x%04x"), level, m_level);
+               return false;
+       }
+
+       return match(line, cb, objectId, userArg);
 }
 
 
@@ -144,7 +177,7 @@ BOOL LogParserRule::Match(const char *line, LOG_PARSER_CALLBACK cb, DWORD object
 // Expand macros in regexp
 //
 
-void LogParserRule::ExpandMacros(const char *regexp, String &out)
+void LogParserRule::expandMacros(const char *regexp, String &out)
 {
        const char *curr, *prev;
        char name[256];
@@ -171,7 +204,7 @@ void LogParserRule::ExpandMacros(const char *regexp, String &out)
                                        for(i = 0; (*curr != 0) && (*curr != '}'); i++)
                                                name[i] = *curr++;
                                        name[i] = 0;
-                                       out += m_parser->GetMacro(name);
+                                       out += m_parser->getMacro(name);
                                }
                                else
                                {
index 584413d..2f21a2e 100644 (file)
@@ -49,7 +49,7 @@ static void GenerateCurrentFileName(LogParser *parser, char *fname)
 #else
        ltm = localtime(&t);
 #endif
-       _tcsftime(fname, MAX_PATH, parser->GetFileName(), ltm);
+       _tcsftime(fname, MAX_PATH, parser->getFileName(), ltm);
 }
 
 
@@ -81,7 +81,7 @@ static void ParseNewRecords(LogParser *parser, int fh)
                                        *(eptr - 1) = 0;
                                else
                                        *eptr = 0;
-                               parser->MatchLine(ptr);
+                               parser->matchLine(ptr);
          }
       }
       else
@@ -96,7 +96,7 @@ static void ParseNewRecords(LogParser *parser, int fh)
 // File parser thread
 //
 
-BOOL LogParser::MonitorFile(CONDITION stopCondition, BOOL *stopFlag, void (*logger)(int, const TCHAR *, ...))
+bool LogParser::monitorFile(CONDITION stopCondition, bool *stopFlag, void (*logger)(int, const TCHAR *, ...))
 {
        char fname[MAX_PATH], temp[MAX_PATH];
        struct stat st;
@@ -104,7 +104,7 @@ BOOL LogParser::MonitorFile(CONDITION stopCondition, BOOL *stopFlag, void (*logg
        int err, fh;
 
        if ((m_fileName == NULL) || (stopFlag == NULL))
-               return FALSE;
+               return false;
 
 
        if (logger != NULL)
@@ -168,5 +168,5 @@ BOOL LogParser::MonitorFile(CONDITION stopCondition, BOOL *stopFlag, void (*logg
 
        if (logger != NULL)
                logger(EVENTLOG_DEBUG_TYPE, _T("LogParser: parser thread for file \"%s\" stopped"), m_fileName);
-       return TRUE;
+       return true;
 }
index 153dcec..d1ebe38 100644 (file)
@@ -62,7 +62,7 @@ static void ParseNewRecords(LogParser *parser, HANDLE hFile, void (*logger)(int,
                                else
                                        *eptr = 0;
 
-                               parser->MatchLine(ptr);
+                               parser->matchLine(ptr);
          }
       }
       else
@@ -77,7 +77,7 @@ static void ParseNewRecords(LogParser *parser, HANDLE hFile, void (*logger)(int,
 // Monitor file changes and parse line by line
 //
 
-BOOL LogParser::MonitorFile(HANDLE stopEvent, void (*logger)(int, const TCHAR *, ...))
+bool LogParser::monitorFile(HANDLE stopEvent, void (*logger)(int, const TCHAR *, ...))
 {
    HANDLE hFile, hChange, handles[2];
    LARGE_INTEGER fp, fsnew;
@@ -157,5 +157,5 @@ BOOL LogParser::MonitorFile(HANDLE stopEvent, void (*logger)(int, const TCHAR *,
                        logger(EVENTLOG_ERROR_TYPE, _T("LogParser: Cannot open log file %s"), m_fileName);
    }
 
-       return TRUE;
+       return true;
 }
index 5cf7b35..8a674fe 100644 (file)
@@ -18,5 +18,5 @@ libnxmapw_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
 libnxmapw_la_LIBADD = ../libnetxms/libnetxmsw.la
 
 EXTRA_DIST = \
-       libnxmap.vcproj libnxmapw.vcproj libnxmap.dsp \
+       libnxmap.vcproj libnxmapw.vcproj \
        libnxmap.h
diff --git a/src/libnxmap/libnxmap.dsp b/src/libnxmap/libnxmap.dsp
deleted file mode 100644 (file)
index b864d10..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libnxmap" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libnxmap - Win32 Debug UNICODE
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "libnxmap.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "libnxmap.mak" CFG="libnxmap - Win32 Debug UNICODE"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "libnxmap - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxmap - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxmap - Win32 Debug UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libnxmap - Win32 Release UNICODE" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "libnxmap - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "libnxmap_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXMAP_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\libnetxms\Release"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release\libnxmap.dll C:\NetXMS\bin copy Release\libnxmap.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxmap - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "libnxmap_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXMAP_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\libnetxms\Debug"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=copy Debug\libnxmap.dll ..\..\bin       copy Debug\libnxmap.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxmap - Win32 Debug UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "libnxmap___Win32_Debug_UNICODE"
-# PROP BASE Intermediate_Dir "libnxmap___Win32_Debug_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_UNICODE"
-# PROP Intermediate_Dir "Debug_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXMAP_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\include" /D "UNICODE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXMAP_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib libnxcscp.lib /nologo /version:0.1 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\libnetxms\Debug" /libpath:"..\libnxcscp\Debug"
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxmsw.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Debug_UNICODE/libnxmapw.dll" /pdbtype:sept /libpath:"..\libnetxms\Debug_UNICODE"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Cmds=copy Debug_UNICODE\libnxmapw.dll ..\..\bin      copy Debug_UNICODE\libnxmapw.pdb ..\..\bin
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "libnxmap - Win32 Release UNICODE"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "libnxmap___Win32_Release_UNICODE"
-# PROP BASE Intermediate_Dir "libnxmap___Win32_Release_UNICODE"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_UNICODE"
-# PROP Intermediate_Dir "Release_UNICODE"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXMAP_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O2 /I "..\..\include" /D "UNICODE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBNXMAP_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib libnxcscp.lib /nologo /version:0.1 /dll /machine:I386 /libpath:"..\libnetxms\Release" /libpath:"..\libnxcscp\Release"
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxmsw.lib ws2_32.lib /nologo /version:0.1 /dll /debug /machine:I386 /out:"Release_UNICODE/libnxmapw.dll" /pdbtype:sept /libpath:"..\libnetxms\Release_UNICODE"
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy files
-PostBuild_Cmds=copy Release_UNICODE\libnxmapw.dll C:\NetXMS\bin        copy Release_UNICODE\libnxmapw.pdb C:\NetXMS\bin
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "libnxmap - Win32 Release"
-# Name "libnxmap - Win32 Debug"
-# Name "libnxmap - Win32 Debug UNICODE"
-# Name "libnxmap - Win32 Release UNICODE"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\graph.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\main.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\map.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\objlist.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\radial.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\rt.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\submap.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\vertex.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\libnxmap.h
-# End Source File
-# Begin Source File
-
-SOURCE="..\..\include\netxms-version.h"
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\netxms_maps.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_common.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_cscp.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_threads.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nms_util.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxclapi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxcscpapi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxevent.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\nxtools.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\include\unicode.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/src/libnxmb/dispatcher.cpp b/src/libnxmb/dispatcher.cpp
new file mode 100644 (file)
index 0000000..5c587dc
--- /dev/null
@@ -0,0 +1,207 @@
+/* 
+** NetXMS - Network Management System
+** NetXMS Message Bus Library
+** Copyright (C) 2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: dispatcher.cpp
+**
+**/
+
+#include "libnxmb.h"
+
+
+//
+// Worker thread starter
+//
+
+static THREAD_RESULT THREAD_CALL WorkerThreadStarter(void *arg)
+{
+       ((NXMBDispatcher *)arg)->workerThread();
+       return THREAD_OK;
+}
+
+
+//
+// Constructor
+//
+
+NXMBDispatcher::NXMBDispatcher()
+{
+       m_queue = new Queue;
+       m_numSubscribers = 0;
+       m_subscribers = NULL;
+       m_filters = NULL;
+       m_subscriberListAccess = MutexCreate();
+       m_workerThreadHandle = ThreadCreateEx(WorkerThreadStarter, 0, this);
+}
+
+
+//
+// Destructor
+//
+
+NXMBDispatcher::~NXMBDispatcher()
+{
+       NXMBMessage *msg;
+       int i;
+
+       while((msg = (NXMBMessage *)m_queue->Get()) != NULL)
+               delete msg;
+       m_queue->Put(INVALID_POINTER_VALUE);
+       ThreadJoin(m_workerThreadHandle);
+
+       delete m_queue;
+
+       MutexDestroy(m_subscriberListAccess);
+
+       for(i = 0; i < m_numSubscribers; i++)
+       {
+               if ((m_subscribers[i] != NULL) && m_subscribers[i]->isOwnedByDispatcher())
+                       delete m_subscribers[i];
+               if ((m_filters[i] != NULL) && m_filters[i]->isOwnedByDispatcher())
+                       delete m_filters[i];
+       }
+       safe_free(m_subscribers);
+       safe_free(m_filters);
+}
+
+
+//
+// Worker thread
+//
+
+void NXMBDispatcher::workerThread()
+{
+       NXMBMessage *msg;
+       int i;
+
+       while(true)
+       {
+               msg = (NXMBMessage *)m_queue->GetOrBlock();
+               if (msg == INVALID_POINTER_VALUE)
+                       break;
+
+               MutexLock(m_subscriberListAccess, INFINITE);
+               for(i = 0; i < m_numSubscribers; i++)
+               {
+                       if (m_filters[i]->isAllowed(*msg))
+                               m_subscribers[i]->messageHandler(*msg);
+               }
+               MutexUnlock(m_subscriberListAccess);
+               delete msg;
+       }
+}
+
+
+//
+// Post message
+//
+
+void NXMBDispatcher::postMessage(NXMBMessage *msg)
+{
+       m_queue->Put(msg);
+}
+
+
+//
+// Add subscriber
+//
+
+void NXMBDispatcher::addSubscriber(NXMBSubscriber *subscriber, NXMBFilter *filter)
+{
+       int i;
+
+       MutexLock(m_subscriberListAccess, INFINITE);
+
+       for(i = 0; i < m_numSubscribers; i++)
+       {
+               if ((m_subscribers[i] != NULL) && (!_tcscmp(m_subscribers[i]->getId(), subscriber->getId())))
+               {
+                       // Subscriber already registered, replace it
+                       if (m_subscribers[i] != subscriber)
+                       {
+                               // Different object with same ID
+                               if (m_subscribers[i]->isOwnedByDispatcher())
+                                       delete m_subscribers[i];
+                               m_subscribers[i] = subscriber;
+                       }
+
+                       // Replace filter
+                       if (m_filters[i] != filter)
+                       {
+                               if (m_filters[i]->isOwnedByDispatcher())
+                                       delete m_filters[i];
+                               m_filters[i] = filter;
+                       }
+                       break;
+               }
+       }
+
+       if (i == m_numSubscribers)              // New subscriber
+       {
+               m_numSubscribers++;
+               m_subscribers = (NXMBSubscriber **)realloc(m_subscribers, sizeof(NXMBSubscriber *) * m_numSubscribers);
+               m_filters = (NXMBFilter **)realloc(m_filters, sizeof(NXMBFilter *) * m_numSubscribers);
+               m_subscribers[i] = subscriber;
+               m_filters[i] = filter;
+       }
+
+       MutexUnlock(m_subscriberListAccess);
+}
+
+
+//
+// Remove subscriber
+//
+
+void NXMBDispatcher::removeSubscriber(const TCHAR *id)
+{
+       int i;
+
+       MutexLock(m_subscriberListAccess, INFINITE);
+
+       for(i = 0; i < m_numSubscribers; i++)
+       {
+               if ((m_subscribers[i] != NULL) && (!_tcscmp(m_subscribers[i]->getId(), id)))
+               {
+                       if (m_subscribers[i]->isOwnedByDispatcher())
+                               delete m_subscribers[i];
+                       if ((m_filters[i] != NULL) && m_filters[i]->isOwnedByDispatcher())
+                               delete m_filters[i];
+                       m_numSubscribers--;
+                       memmove(&m_subscribers[i], &m_subscribers[i + 1], sizeof(NXMBSubscriber *) * (m_numSubscribers - i));
+                       memmove(&m_filters[i], &m_filters[i + 1], sizeof(NXMBFilter *) * (m_numSubscribers - i));
+                       break;
+               }
+       }
+
+       MutexUnlock(m_subscriberListAccess);
+}
+
+
+//
+// Get global dispatcher instance
+//
+
+NXMBDispatcher *NXMBDispatcher::m_instance = NULL;
+
+NXMBDispatcher *NXMBDispatcher::getInstance()
+{
+       if (m_instance == NULL)
+               m_instance = new NXMBDispatcher();
+       return m_instance;
+}
diff --git a/src/libnxmb/filter.cpp b/src/libnxmb/filter.cpp
new file mode 100644 (file)
index 0000000..9238582
--- /dev/null
@@ -0,0 +1,76 @@
+/* 
+** NetXMS - Network Management System
+** NetXMS Message Bus Library
+** Copyright (C) 2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: filter.cpp
+**
+**/
+
+#include "libnxmb.h"
+
+
+//
+// Basic filter class implementation
+//
+
+NXMBFilter::NXMBFilter()
+{
+}
+
+NXMBFilter::~NXMBFilter()
+{
+}
+
+bool NXMBFilter::isAllowed(NXMBMessage &msg)
+{ 
+       return TRUE;
+}
+
+bool NXMBFilter::isOwnedByDispatcher()
+{
+       return TRUE;
+}
+
+
+//
+// Filter by message type implementation
+//
+
+NXMBTypeFilter::NXMBTypeFilter()
+               :NXMBFilter()
+{
+}
+
+NXMBTypeFilter::~NXMBTypeFilter()
+{
+}
+
+bool NXMBTypeFilter::isAllowed(NXMBMessage &msg)
+{ 
+       return m_types.Get(msg.getType()) != NULL;
+}
+
+void NXMBTypeFilter::addMessageType(const TCHAR *type)
+{ 
+       m_types.Set(type, _T("*"));
+}
+
+void NXMBTypeFilter::removeMessageType(const TCHAR *type)
+{ 
+       m_types.Delete(type);
+}
diff --git a/src/libnxmb/libnxmb.h b/src/libnxmb/libnxmb.h
new file mode 100644 (file)
index 0000000..4771738
--- /dev/null
@@ -0,0 +1,30 @@
+/* 
+** NetXMS - Network Management System
+** NetXMS Message Bus library
+** Copyright (C) 2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: libnxmb.h
+**
+**/
+
+#ifndef _libnxmb_h_
+#define _libnxmb_h_
+
+#include <nxmbapi.h>
+
+
+#endif
similarity index 61%
copy from src/libnetxms/libnetxms.vcproj
copy to src/libnxmb/libnxmb.vcproj
index 3b3708a..425f9ea 100644 (file)
@@ -2,9 +2,9 @@
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
        Version="8.00"\r
-       Name="libnetxms"\r
-       ProjectGUID="{B1745870-F3ED-4ACB-B813-0C4F47EF0793}"\r
-       RootNamespace="libnetxms"\r
+       Name="libnxmb"\r
+       ProjectGUID="{DAA82F5C-1144-4DC0-A2E8-5253068565F1}"\r
+       RootNamespace="libnxmb"\r
        Keyword="Win32Proj"\r
        >\r
        <Platforms>\r
@@ -43,8 +43,8 @@
                        <Tool\r
                                Name="VCCLCompilerTool"\r
                                Optimization="0"\r
-                               AdditionalIncludeDirectories="..\..\include;..\libexpat\libexpat"\r
-                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_DEBUG;_USRDLL;LIBNETXMS_EXPORTS"\r
+                               AdditionalIncludeDirectories="..\..\include"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBNXMB_EXPORTS"\r
                                MinimalRebuild="true"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="3"\r
@@ -64,7 +64,6 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="2"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
-                               AdditionalIncludeDirectories="..\..\include;..\libexpat\libexpat"\r
-                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_DEBUG;_USRDLL;LIBNETXMS_EXPORTS"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="3"\r
+                               AdditionalIncludeDirectories="..\..\include"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBNXMB_EXPORTS"\r
+                               RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               TargetMachine="17"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="2"\r
                        CharacterSet="2"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               AdditionalIncludeDirectories="..\..\include;..\libexpat\libexpat"\r
-                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_USRDLL;LIBNETXMS_EXPORTS;NDEBUG"\r
-                               RuntimeLibrary="2"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="..\..\include"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBNXMB_EXPORTS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="false"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
-                               LinkIncremental="1"\r
+                               LinkIncremental="2"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               TargetMachine="1"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               AdditionalIncludeDirectories="..\..\include;..\libexpat\libexpat"\r
-                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;NDEBUG;_USRDLL;LIBNETXMS_EXPORTS"\r
+                               AdditionalIncludeDirectories="..\..\include"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBNXMB_EXPORTS"\r
                                RuntimeLibrary="2"\r
                                UsePrecompiledHeader="0"\r
                                WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
+                               Detect64BitPortabilityProblems="false"\r
                                DebugInformationFormat="3"\r
                        />\r
                        <Tool\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               AdditionalDependencies="ws2_32.lib libeay32.lib crypt32.lib"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
                        UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
                        >\r
                        <File\r
-                               RelativePath=".\base64.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\config.cpp"\r
+                               RelativePath=".\dispatcher.cpp"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\crypto.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\dir.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\dload.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\gen_uuid.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\getopt.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\hash.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\icmp.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\inline.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\log.cpp"\r
+                               RelativePath=".\filter.cpp"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath=".\main.cpp"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\md5.cpp"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\message.cpp"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\msgwq.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\nxcp.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\qsort.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\queue.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\regex.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\rwlock.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\scandir.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\seh.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\serial.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\sha1.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\StackWalker.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\string.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\strmap.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\strtoll.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\strtoull.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\table.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\threads.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\tools.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\unicode.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\uuid.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\wcstoll.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\wcstoull.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\xml.cpp"\r
+                               RelativePath=".\subscriber.cpp"\r
                                >\r
                        </File>\r
                </Filter>\r
                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
                        >\r
                        <File\r
-                               RelativePath="..\..\include\base64.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\libnetxms.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\md5.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\include\netxms-regex.h"\r
+                               RelativePath=".\libnxmb.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\include\netxms-version.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\include\netxms_getopt.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\include\nms_agent.h"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\include\nms_common.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\include\nms_cscp.h"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\include\nms_threads.h"\r
                                >\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\..\include\nxcpapi.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\..\include\nxlog.h"\r
+                               RelativePath="..\..\include\nxmbapi.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\include\nxqueue.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\..\include\rwlock.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\sha1.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\StackWalker.h"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\..\include\unicode.h"\r
                                >\r
                                RelativePath="..\..\include\uuid.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\uuidP.h"\r
-                               >\r
-                       </File>\r
                </Filter>\r
                <Filter\r
                        Name="Resource Files"\r
diff --git a/src/libnxmb/main.cpp b/src/libnxmb/main.cpp
new file mode 100644 (file)
index 0000000..604531f
--- /dev/null
@@ -0,0 +1,40 @@
+/* 
+** NetXMS - Network Management System
+** NetXMS Message Bus Library
+** Copyright (C) 2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: main.cpp
+**
+**/
+
+#include "libnxmb.h"
+
+
+//
+// DLL entry point
+//
+
+#if defined(_WIN32) && !defined(UNDER_CE)
+
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+   if (dwReason == DLL_PROCESS_ATTACH)
+      DisableThreadLibraryCalls(hInstance);
+   return TRUE;
+}
+
+#endif   /* _WIN32 */
diff --git a/src/libnxmb/message.cpp b/src/libnxmb/message.cpp
new file mode 100644 (file)
index 0000000..da32ae2
--- /dev/null
@@ -0,0 +1,57 @@
+/* 
+** NetXMS - Network Management System
+** NetXMS Message Bus Library
+** Copyright (C) 2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: message.cpp
+**
+**/
+
+#include "libnxmb.h"
+
+
+//
+// Default constructor
+//
+
+NXMBMessage::NXMBMessage()
+{
+       m_type = _tcsdup(_T("NONE"));
+       m_senderId = _tcsdup(_T("UNKNOWN"));
+}
+
+
+//
+// Create message with type and sender information
+//
+
+NXMBMessage::NXMBMessage(const TCHAR *type, const TCHAR *senderId)
+{
+       m_type = _tcsdup(CHECK_NULL(type));
+       m_senderId = _tcsdup(CHECK_NULL(senderId));
+}
+
+
+//
+// Destructor
+//
+
+NXMBMessage::~NXMBMessage()
+{
+       safe_free(m_type);
+       safe_free(m_senderId);
+}
diff --git a/src/libnxmb/subscriber.cpp b/src/libnxmb/subscriber.cpp
new file mode 100644 (file)
index 0000000..3556c00
--- /dev/null
@@ -0,0 +1,64 @@
+/* 
+** NetXMS - Network Management System
+** NetXMS Message Bus Library
+** Copyright (C) 2009 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: subscriber.cpp
+**
+**/
+
+#include "libnxmb.h"
+
+
+//
+// Default constructor
+//
+
+NXMBSubscriber::NXMBSubscriber(const TCHAR *id)
+{
+       m_id = _tcsdup(CHECK_NULL(id));
+}
+
+
+//
+// Desctructor
+//
+
+NXMBSubscriber::~NXMBSubscriber()
+{
+       safe_free(m_id);
+}
+
+
+//
+// Default message handler
+//
+
+void NXMBSubscriber::messageHandler(NXMBMessage &msg)
+{
+}
+
+
+//
+// If this method returns TRUE, dispatcher will delete subscriber object
+// on unregister or in own destructor
+//
+
+bool NXMBSubscriber::isOwnedByDispatcher()
+{
+       return true;
+}