[SVN-NetXMS] revision 3320

From: NetXMS.org SVN Server <svn_at_DOMAIN_REMOVED>
Date: Thu, 19 Jun 2008 00:47:19 +0300

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

Info

Revision:3320
Author:victor

Date:2008-06-19 00:47:18 +0300 (Thu, 19 Jun 2008)

Comment:Changed to use GetSystemErrorText from libnetxms

Changes
U trunk/src/server/netxmsd/winsrv.cpp

Diff
Modified: trunk/src/server/netxmsd/winsrv.cpp
===================================================================
--- trunk/src/server/netxmsd/winsrv.cpp 2008-06-18 21:23:56 UTC (rev 3319)
+++ trunk/src/server/netxmsd/winsrv.cpp 2008-06-18 21:47:18 UTC (rev 3320)
@@ -28,7 +28,7 @@
 // Static data
 //
 
-static SERVICE_STATUS_HANDLE serviceHandle;
+static SERVICE_STATUS_HANDLE m_serviceHandle;
 
 
 //
@@ -53,7 +53,7 @@
       case SERVICE_CONTROL_SHUTDOWN:
          status.dwCurrentState = SERVICE_STOP_PENDING;
          status.dwWaitHint = 60000;
- SetServiceStatus(serviceHandle, &amp;status);
+ SetServiceStatus(m_serviceHandle, &amp;status);
 
          if (ctrlCode == SERVICE_CONTROL_SHUTDOWN)
             FastShutdown();
@@ -67,7 +67,7 @@
          break;
    }
 
- SetServiceStatus(serviceHandle, &amp;status);
+ SetServiceStatus(m_serviceHandle, &amp;status);
 }
 
 
@@ -79,7 +79,7 @@
 {
    SERVICE_STATUS status;
 
- serviceHandle = RegisterServiceCtrlHandler(CORE_SERVICE_NAME, ServiceCtrlHandler);
+ m_serviceHandle = RegisterServiceCtrlHandler(CORE_SERVICE_NAME, ServiceCtrlHandler);
 
    // Now we start service initialization
    status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
@@ -89,7 +89,7 @@
    status.dwServiceSpecificExitCode = 0;
    status.dwCheckPoint = 0;
    status.dwWaitHint = 300000; // Assume that startup can take up to 5 minutes
- SetServiceStatus(serviceHandle, &amp;status);
+ SetServiceStatus(m_serviceHandle, &amp;status);
 
    // Actual initialization
    if (!Initialize())
@@ -104,14 +104,14 @@
       // Now service is stopped
       status.dwCurrentState = SERVICE_STOPPED;
       status.dwWaitHint = 0;
- SetServiceStatus(serviceHandle, &amp;status);
+ SetServiceStatus(m_serviceHandle, &amp;status);
       return;
    }
 
    // Now service is running
    status.dwCurrentState = SERVICE_RUNNING;
    status.dwWaitHint = 0;
- SetServiceStatus(serviceHandle, &amp;status);
+ SetServiceStatus(m_serviceHandle, &amp;status);
 
    SetProcessShutdownParameters(0x3FF, 0);
 
@@ -126,9 +126,10 @@
 void InitService(void)
 {
    static SERVICE_TABLE_ENTRY serviceTable[2] = { { CORE_SERVICE_NAME, CoreServiceMain }, { NULL, NULL } };
+ TCHAR errorText[1024];
 
    if (!StartServiceCtrlDispatcher(serviceTable))
- printf(&quot;StartServiceCtrlDispatcher() failed: %s\n&quot;, GetSystemErrorText(GetLastError()));
+ printf(&quot;StartServiceCtrlDispatcher() failed: %s\n&quot;, GetSystemErrorText(GetLastError(), errorText, 1024));
 }
 
 
