server compiles and (somehow) working with UNICODE support
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 15 Dec 2010 22:53:57 +0000 (22:53 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 15 Dec 2010 22:53:57 +0000 (22:53 +0000)
16 files changed:
include/nms_util.h
include/nxlog.h
netxms.sln
src/libnetxms/log.cpp
src/libnetxms/tools.cpp
src/server/core/netmap.cpp
src/server/core/session.cpp
src/server/core/snmp.cpp
src/server/core/syslogd.cpp
src/server/include/nms_core.h
src/server/include/nxsrvapi.h
src/server/libnxsrv/agent.cpp
src/server/netxmsd/netxmsd.cpp
src/server/netxmsd/netxmsd.h
src/server/netxmsd/netxmsd.vcproj
src/server/netxmsd/winsrv.cpp

index 9633d92..3e29dea 100644 (file)
@@ -521,6 +521,9 @@ extern "C"
 
    int LIBNETXMS_EXPORTABLE BitsInMask(DWORD dwMask);
    TCHAR LIBNETXMS_EXPORTABLE *IpToStr(DWORD dwAddr, TCHAR *szBuffer);
+#ifdef UNICODE
+   char LIBNETXMS_EXPORTABLE *IpToStrA(DWORD dwAddr, char *szBuffer);
+#endif
    DWORD LIBNETXMS_EXPORTABLE ResolveHostName(const TCHAR *pszName);
 #ifdef UNICODE
    DWORD LIBNETXMS_EXPORTABLE ResolveHostNameA(const char *pszName);
index 769db04..d0377c1 100644 (file)
@@ -57,7 +57,7 @@
 
 
 //
-// Unified log record structure
+// Syslog message structure
 //
 
 typedef struct
@@ -67,10 +67,10 @@ typedef struct
    int nFacility;
    int nSeverity;
    DWORD dwSourceObject;
-   TCHAR szHostName[MAX_SYSLOG_HOSTNAME_LEN];
-   TCHAR szTag[MAX_SYSLOG_TAG_LEN];
-   TCHAR szMessage[MAX_LOG_MSG_LENGTH];
-} NX_LOG_RECORD;
+   char szHostName[MAX_SYSLOG_HOSTNAME_LEN];
+   char szTag[MAX_SYSLOG_TAG_LEN];
+   char szMessage[MAX_LOG_MSG_LENGTH];
+} NX_SYSLOG_RECORD;
 
 
 #endif
index 45cb7c4..7ded79d 100644 (file)
@@ -186,13 +186,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnxsrv", "src\server\libn
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nxcore", "src\server\core\nxcore.vcproj", "{3B172035-5EEC-45A3-8471-2C390B7ED683}"
        ProjectSection(ProjectDependencies) = postProject
+               {B2988503-1921-4B9F-BBC1-5E5CF62F335E} = {B2988503-1921-4B9F-BBC1-5E5CF62F335E}
+               {406AE5C7-343D-4C88-B8F3-84E46255B830} = {406AE5C7-343D-4C88-B8F3-84E46255B830}
                {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC} = {7DC90EE4-E31C-4F12-8F1E-81F10E9099FC}
                {0A5E80F3-485D-40C8-BE1E-9D7EE744DB8B} = {0A5E80F3-485D-40C8-BE1E-9D7EE744DB8B}
                {96EF0643-89FD-47CD-B82E-9F7D1DAF35EC} = {96EF0643-89FD-47CD-B82E-9F7D1DAF35EC}
                {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA} = {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA}
                {64EFC0C2-C67B-41F6-851D-F11DAB27A60B} = {64EFC0C2-C67B-41F6-851D-F11DAB27A60B}
                {CB89D905-C8BE-4027-B2D8-F96C245E9160} = {CB89D905-C8BE-4027-B2D8-F96C245E9160}
-               {B2988503-1921-4B9F-BBC1-5E5CF62F335E} = {B2988503-1921-4B9F-BBC1-5E5CF62F335E}
        EndProjectSection
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nxsl", "nxsl", "{CE0DA89E-CF0C-452C-9C33-75A143355BDC}"
@@ -211,9 +212,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nxscript", "src\nxscript\nx
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "netxmsd", "src\server\netxmsd\netxmsd.vcproj", "{E417A0C4-41F1-4F87-8C33-8526ECB1F8AF}"
        ProjectSection(ProjectDependencies) = postProject
-               {B1745870-F3ED-4ACB-B813-0C4F47EF0793} = {B1745870-F3ED-4ACB-B813-0C4F47EF0793}
                {3B172035-5EEC-45A3-8471-2C390B7ED683} = {3B172035-5EEC-45A3-8471-2C390B7ED683}
                {CB89D905-C8BE-4027-B2D8-F96C245E9160} = {CB89D905-C8BE-4027-B2D8-F96C245E9160}
+               {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA} = {AEB182ED-7F5C-4F5A-BCE1-9A38E98579BA}
        EndProjectSection
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{64482674-7B36-4A14-A612-247333174315}"
index 0434863..b61ccf8 100644 (file)
@@ -405,7 +405,7 @@ void LIBNETXMS_EXPORTABLE nxlog_write(DWORD msg, WORD wType, const char *format,
                                  (LPTSTR)&pMsg, 0, NULL) > 0)
                {
                   pMsg[_tcscspn(pMsg, _T("\r\n"))] = 0;
-                  strings[numStrings] = (TCHAR *)malloc(_tcslen(pMsg) + 1);
+                  strings[numStrings] = (TCHAR *)malloc((_tcslen(pMsg) + 1) * sizeof(TCHAR));
                   _tcscpy(strings[numStrings], pMsg);
                   LocalFree(pMsg);
                }
