Fixed Windows build errors
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 20 May 2016 14:30:01 +0000 (17:30 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 20 May 2016 14:30:01 +0000 (17:30 +0300)
src/agent/libnxagent/libnxagent.vcproj
src/agent/libnxappc/nxappc.c

index 3f8fe37..bbc0952 100644 (file)
                        />
                </Configuration>
                <Configuration
-                       Name="Release|Win32"
-                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-                       IntermediateDirectory="$(ConfigurationName)"
+                       Name="Debug|x64"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
                        ConfigurationType="2"
                        CharacterSet="1"
-                       WholeProgramOptimization="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
                        />
                        <Tool
                                Name="VCMIDLTool"
+                               TargetEnvironment="3"
                        />
                        <Tool
                                Name="VCCLCompilerTool"
+                               Optimization="0"
                                AdditionalIncludeDirectories="..\..\..\include"
-                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBNXAGENT_EXPORTS"
-                               RuntimeLibrary="2"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBNXAGENT_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
                                UsePrecompiledHeader="0"
                                WarningLevel="3"
                                Detect64BitPortabilityProblems="true"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               LinkIncremental="1"
+                               LinkIncremental="2"
                                GenerateDebugInformation="true"
                                SubSystem="2"
-                               OptimizeReferences="2"
-                               EnableCOMDATFolding="2"
-                               TargetMachine="1"
+                               TargetMachine="17"
                        />
                        <Tool
                                Name="VCALinkTool"
                        />
                </Configuration>
                <Configuration
-                       Name="Debug|x64"
-                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
                        ConfigurationType="2"
                        CharacterSet="1"
+                       WholeProgramOptimization="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
                        />
                        <Tool
                                Name="VCMIDLTool"
-                               TargetEnvironment="3"
                        />
                        <Tool
                                Name="VCCLCompilerTool"
-                               Optimization="0"
                                AdditionalIncludeDirectories="..\..\..\include"
-                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBNXAGENT_EXPORTS"
-                               MinimalRebuild="true"
-                               BasicRuntimeChecks="3"
-                               RuntimeLibrary="3"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBNXAGENT_EXPORTS"
+                               RuntimeLibrary="2"
                                UsePrecompiledHeader="0"
                                WarningLevel="3"
                                Detect64BitPortabilityProblems="true"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               LinkIncremental="2"
+                               LinkIncremental="1"
                                GenerateDebugInformation="true"
                                SubSystem="2"
-                               TargetMachine="17"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
                        />
                        <Tool
                                Name="VCALinkTool"
                                RelativePath=".\main.cpp"
                                >
                        </File>
+                       <File
+                               RelativePath=".\registry.cpp"
+                               >
+                       </File>
                        <File
                                RelativePath=".\tools.cpp"
                                >
index ea91a2c..f8742f5 100644 (file)
@@ -185,18 +185,33 @@ int LIBNXAPPC_EXPORTABLE nxappc_send_event(int code, const char *name, const cha
 int LIBNXAPPC_EXPORTABLE nxappc_send_data(void *data, int size)
 {
    char *msg;
+#ifdef _WIN32
+   int rc;
+   char buffer[4096];
+#endif
 
    if ((size < 0) || (size > 65532))
       return NXAPPC_FAIL;
 
    CHECK_CHANNEL;
 
+#ifdef _WIN32
+   msg = (size <= 4092) ? buffer : malloc(size + 4);
+#else
    msg = alloca(size + 4);
+#endif
    msg[0] = NXAPPC_CMD_SEND_DATA;
    msg[1] = 0; // reserved
    *((unsigned short *)&msg[2]) = (unsigned short)size;
    memcpy(&msg[4], data, size);
+#ifdef _WIN32
+   rc = (send_data(msg, size + 4) == size + 4) ? NXAPPC_SUCCESS : NXAPPC_FAIL;
+   if (msg != buffer)
+      free(msg);
+   return rc;
+#else
    return (send_data(msg, size + 4) == size + 4) ? NXAPPC_SUCCESS : NXAPPC_FAIL;
+#endif
 }
 
 /**