@@ -140,13 +141,13 @@
                     TCHAR *pszLogin, TCHAR *pszPassword)
 {
    SC_HANDLE hMgr, hService;
- TCHAR szCmdLine[MAX_PATH * 2];
+ TCHAR szCmdLine[MAX_PATH * 2], errorText[1024];
 
    hMgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (hMgr == NULL)
    {
       printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -163,7 +164,7 @@
       if (code == ERROR_SERVICE_EXISTS)
          printf(&quot;ERROR: Service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; already exist\n&quot;);
       else
- printf(&quot;ERROR: Cannot create service (%s)\n&quot;, GetSystemErrorText(code));
+ printf(&quot;ERROR: Cannot create service (%s)\n&quot;, GetSystemErrorText(code, errorText, 1024));
    }
    else
    {
@@ -184,11 +185,12 @@
 void RemoveService(void)
 {
    SC_HANDLE mgr, service;
+ TCHAR errorText[1024];
 
    mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (mgr == NULL)
    {
- printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError()));
+ printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -196,7 +198,7 @@
    if (service == NULL)
    {
       printf(&quot;ERROR: Cannot open service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
    }
    else
    {
@@ -204,7 +206,7 @@
          printf(&quot;NetXMS Core service deleted successfully\n&quot;);
       else
          printf(&quot;ERROR: Cannot remove service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
 
       CloseServiceHandle(service);
    }
@@ -273,13 +275,13 @@
 {
    SC_HANDLE mgr, service;
         QUERY_SERVICE_CONFIG *cfg;
- TCHAR *cmdLine;
+ TCHAR *cmdLine, errorText[1024];
         DWORD bytes, error;
 
    mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (mgr == NULL)
    {
- printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError()));
+ printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -307,7 +309,7 @@
                                         else
                                         {
                                                 printf(&quot;ERROR: Cannot update configuration for service &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
                                         }
                                         free(cmdLine);
                                 }
@@ -319,21 +321,21 @@
                         else
                         {
                                 printf(&quot;ERROR: Cannot query configuration for service &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
                         }
                         free(cfg);
                 }
                 else
                 {
                         printf(&quot;ERROR: Cannot query configuration for service &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(error));
+ GetSystemErrorText(error, errorText, 1024));
                 }
       CloseServiceHandle(service);
         }
         else
    {
       printf(&quot;ERROR: Cannot open service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
    }
 
    CloseServiceHandle(mgr);
@@ -347,11 +349,12 @@
 void StartCoreService(void)
 {
    SC_HANDLE mgr,service;
+ TCHAR errorText[1024];
 
    mgr = OpenSCManager(NULL,NULL,GENERIC_WRITE);
    if (mgr == NULL)
    {
- printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError()));
+ printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -359,7 +362,7 @@
    if (service == NULL)
    {
       printf(&quot;ERROR: Cannot open service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
    }
    else
    {
@@ -367,7 +370,7 @@
          printf(&quot;NetXMS Core service started successfully\n&quot;);
       else
          printf(&quot;ERROR: Cannot start service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
 
       CloseServiceHandle(service);
    }
@@ -383,11 +386,12 @@
 void StopCoreService(void)
 {
    SC_HANDLE mgr,service;
+ TCHAR errorText[1024];
 
    mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE);
    if (mgr == NULL)
    {
- printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError()));
+ printf(&quot;ERROR: Cannot connect to Service Manager (%s)\n&quot;, GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -395,7 +399,7 @@
    if (service == NULL)
    {
       printf(&quot;ERROR: Cannot open service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
    }
    else
    {
@@ -405,7 +409,7 @@
          printf(&quot;NetXMS Core service stopped successfully\n&quot;);
       else
          printf(&quot;ERROR: Cannot stop service named &#39;&quot; CORE_SERVICE_NAME &quot;&#39; (%s)\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
 
       CloseServiceHandle(service);
    }
@@ -422,12 +426,13 @@
 {
    HKEY hKey;
    DWORD dwTypes = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
+ TCHAR errorText[1024];
 
    if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_LOCAL_MACHINE,
          &quot;System\\CurrentControlSet\\Services\\EventLog\\System\\&quot; CORE_EVENT_SOURCE,
          0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &amp;hKey, NULL))
    {
- printf(&quot;Unable to create registry key: %s\n&quot;, GetSystemErrorText(GetLastError()));
+ printf(&quot;Unable to create registry key: %s\n&quot;, GetSystemErrorText(GetLastError(), errorText, 1024));
       return;
    }
 
@@ -445,6 +450,8 @@
 
 void RemoveEventSource(void)
 {
+ TCHAR errorText[1024];
+
    if (ERROR_SUCCESS == RegDeleteKey(HKEY_LOCAL_MACHINE,
          &quot;System\\CurrentControlSet\\Services\\EventLog\\System\\&quot; CORE_EVENT_SOURCE))
    {
@@ -453,7 +460,7 @@
    else
    {
       printf(&quot;Unable to uninstall event source \&quot;&quot; CORE_EVENT_SOURCE &quot;\&quot;: %s\n&quot;,
- GetSystemErrorText(GetLastError()));
+ GetSystemErrorText(GetLastError(), errorText, 1024));
    }
 }
 
Received on Thu Jun 19 2008 - 00:47:19 EEST

This archive was generated by hypermail 2.2.0 : Thu Jun 19 2008 - 00:43:25 EEST