index 5135066..bd5c34a 100644 (file)
@@ -78,12 +78,27 @@ TCHAR LIBNETXMS_EXPORTABLE *IpToStr(DWORD dwAddr, TCHAR *szBuffer)
    static TCHAR szInternalBuffer[32];
    TCHAR *szBufPtr;
 
-   szBufPtr = szBuffer == NULL ? szInternalBuffer : szBuffer;
+   szBufPtr = (szBuffer == NULL) ? szInternalBuffer : szBuffer;
    _sntprintf(szBufPtr, 32, _T("%d.%d.%d.%d"), (int)(dwAddr >> 24), (int)((dwAddr >> 16) & 255),
               (int)((dwAddr >> 8) & 255), (int)(dwAddr & 255));
    return szBufPtr;
 }
 
+#ifdef UNICODE
+
+char LIBNETXMS_EXPORTABLE *IpToStrA(DWORD dwAddr, char *szBuffer)
+{
+   static char szInternalBuffer[32];
+   char *szBufPtr;
+
+   szBufPtr = (szBuffer == NULL) ? szInternalBuffer : szBuffer;
+   snprintf(szBufPtr, 32, "%d.%d.%d.%d", (int)(dwAddr >> 24), (int)((dwAddr >> 16) & 255),
+            (int)((dwAddr >> 8) & 255), (int)(dwAddr & 255));
+   return szBufPtr;
+}
+
+#endif
+
 
 //
 // Duplicate memory block
index 5365c35..e7df35d 100644 (file)
@@ -262,7 +262,7 @@ BOOL NetworkMap::CreateFromDB(DWORD dwId)
       }
 
                // Load links
-      _sntprintf(query, 256, _T("SELECT element1,element2,link_type,link_name,connector_name1,connector_name2 FROM network_map_elements WHERE map_id=%d"), m_dwId);
+      _sntprintf(query, 256, _T("SELECT element1,element2,link_type,link_name,connector_name1,connector_name2 FROM network_map_links WHERE map_id=%d"), m_dwId);
       hResult = DBSelect(g_hCoreDB, query);
       if (hResult != NULL)
       {
index c8dc5bc..7b28443 100644 (file)
@@ -605,7 +605,7 @@ void ClientSession::UpdateThread()
          case INFO_CAT_SYSLOG_MSG:
             MutexLock(m_mutexSendSyslog, INFINITE);
             msg.SetCode(CMD_SYSLOG_RECORDS);
-            CreateMessageFromSyslogMsg(&msg, (NX_LOG_RECORD *)pUpdate->pData);
+            CreateMessageFromSyslogMsg(&msg, (NX_SYSLOG_RECORD *)pUpdate->pData);
             sendMessage(&msg);
             MutexUnlock(m_mutexSendSyslog);
             free(pUpdate->pData);
@@ -6649,7 +6649,7 @@ void ClientSession::KillSession(CSCPMessage *pRequest)
 // Handler for new syslog messages
 //
 
-void ClientSession::onSyslogMessage(NX_LOG_RECORD *pRec)
+void ClientSession::onSyslogMessage(NX_SYSLOG_RECORD *pRec)
 {
    UPDATE_INFO *pUpdate;
 
@@ -6657,7 +6657,7 @@ void ClientSession::onSyslogMessage(NX_LOG_RECORD *pRec)
    {
       pUpdate = (UPDATE_INFO *)malloc(sizeof(UPDATE_INFO));
       pUpdate->dwCategory = INFO_CAT_SYSLOG_MSG;
-      pUpdate->pData = nx_memdup(pRec, sizeof(NX_LOG_RECORD));
+      pUpdate->pData = nx_memdup(pRec, sizeof(NX_SYSLOG_RECORD));
       m_pUpdateQueue->Put(pUpdate);
    }
 }
index b1a2431..6cc0673 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
+** Copyright (C) 2003-2010 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
@@ -817,7 +817,7 @@ restart_check:
        }
 
        // Check default community
-       DbgPrintf(5, _T("SnmpCheckCommSettings: trying version %d community '%s'"), snmpVer, defCommunity);
+       DbgPrintf(5, _T("SnmpCheckCommSettings: trying version %d community '%hs'"), snmpVer, defCommunity);
        pTransport->setSecurityContext(new SNMP_SecurityContext(defCommunity));
        if (SnmpGet(snmpVer, pTransport, _T(".1.3.6.1.2.1.1.2.0"), NULL,
                         0, buffer, 1024, FALSE, FALSE) == SNMP_ERR_SUCCESS)
index 8589118..6c622e2 100644 (file)
@@ -151,12 +151,12 @@ static BOOL ParseTimeStamp(char **ppStart, int nMsgSize, int *pnPos, time_t *ptm
 // Parse syslog message
 //
 
-static BOOL ParseSyslogMessage(char *psMsg, int nMsgLen, NX_LOG_RECORD *pRec)
+static BOOL ParseSyslogMessage(char *psMsg, int nMsgLen, NX_SYSLOG_RECORD *pRec)
 {
    int i, nLen, nPos = 0;
    char *pCurr = psMsg;
 
-   memset(pRec, 0, sizeof(NX_LOG_RECORD));
+   memset(pRec, 0, sizeof(NX_SYSLOG_RECORD));
 
    // Parse PRI part
    if (*psMsg == '<')
@@ -233,7 +233,7 @@ static BOOL ParseSyslogMessage(char *psMsg, int nMsgLen, NX_LOG_RECORD *pRec)
 // dwSourceIP is an IP address from which we receive message
 //
 
-static void BindMsgToNode(NX_LOG_RECORD *pRec, DWORD dwSourceIP)
+static void BindMsgToNode(NX_SYSLOG_RECORD *pRec, DWORD dwSourceIP)
 {
    Node *pNode = NULL;
    DWORD dwIpAddr;
@@ -246,10 +246,17 @@ static void BindMsgToNode(NX_LOG_RECORD *pRec, DWORD dwSourceIP)
    }
    else
    {
-      dwIpAddr = ResolveHostName(pRec->szHostName);
+      dwIpAddr = ResolveHostNameA(pRec->szHostName);
                if ((dwIpAddr == INADDR_NONE) || (dwIpAddr == INADDR_ANY))
                {
+#ifdef UNICODE
+                       WCHAR wname[MAX_OBJECT_NAME];
+                       MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pRec->szHostName, -1, wname, MAX_OBJECT_NAME);
+                       wname[MAX_OBJECT_NAME - 1] = 0;
+                       pNode = (Node *)FindObjectByName(wname, OBJECT_NODE);
+#else
                        pNode = (Node *)FindObjectByName(pRec->szHostName, OBJECT_NODE);
+#endif
                        if (pNode == NULL)
                                dwIpAddr = dwSourceIP;
                }
@@ -263,12 +270,19 @@ static void BindMsgToNode(NX_LOG_RECORD *pRec, DWORD dwSourceIP)
    {
       pRec->dwSourceObject = pNode->Id();
       if (pRec->szHostName[0] == 0)
+               {
+#ifdef UNICODE
+                       WideCharToMultiByte(CP_ACP, WC_DEFAULTCHAR | WC_COMPOSITECHECK, pNode->Name(), -1, pRec->szHostName, MAX_SYSLOG_HOSTNAME_LEN, NULL, NULL);
+                       pRec->szHostName[MAX_SYSLOG_HOSTNAME_LEN - 1] = 0;
+#else
          nx_strncpy(pRec->szHostName, pNode->Name(), MAX_SYSLOG_HOSTNAME_LEN);
+#endif
+               }
    }
    else
    {
       if (pRec->szHostName[0] == 0)
-         IpToStr(dwSourceIP, pRec->szHostName);
+         IpToStrA(dwSourceIP, pRec->szHostName);
    }
 }
 
@@ -280,7 +294,7 @@ static void BindMsgToNode(NX_LOG_RECORD *pRec, DWORD dwSourceIP)
 static void BroadcastSyslogMessage(ClientSession *pSession, void *pArg)
 {
    if (pSession->isAuthenticated())
-      pSession->onSyslogMessage((NX_LOG_RECORD *)pArg);
+      pSession->onSyslogMessage((NX_SYSLOG_RECORD *)pArg);
 }
 
 
@@ -290,7 +304,7 @@ static void BroadcastSyslogMessage(ClientSession *pSession, void *pArg)
 
 static void ProcessSyslogMessage(char *psMsg, int nMsgLen, DWORD dwSourceIP)
 {
-   NX_LOG_RECORD record;
+   NX_SYSLOG_RECORD record;
    TCHAR szQuery[4096];
 
    if (ParseSyslogMessage(psMsg, nMsgLen, &record))
@@ -303,7 +317,7 @@ static void ProcessSyslogMessage(char *psMsg, int nMsgLen, DWORD dwSourceIP)
                  _T("(") UINT64_FMT _T(",") TIME_T_FMT _T(",%d,%d,%d,'%s','%s',%s)"),
                  record.qwMsgId, record.tmTimeStamp, record.nFacility,
                  record.nSeverity, record.dwSourceObject,
-                                         record.szHostName, record.szTag, (const TCHAR *)DBPrepareString(g_hCoreDB, record.szMessage));
+                                         record.szHostName, record.szTag, (const TCHAR *)DBPrepareStringA(g_hCoreDB, record.szMessage));
       DBQuery(g_hCoreDB, szQuery);
 
       // Send message to all connected clients
@@ -566,10 +580,10 @@ THREAD_RESULT THREAD_CALL SyslogDaemon(void *pArg)
 
 
 //
-// Create NXCP message from NX_LOG_RECORd structure
+// Create NXCP message from NX_SYSLOG_RECORD structure
 //
 
-void CreateMessageFromSyslogMsg(CSCPMessage *pMsg, NX_LOG_RECORD *pRec)
+void CreateMessageFromSyslogMsg(CSCPMessage *pMsg, NX_SYSLOG_RECORD *pRec)
 {
    DWORD dwId = VID_SYSLOG_MSG_BASE;
 
@@ -579,9 +593,9 @@ void CreateMessageFromSyslogMsg(CSCPMessage *pMsg, NX_LOG_RECORD *pRec)
    pMsg->SetVariable(dwId++, (WORD)pRec->nFacility);
    pMsg->SetVariable(dwId++, (WORD)pRec->nSeverity);
    pMsg->SetVariable(dwId++, pRec->dwSourceObject);
-   pMsg->SetVariable(dwId++, pRec->szHostName);
-   pMsg->SetVariable(dwId++, pRec->szTag);
-   pMsg->SetVariable(dwId++, pRec->szMessage);
+   pMsg->SetVariableFromMBString(dwId++, pRec->szHostName);
+   pMsg->SetVariableFromMBString(dwId++, pRec->szTag);
+       pMsg->SetVariableFromMBString(dwId++, pRec->szMessage);
 }
 
 
index 4873ce3..d653dc3 100644 (file)
@@ -587,7 +587,7 @@ public:
 
        void queueUpdate(UPDATE_INFO *pUpdate) { m_pUpdateQueue->Put(pUpdate); }
    void onNewEvent(Event *pEvent);
-   void onSyslogMessage(NX_LOG_RECORD *pRec);
+   void onSyslogMessage(NX_SYSLOG_RECORD *pRec);
    void onNewSNMPTrap(CSCPMessage *pMsg);
    void onObjectChange(NetObj *pObject);
    void onUserDBUpdate(int code, DWORD id, UserDatabaseObject *user);
@@ -721,7 +721,7 @@ DWORD ExecuteTableTool(DWORD dwToolId, Node *pNode, DWORD dwRqId, ClientSession
 DWORD DeleteObjectToolFromDB(DWORD dwToolId);
 DWORD UpdateObjectToolFromMessage(CSCPMessage *pMsg);
 
-void CreateMessageFromSyslogMsg(CSCPMessage *pMsg, NX_LOG_RECORD *pRec);
+void CreateMessageFromSyslogMsg(CSCPMessage *pMsg, NX_SYSLOG_RECORD *pRec);
 void ReinitializeSyslogParser();
 
 void EscapeString(String &str);
index ff6c1be..4ef03b3 100644 (file)
@@ -327,7 +327,7 @@ public:
    DWORD GetParameter(const TCHAR *pszParam, DWORD dwBufSize, TCHAR *pszBuffer);
    DWORD GetList(const TCHAR *pszParam);
    DWORD nop();
-   DWORD ExecAction(const TCHAR *pszAction, int argc, const TCHAR **argv);
+   DWORD ExecAction(const TCHAR *pszAction, int argc, TCHAR **argv);
    DWORD UploadFile(const TCHAR *pszFile, void (* progressCallback)(INT64, void *) = NULL, void *cbArg = NULL);
    DWORD StartUpgrade(const TCHAR *pszPkgName);
    DWORD CheckNetworkService(DWORD *pdwStatus, DWORD dwIpAddr, int iServiceType, WORD wPort = 0, 
index 345a130..30294ae 100644 (file)
@@ -934,7 +934,7 @@ DWORD AgentConnection::authenticate(BOOL bProxyData)
 // Execute action on agent
 //
 
-DWORD AgentConnection::ExecAction(const TCHAR *pszAction, int argc, const TCHAR **argv)
+DWORD AgentConnection::ExecAction(const TCHAR *pszAction, int argc, TCHAR **argv)
 {
    CSCPMessage msg(m_nProtocolVersion);
    DWORD dwRqId;
index 8ee58ff..5772aeb 100644 (file)
@@ -43,42 +43,42 @@ BOOL g_bCheckDB = FALSE;
 // Help text
 //
 
-static char help_text[]="NetXMS Server Version " NETXMS_VERSION_STRING "\n"
-                        "Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 NetXMS Team\n\n"
-                        "Usage: netxmsd [<options>]\n\n"
-                        "Valid options are:\n"
-                        "   -e          : Run database check on startup\n"
-                        "   -c <file>   : Set non-default configuration file\n"
-                        "               : Default is " DEFAULT_CONFIG_FILE "\n"
-                        "   -d          : Run as daemon/service\n"
-                        "   -D <level>  : Set debug level (valid levels are 0..9)\n"
-                        "   -h          : Display help and exit\n"
+static TCHAR help_text[] = _T("NetXMS Server Version ") NETXMS_VERSION_STRING _T("\n")
+                           _T("Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 NetXMS Team\n\n")
+                           _T("Usage: netxmsd [<options>]\n\n")
+                           _T("Valid options are:\n")
+                           _T("   -e          : Run database check on startup\n")
+                           _T("   -c <file>   : Set non-default configuration file\n")
+                           _T("               : Default is ") DEFAULT_CONFIG_FILE _T("\n")
+                           _T("   -d          : Run as daemon/service\n")
+                           _T("   -D <level>  : Set debug level (valid levels are 0..9)\n")
+                           _T("   -h          : Display help and exit\n")
 #ifdef _WIN32
-                        "   -I          : Install Windows service\n"
-                        "   -L <user>   : Login name for service account.\n"
-                        "   -P <passwd> : Password for service account.\n"
+                           _T("   -I          : Install Windows service\n")
+                           _T("   -L <user>   : Login name for service account.\n")
+                           _T("   -P <passwd> : Password for service account.\n")
 #else
-                        "   -p <file>   : Specify pid file.\n"
+                           _T("   -p <file>   : Specify pid file.\n")
 #endif
 #ifdef _WIN32
-                        "   -R          : Remove Windows service\n"
-                        "   -s          : Start Windows service\n"
-                        "   -S          : Stop Windows service\n"
+                           _T("   -R          : Remove Windows service\n")
+                           _T("   -s          : Start Windows service\n")
+                           _T("   -S          : Stop Windows service\n")
 #endif
-                        "   -v          : Display version and exit\n"
-                        "\n";
+                           _T("   -v          : Display version and exit\n")
+                           _T("\n");
 
 
 //
 // Execute command and wait
 //
 
-static BOOL ExecAndWait(TCHAR *pszCommand)
+static BOOL ExecAndWait(char *pszCommand)
 {
    BOOL bSuccess = TRUE;
 
 #ifdef _WIN32
-   STARTUPINFO si;
+   STARTUPINFOA si;
    PROCESS_INFORMATION pi;
 
    // Fill in process startup info structure
@@ -87,9 +87,9 @@ static BOOL ExecAndWait(TCHAR *pszCommand)
    si.dwFlags = 0;
 
    // Create new process
-   if (!CreateProcess(NULL, pszCommand, NULL, NULL, FALSE,
-                      IsStandalone() ? 0 : CREATE_NO_WINDOW | DETACHED_PROCESS,
-                      NULL, NULL, &si, &pi))
+   if (!CreateProcessA(NULL, pszCommand, NULL, NULL, FALSE,
+                       IsStandalone() ? 0 : CREATE_NO_WINDOW | DETACHED_PROCESS,
+                       NULL, NULL, &si, &pi))
    {
       bSuccess = FALSE;
    }
@@ -120,7 +120,7 @@ static void CreateMiniDump(DWORD pid)
    HANDLE hFile, hProcess;
        TCHAR error[256];
 
-       printf("INFO: Starting minidump for process %d\n", pid);
+       _tprintf(_T("INFO: Starting minidump for process %d\n"), pid);
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
        if (hProcess != NULL)
        {
@@ -130,16 +130,16 @@ static void CreateMiniDump(DWORD pid)
                {
                        MiniDumpWriteDump(hProcess, pid, hFile, MiniDumpNormal, NULL, NULL, NULL);
                        CloseHandle(hFile);
-                       printf("INFO: Minidump created successfully\n");
+                       _tprintf(_T("INFO: Minidump created successfully\n"));
                }
                else
                {
-                       printf("ERROR: cannot create file for minidump (%s)\n", GetSystemErrorText(GetLastError(), error, 256));
+                       _tprintf(_T("ERROR: cannot create file for minidump (%s)\n"), GetSystemErrorText(GetLastError(), error, 256));
                }
        }
        else
        {
-               printf("ERROR: cannot open process %d (%s)\n", pid, GetSystemErrorText(GetLastError(), error, 256));
+               _tprintf(_T("ERROR: cannot open process %d (%s)\n"), pid, GetSystemErrorText(GetLastError(), error, 256));
        }
 }
 
@@ -160,9 +160,10 @@ static void CreateMiniDump(DWORD pid)
 static BOOL ParseCommandLine(int argc, char *argv[])
 {
    int ch;
-   TCHAR *eptr;
+   char *eptr;
 #ifdef _WIN32
-       char login[256] = "", password[256] = "", exePath[MAX_PATH], dllPath[MAX_PATH], *ptr;
+       TCHAR login[256] = _T(""), password[256] = _T("");
+       char exePath[MAX_PATH], dllPath[MAX_PATH], *ptr;
        BOOL useLogin = FALSE;
 #endif
 #if defined(_WIN32) || HAVE_DECL_GETOPT_LONG
@@ -183,7 +184,7 @@ static BOOL ParseCommandLine(int argc, char *argv[])
                { "start", 0, NULL, 's' },
                { "stop", 0, NULL, 'S' },
 #else
-               { "pid-file", 1, NULL, 'p' },
+               { _T("pid-file"), 1, NULL, 'p' },
 #endif
                { NULL, 0, 0, 0 }
        };
@@ -198,17 +199,22 @@ static BOOL ParseCommandLine(int argc, char *argv[])
        switch(ch)
        {
                        case 'h':
-                printf(help_text);
+                _tprintf(help_text);
                 return FALSE;
                        case 'v':
-                               printf("NetXMS Server Version " NETXMS_VERSION_STRING " Build of " __DATE__ "\n");
+                               _tprintf(_T("NetXMS Server Version ") NETXMS_VERSION_STRING _T(" Build of %hs\n"), __DATE__);
                                return FALSE;
                        case 'c':
+#ifdef UNICODE
+                               MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, optarg, -1, g_szConfigFile, MAX_PATH);
+                               g_szConfigFile[MAX_PATH - 1] = 0;
+#else
                                nx_strncpy(g_szConfigFile, optarg, MAX_PATH);
+#endif
                                break;
                        case 'C':       // Check config
                                g_dwFlags &= ~AF_DAEMON;
-                               printf("Checking configuration file (%s):\n\n", g_szConfigFile);
+                               _tprintf(_T("Checking configuration file (%s):\n\n"), g_szConfigFile);
                                LoadConfig();
                                return FALSE;
                        case 'd':
@@ -218,7 +224,7 @@ static BOOL ParseCommandLine(int argc, char *argv[])
                                g_nDebugLevel = strtol(optarg, &eptr, 0);
                                if ((*eptr != 0) || (g_nDebugLevel < 0) || (g_nDebugLevel > 9))
                                {
-                                       printf("Invalid debug level \"%s\" - should be in range 0..9\n", optarg);
+                                       _tprintf(_T("Invalid debug level \"%hs\" - should be in range 0..9\n"), optarg);
                                        g_nDebugLevel = 0;
                                }
                                break;
@@ -227,11 +233,21 @@ static BOOL ParseCommandLine(int argc, char *argv[])
                                break;
 #ifdef _WIN32
                        case 'L':
+#ifdef UNICODE
+                               MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, optarg, -1, login, 256);
+                               login[255] = 0;
+#else
                                nx_strncpy(login, optarg, 256);
+#endif
                                useLogin = TRUE;
                                break;
                        case 'P':
+#ifdef UNICODE
+                               MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, optarg, -1, password, 256);
+                               password[255] = 0;
+#else
                                nx_strncpy(password, optarg, 256);
+#endif
                                break;
                        case 'I':       // Install service
                                ptr = strrchr(argv[0], '\\');
@@ -251,8 +267,16 @@ static BOOL ParseCommandLine(int argc, char *argv[])
                                        ptr++;
                                        strcpy(ptr, "libnxsrv.dll");
                                }
-
+#ifdef UNICODE
+                               WCHAR wexePath[MAX_PATH], wdllPath[MAX_PATH];
+                               MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, exePath, -1, wexePath, MAX_PATH);
+                               wexePath[MAX_PATH - 1] = 0;
+                               MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, dllPath, -1, wdllPath, MAX_PATH);
+                               wdllPath[MAX_PATH - 1] = 0;
+                               InstallService(wexePath, wdllPath, useLogin ? login : NULL, useLogin ? password : NULL);
+#else
                                InstallService(exePath, dllPath, useLogin ? login : NULL, useLogin ? password : NULL);
+#endif
                                return FALSE;
                        case 'R':       // Remove service
                                RemoveService();
@@ -267,7 +291,7 @@ static BOOL ParseCommandLine(int argc, char *argv[])
                                CheckServiceConfig();
                                return FALSE;
                        case '~':
-                               CreateMiniDump(_tcstoul(optarg, NULL, 0));
+                               CreateMiniDump(strtoul(optarg, NULL, 0));
                                return FALSE;
 #endif
                default:
@@ -309,7 +333,7 @@ int main(int argc, char *argv[])
       RegCloseKey(hKey);
    }
 #else
-   pszEnv = getenv("NETXMSD_CONFIG");
+   pszEnv = getenv(_T("NETXMSD_CONFIG"));
    if (pszEnv != NULL)
       nx_strncpy(g_szConfigFile, pszEnv, MAX_PATH);
 #endif
@@ -320,7 +344,7 @@ int main(int argc, char *argv[])
    if (!LoadConfig())
    {
       if (IsStandalone())
-         printf("Error loading configuration file\n");
+         _tprintf(_T("Error loading configuration file\n"));
       return 1;
    }
 
@@ -328,7 +352,7 @@ int main(int argc, char *argv[])
 #ifdef _WIN32
        if (g_dwFlags & AF_CATCH_EXCEPTIONS)
                SetExceptionHandler(SEHServiceExceptionHandler, SEHServiceExceptionDataWriter,
-                                   g_szDumpDir, "netxmsd", MSG_EXCEPTION, g_dwFlags & AF_WRITE_FULL_DUMP, IsStandalone());
+                                   g_szDumpDir, _T("netxmsd"), MSG_EXCEPTION, g_dwFlags & AF_WRITE_FULL_DUMP, IsStandalone());
        __try {
 #endif
 
@@ -343,10 +367,14 @@ int main(int argc, char *argv[])
          pszSep++;
       else
          pszSep = szCmd;
-      sprintf(pszSep, "nxdbmgr -c \"%s\" -f check", g_szConfigFile);
+#ifdef UNICODE
+      snprintf(pszSep, 128, "nxdbmgr -c \"%S\" -f check", g_szConfigFile);
+#else
+      snprintf(pszSep, 128, "nxdbmgr -c \"%s\" -f check", g_szConfigFile);
+#endif
       if (!ExecAndWait(szCmd))
          if (IsStandalone())
-            printf("ERROR: Failed to execute command \"%s\"\n", szCmd);
+            _tprintf(_T("ERROR: Failed to execute command \"%hs\"\n"), szCmd);
    }
 
 #ifdef _WIN32
@@ -358,7 +386,7 @@ int main(int argc, char *argv[])
    {
       if (!Initialize())
       {
-         printf("NetXMS Core initialization failed\n");
+         _tprintf(_T("NetXMS Core initialization failed\n"));
 
          // Remove database lock
          if (g_dwFlags & AF_DB_LOCKED)
@@ -381,10 +409,10 @@ int main(int argc, char *argv[])
    }
 
    // Write PID file
-   fp = fopen(g_szPIDFile, "w");
+   fp = _tfopen(g_szPIDFile, _T("w"));
    if (fp != NULL)
    {
-      fprintf(fp, "%d", getpid());
+      _ftprintf(fp, _T("%d"), getpid());
       fclose(fp);
    }
 
index 6a188d0..356a186 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** Server startup module
-** Copyright (C) 2003, 2004 Victor Kirhenshtein
+** Copyright (C) 2003-2010 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
@@ -17,7 +17,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: netxmsd.h
+** File: netxmsd.h
 **
 **/
 
 
 #ifdef _WIN32
 
-void InitService(void);
-void InstallService(TCHAR *pszExecName, TCHAR *pszDllName,
-                    TCHAR *pszLogin, TCHAR *pszPassword);
-void RemoveService(void);
-void CheckServiceConfig(void);
-void StartCoreService(void);
-void StopCoreService(void);
-void InstallEventSource(TCHAR *pszPath);
-void RemoveEventSource(void);
+void InitService();
+void InstallService(const TCHAR *pszExecName, const TCHAR *pszDllName,
+                    const TCHAR *pszLogin, const TCHAR *pszPassword);
+void RemoveService();
+void CheckServiceConfig();
+void StartCoreService();
+void StopCoreService();
+void InstallEventSource(const TCHAR *pszPath);
+void RemoveEventSource();
 
 #endif   /* _WIN32 */
 
index 4b755ec..604d157 100644 (file)
@@ -23,7 +23,7 @@
                        OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
                        IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="1"\r
-                       CharacterSet="2"\r
+                       CharacterSet="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
                        IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="1"\r
-                       CharacterSet="2"\r
+                       CharacterSet="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
                        IntermediateDirectory="$(ConfigurationName)"\r
                        ConfigurationType="1"\r
-                       CharacterSet="2"\r
+                       CharacterSet="1"\r
                        WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                        OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"\r
                        IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
                        ConfigurationType="1"\r
-                       CharacterSet="2"\r
+                       CharacterSet="1"\r
                        WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
index bf668d8..ef04062 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** NetXMS - Network Management System
-** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
+** Copyright (C) 2003-2010 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
@@ -129,7 +129,7 @@ void InitService()
        TCHAR errorText[1024];
 
    if (!StartServiceCtrlDispatcher(serviceTable))
-      printf("StartServiceCtrlDispatcher() failed: %s\n", GetSystemErrorText(GetLastError(), errorText, 1024));
+      _tprintf(_T("StartServiceCtrlDispatcher() failed: %s\n"), GetSystemErrorText(GetLastError(), errorText, 1024));
 }
 
 
@@ -137,8 +137,8 @@ void InitService()
 // Create service
 //
 
-void InstallService(TCHAR *pszExecName, TCHAR *pszDllName,
-                    TCHAR *pszLogin, TCHAR *pszPassword)
+void InstallService(const TCHAR *pszExecName, const TCHAR *pszDllName,
+                    const TCHAR *pszLogin, const TCHAR *pszPassword)
 {
    SC_HANDLE hMgr, hService;
    TCHAR szCmdLine[MAX_PATH * 2], errorText[1024];
@@ -146,14 +146,14 @@ void InstallService(TCHAR *pszExecName, TCHAR *pszDllName,
    hMgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (hMgr == NULL)
    {
-      printf("ERROR: Cannot connect to Service Manager (%s)\n",
+      _tprintf(_T("ERROR: Cannot connect to Service Manager (%s)\n"),
              GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
-   sprintf(szCmdLine, "\"%s\" -d --config \"%s\"%s", pszExecName, g_szConfigFile,
-           g_bCheckDB ? " --check-db" : "");
-   hService = CreateService(hMgr, CORE_SERVICE_NAME, "NetXMS Core",
+   _sntprintf(szCmdLine, MAX_PATH * 2, _T("\"%s\" -d --config \"%s\"%s"), pszExecName, g_szConfigFile,
+              g_bCheckDB ? _T(" --check-db") : _T(""));
+   hService = CreateService(hMgr, CORE_SERVICE_NAME, _T("NetXMS Core"),
                             GENERIC_READ, SERVICE_WIN32_OWN_PROCESS,
                             SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
                             szCmdLine, NULL, NULL, NULL, pszLogin, pszPassword);
@@ -162,13 +162,13 @@ void InstallService(TCHAR *pszExecName, TCHAR *pszDllName,
       DWORD code = GetLastError();
 
       if (code == ERROR_SERVICE_EXISTS)
-         printf("ERROR: Service named '" CORE_SERVICE_NAME "' already exist\n");
+         _tprintf(_T("ERROR: Service named '") CORE_SERVICE_NAME _T("' already exist\n"));
       else
-         printf("ERROR: Cannot create service (%s)\n", GetSystemErrorText(code, errorText, 1024));
+         _tprintf(_T("ERROR: Cannot create service (%s)\n"), GetSystemErrorText(code, errorText, 1024));
    }
    else
    {
-      printf("NetXMS Core service created successfully\n");
+      _tprintf(_T("NetXMS Core service created successfully\n"));
       CloseServiceHandle(hService);
    }
 
@@ -190,22 +190,22 @@ void RemoveService(void)
    mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (mgr == NULL)
    {
-      printf("ERROR: Cannot connect to Service Manager (%s)\n", GetSystemErrorText(GetLastError(), errorText, 1024));
+      _tprintf(_T("ERROR: Cannot connect to Service Manager (%s)\n"), GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
    service = OpenService(mgr, CORE_SERVICE_NAME, DELETE);
    if (service == NULL)
    {
-      printf("ERROR: Cannot open service named '" CORE_SERVICE_NAME "' (%s)\n",
+      _tprintf(_T("ERROR: Cannot open service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
              GetSystemErrorText(GetLastError(), errorText, 1024));
    }
    else
    {
       if (DeleteService(service))
-         printf("NetXMS Core service deleted successfully\n");
+         _tprintf(_T("NetXMS Core service deleted successfully\n"));
       else
-         printf("ERROR: Cannot remove service named '" CORE_SERVICE_NAME "' (%s)\n",
+         _tprintf(_T("ERROR: Cannot remove service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
                 GetSystemErrorText(GetLastError(), errorText, 1024));
 
       CloseServiceHandle(service);
@@ -281,7 +281,7 @@ void CheckServiceConfig(void)
    mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (mgr == NULL)
    {
-      printf("ERROR: Cannot connect to Service Manager (%s)\n", GetSystemErrorText(GetLastError(), errorText, 1024));
+      _tprintf(_T("ERROR: Cannot connect to Service Manager (%s)\n"), GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -304,37 +304,37 @@ void CheckServiceConfig(void)
                                                                                                        cfg->dwErrorControl, cmdLine, NULL, NULL,
                                                                                                        NULL, NULL, NULL, NULL))
                                        {
-                                               printf("INFO: Service configuration successfully updated\n");
+                                               _tprintf(_T("INFO: Service configuration successfully updated\n"));
                                        }
                                        else
                                        {
-                                               printf("ERROR: Cannot update configuration for service '" CORE_SERVICE_NAME "' (%s)\n",
+                                               _tprintf(_T("ERROR: Cannot update configuration for service '") CORE_SERVICE_NAME _T("' (%s)\n"),
                                                                 GetSystemErrorText(GetLastError(), errorText, 1024));
                                        }
                                        free(cmdLine);
                                }
                                else
                                {
-                                       printf("INFO: Service configuration is valid\n");
+                                       _tprintf(_T("INFO: Service configuration is valid\n"));
                                }
                        }
                        else
                        {
-                               printf("ERROR: Cannot query configuration for service '" CORE_SERVICE_NAME "' (%s)\n",
+                               _tprintf(_T("ERROR: Cannot query configuration for service '") CORE_SERVICE_NAME _T("' (%s)\n"),
                                                 GetSystemErrorText(GetLastError(), errorText, 1024));
                        }
                        free(cfg);
                }
                else
                {
-                       printf("ERROR: Cannot query configuration for service '" CORE_SERVICE_NAME "' (%s)\n",
+                       _tprintf(_T("ERROR: Cannot query configuration for service '") CORE_SERVICE_NAME _T("' (%s)\n"),
                                         GetSystemErrorText(error, errorText, 1024));
                }
       CloseServiceHandle(service);
        }
        else
    {
-      printf("ERROR: Cannot open service named '" CORE_SERVICE_NAME "' (%s)\n",
+      _tprintf(_T("ERROR: Cannot open service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
              GetSystemErrorText(GetLastError(), errorText, 1024));
    }
 
@@ -346,7 +346,7 @@ void CheckServiceConfig(void)
 // Start service
 //
 
-void StartCoreService(void)
+void StartCoreService()
 {
    SC_HANDLE mgr,service;
        TCHAR errorText[1024];
@@ -354,22 +354,22 @@ void StartCoreService(void)
    mgr = OpenSCManager(NULL,NULL,GENERIC_WRITE);
    if (mgr == NULL)
    {
-      printf("ERROR: Cannot connect to Service Manager (%s)\n", GetSystemErrorText(GetLastError(), errorText, 1024));
+      _tprintf(_T("ERROR: Cannot connect to Service Manager (%s)\n"), GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
    service = OpenService(mgr, CORE_SERVICE_NAME, SERVICE_START);
    if (service == NULL)
    {
-      printf("ERROR: Cannot open service named '" CORE_SERVICE_NAME "' (%s)\n",
+      _tprintf(_T("ERROR: Cannot open service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
              GetSystemErrorText(GetLastError(), errorText, 1024));
    }
    else
    {
       if (StartService(service, 0, NULL))
-         printf("NetXMS Core service started successfully\n");
+         _tprintf(_T("NetXMS Core service started successfully\n"));
       else
-         printf("ERROR: Cannot start service named '" CORE_SERVICE_NAME "' (%s)\n",
+         _tprintf(_T("ERROR: Cannot start service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
                 GetSystemErrorText(GetLastError(), errorText, 1024));
 
       CloseServiceHandle(service);
@@ -383,7 +383,7 @@ void StartCoreService(void)
 // Stop service
 //
 
-void StopCoreService(void)
+void StopCoreService()
 {
    SC_HANDLE mgr,service;
        TCHAR errorText[1024];
@@ -391,14 +391,14 @@ void StopCoreService(void)
    mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (mgr == NULL)
    {
-      printf("ERROR: Cannot connect to Service Manager (%s)\n", GetSystemErrorText(GetLastError(), errorText, 1024));
+      _tprintf(_T("ERROR: Cannot connect to Service Manager (%s)\n"), GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
    service = OpenService(mgr, CORE_SERVICE_NAME, SERVICE_STOP);
    if (service == NULL)
    {
-      printf("ERROR: Cannot open service named '" CORE_SERVICE_NAME "' (%s)\n",
+      _tprintf(_T("ERROR: Cannot open service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
              GetSystemErrorText(GetLastError(), errorText, 1024));
    }
    else
@@ -406,9 +406,9 @@ void StopCoreService(void)
       SERVICE_STATUS status;
 
       if (ControlService(service, SERVICE_CONTROL_STOP, &status))
-         printf("NetXMS Core service stopped successfully\n");
+         _tprintf(_T("NetXMS Core service stopped successfully\n"));
       else
-         printf("ERROR: Cannot stop service named '" CORE_SERVICE_NAME "' (%s)\n",
+         _tprintf(_T("ERROR: Cannot stop service named '") CORE_SERVICE_NAME _T("' (%s)\n"),
                 GetSystemErrorText(GetLastError(), errorText, 1024));
 
       CloseServiceHandle(service);
@@ -422,25 +422,25 @@ void StopCoreService(void)
 // Install event source
 //
 
-void InstallEventSource(char *path)
+void InstallEventSource(const TCHAR *path)
 {
    HKEY hKey;
    DWORD dwTypes = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
        TCHAR errorText[1024];
 
    if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_LOCAL_MACHINE,
-         "System\\CurrentControlSet\\Services\\EventLog\\System\\" CORE_EVENT_SOURCE,
+         _T("System\\CurrentControlSet\\Services\\EventLog\\System\\") CORE_EVENT_SOURCE,
          0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL))
    {
-      printf("Unable to create registry key: %s\n", GetSystemErrorText(GetLastError(), errorText, 1024));
+      _tprintf(_T("Unable to create registry key: %s\n"), GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
-   RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD,(BYTE *)&dwTypes, sizeof(DWORD));
-   RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,(BYTE *)path, (DWORD)_tcslen(path) + 1);
+   RegSetValueEx(hKey, _T("TypesSupported"), 0, REG_DWORD,(BYTE *)&dwTypes, sizeof(DWORD));
+   RegSetValueEx(hKey, _T("EventMessageFile"), 0, REG_EXPAND_SZ,(BYTE *)path, (DWORD)_tcslen(path) + 1);
 
    RegCloseKey(hKey);
-   printf("Event source \"" CORE_EVENT_SOURCE "\" installed successfully\n");
+   _tprintf(_T("Event source \"") CORE_EVENT_SOURCE _T("\" installed successfully\n"));
 }
 
 
@@ -448,18 +448,18 @@ void InstallEventSource(char *path)
 // Remove event source
 //
 
-void RemoveEventSource(void)
+void RemoveEventSource()
 {
        TCHAR errorText[1024];
 
    if (ERROR_SUCCESS == RegDeleteKey(HKEY_LOCAL_MACHINE,
-         "System\\CurrentControlSet\\Services\\EventLog\\System\\" CORE_EVENT_SOURCE))
+         _T("System\\CurrentControlSet\\Services\\EventLog\\System\\") CORE_EVENT_SOURCE))
    {
-      printf("Event source \"" CORE_EVENT_SOURCE "\" uninstalled successfully\n");
+      _tprintf(_T("Event source \"") CORE_EVENT_SOURCE _T("\" uninstalled successfully\n"));
    }
    else
    {
-      printf("Unable to uninstall event source \"" CORE_EVENT_SOURCE "\": %s\n",
+      _tprintf(_T("Unable to uninstall event source \"") CORE_EVENT_SOURCE _T("\": %s\n"),
              GetSystemErrorText(GetLastError(), errorText, 1024));
    }
 }