Tuxedo related code refactoring - common Tuxedo helpers moved to separate library
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 8 Jul 2016 18:30:13 +0000 (21:30 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 8 Jul 2016 18:30:13 +0000 (21:30 +0300)
14 files changed:
configure.ac
include/Makefile.am
include/nxtux.h [new file with mode: 0644]
src/agent/Makefile.am
src/agent/libnxtux/.cproject [new file with mode: 0644]
src/agent/libnxtux/.project [copied from src/agent/subagents/tuxedo/.project with 91% similarity]
src/agent/libnxtux/.settings/language.settings.xml [new file with mode: 0644]
src/agent/libnxtux/Makefile.am [new file with mode: 0644]
src/agent/libnxtux/nxtux.cpp [new file with mode: 0644]
src/agent/subagents/tuxedo/.project
src/agent/subagents/tuxedo/Makefile.am
src/agent/subagents/tuxedo/main.cpp
src/agent/subagents/tuxedo/tuxedo_subagent.h
src/tools/nxdevcfg/nxdevcfg.cpp

index eb28fea..bd852c3 100644 (file)
@@ -65,6 +65,7 @@ STATIC_SUBAGENT_LIST=""
 PROPOSED_STATIC_SUBAGENTS="default"
 SUBAGENT_DIRS=""
 SUBAGENT_LIBS=""
+AGENT_DIRS=""
 SERVER_LIBS=""
 SERVER_TOOLS=""
 SERVER_INCLUDE=""
@@ -99,6 +100,7 @@ ZEROMQ_LDFLAGS=""
 LDAP_SUPPORT="yes"
 DISABLE_READLINE="no"
 TUXEDO_LIBS=""
+TUXEDO_TPINIT=""
 MONGODB_LIBS=""
 DISABLE_IPV6="no"
 IPV6_SUPPORT="no"
@@ -560,6 +562,7 @@ AC_ARG_WITH(dist,
        DB_DRIVERS=" mysql pgsql odbc mssql sqlite oracle db2 informix"
        MODULES="appagent jansson libexpat libstrophe libtre zlib libnetxms install sqlite snmp libnxsl libnxmb libnxlp libnxcc db server smsdrv agent libnxmap client nxscript nxcproxy nxlptest tools"
        SUBAGENT_DIRS="linux ds18x20 freebsd openbsd minix netbsd sunos aix ipso hpux odbcquery informix oracle lmsensors darwin rpi java ubntlw netsvc db2 tuxedo mongodb"
+       AGENT_DIRS="libnxtux"
        SMSDRV_DIRS="kannel nxagent slack text2reach websms"
    HDLINK_DIRS="jira"
    PDSDRV_DIRS="rrdtool"
@@ -836,6 +839,7 @@ fi
 
 check_substr "$COMPONENTS" "tuxedo"
 if test $? = 0; then
+       AGENT_DIRS="$AGENT_DIRS libnxtux"
        SUBAGENT_DIRS="$SUBAGENT_DIRS tuxedo"
 fi
 
@@ -2839,7 +2843,7 @@ if test $? = 0; then
 
        if test "x$PLATFORM" = "xAIX"; then
                if test -e $TUXEDO_BASE/lib/tpinit.o; then
-                       TUXEDO_LIBS="$TUXEDO_BASE/lib/tpinit.o $TUXEDO_LIBS"
+                       TUXEDO_TPINIT="$TUXEDO_BASE/lib/tpinit.o"
                fi
        fi
 fi
@@ -2980,6 +2984,7 @@ AM_CONDITIONAL([ZEROMQ_SUPPORT], [test "x$ZEROMQ_SUPPORT" = "xyes"])
 
 AS_IF([test "x$with_dist" = "xyes"],
 [
+  AGENT_DIRS=`echo $AGENT_DIRS|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
   SUBAGENT_DIRS=`echo $SUBAGENT_DIRS|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
   MODULES=`echo $MODULES|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
   SMSDRV_DIRS=`echo $SMSDRV_DIRS|perl -nae 'my %seen; my @out; for (@F) {push(@out, $_) unless $seen{$_}++; }; print join(" ", @out)'`
@@ -2992,6 +2997,7 @@ AS_IF([test "x$with_dist" = "xyes"],
 
 AC_SUBST(DB_DRIVERS)
 AC_SUBST(MODULES)
+AC_SUBST(AGENT_DIRS)
 AC_SUBST(SUBAGENT_DIRS)
 AC_SUBST(SERVER_INCLUDE)
 AC_SUBST(SERVER_LIBS)
@@ -3030,6 +3036,7 @@ AC_SUBST(SHLIB_SUFFIX)
 AC_SUBST(TUXEDO_CPPFLAGS)
 AC_SUBST(TUXEDO_LDFLAGS)
 AC_SUBST(TUXEDO_LIBS)
+AC_SUBST(TUXEDO_TPINIT)
 AC_SUBST(MONGODB_CPPFLAGS)
 AC_SUBST(MONGODB_LDFLAGS)
 AC_SUBST(MONGODB_LIBS)
@@ -3105,6 +3112,7 @@ AC_CONFIG_FILES([
        src/agent/libnxagent/Makefile
        src/agent/libnxappc/Makefile
        src/agent/libnxsd/Makefile
+       src/agent/libnxtux/Makefile
        src/agent/subagents/Makefile
        src/agent/subagents/aix/Makefile
        src/agent/subagents/darwin/Makefile
@@ -3347,6 +3355,7 @@ else
 fi
 if test "x${BUILD_AGENT}" = "xyes"; then
        echo "Build Agent             : YES"
+       echo "Agent extra components  : ${AGENT_DIRS}"
        echo "Subagents list          : ${SUBAGENT_DIRS}"
 else
        echo "Build Agent             : NO"
@@ -3503,3 +3512,6 @@ echo "const TCHAR *g_cxx = _T(\"${CXX}\");" >> $FLAGS_CPP
 echo "const TCHAR *g_ld = _T(\"${LD}\");" >> $FLAGS_CPP
 echo "const TCHAR *g_perl = _T(\"${PERL}\");" >> $FLAGS_CPP
 echo "const TCHAR *g_serverLibs = _T(\"${SERVER_LIBS}\");" >> $FLAGS_CPP
+echo "const TCHAR *g_tuxedoCppFlags = _T(\"${TUXEDO_CPPFLAGS}\");" >> $FLAGS_CPP
+echo "const TCHAR *g_tuxedoLdFlags = _T(\"${TUXEDO_LDFLAGS}\");" >> $FLAGS_CPP
+echo "const TCHAR *g_tuxedoLibs = _T(\"${TUXEDO_LIBS}\");" >> $FLAGS_CPP
index 5573adb..89bdd02 100644 (file)
@@ -48,6 +48,7 @@ include_HEADERS = \
        nxsnmp.h \
        nxstat.h \
        nxtools.h \
+       nxtux.h \
        rwlock.h \
        strophe.h \
        unicode.h \
diff --git a/include/nxtux.h b/include/nxtux.h
new file mode 100644 (file)
index 0000000..44d9129
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+** NetXMS - Network Management System
+** Copyright (C) 2003-2016 Raden Solutions
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 3 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 Lesser General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: nxtux.h
+**
+**/
+
+#ifndef _nxtux_h_
+#define _nxtux_h_
+
+#ifdef _WIN32
+#ifdef LIBNXTUX_EXPORTS
+#define LIBNXTUX_EXPORTABLE __declspec(dllexport)
+#else
+#define LIBNXTUX_EXPORTABLE __declspec(dllimport)
+#endif
+#else    /* _WIN32 */
+#define LIBNXTUX_EXPORTABLE
+#endif
+
+#include <nms_common.h>
+#include <nms_util.h>
+
+#undef getopt
+#include <atmi.h>
+#include <fml32.h>
+
+bool LIBNXTUX_EXPORTABLE TuxedoConnect();
+void LIBNXTUX_EXPORTABLE TuxedoDisconnect();
+
+bool LIBNXTUX_EXPORTABLE CFgetString(FBFR32 *fb, FLDID32 fieldid, FLDOCC32 oc, char *buf, size_t size);
+
+#endif   /* _nms_agent_h_ */
index 5b550a2..9f8195a 100644 (file)
@@ -8,4 +8,4 @@
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-SUBDIRS = libnxagent libnxappc libnxsd subagents core install tools
+SUBDIRS = libnxagent libnxappc libnxsd @AGENT_DIRS@ subagents core install tools
diff --git a/src/agent/libnxtux/.cproject b/src/agent/libnxtux/.cproject
new file mode 100644 (file)
index 0000000..43afdae
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+       <storageModule moduleId="org.eclipse.cdt.core.settings">
+               <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1127317690">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1127317690" moduleId="org.eclipse.cdt.core.settings" name="Default">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.base.1127317690" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+                                       <folderInfo id="cdt.managedbuild.toolchain.gnu.base.1127317690.1419686813" name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.gnu.base.1205551883" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1732913028" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
+                                                       <builder id="cdt.managedbuild.target.gnu.builder.base.1830542668" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.archiver.base.69990345" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1291574951" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+                                                               <option id="gnu.cpp.compiler.option.include.paths.236280105" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${TUXEDO_INCLUDE_DIR}&quot;"/>
+                                                               </option>
+                                                               <option id="gnu.cpp.compiler.option.preprocessor.def.6856901" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+                                                                       <listOptionValue builtIn="false" value="_THREAD_SAFE"/>
+                                                                       <listOptionValue builtIn="false" value="TRE_WCHAR=1"/>
+                                                                       <listOptionValue builtIn="false" value="UNICODE"/>
+                                                                       <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.292701683" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.722788587" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+                                                               <option id="gnu.c.compiler.option.include.paths.685344555" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${TUXEDO_INCLUDE_DIR}&quot;"/>
+                                                               </option>
+                                                               <option id="gnu.c.compiler.option.preprocessor.def.symbols.1365032448" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
+                                                                       <listOptionValue builtIn="false" value="_THREAD_SAFE"/>
+                                                                       <listOptionValue builtIn="false" value="TRE_WCHAR=1"/>
+                                                                       <listOptionValue builtIn="false" value="UNICODE"/>
+                                                                       <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1689255940" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1929161308" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.327620129" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2046635747" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.assembler.base.31850486" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+                                                               <option id="gnu.both.asm.option.include.paths.2040122570" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${NETXMS_BASE}/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${TUXEDO_INCLUDE_DIR}&quot;"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.assembler.input.291881065" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+       </storageModule>
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+               <project id="libnxtux.null.216904219" name="libnxtux"/>
+       </storageModule>
+       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1127317690;cdt.managedbuild.toolchain.gnu.base.1127317690.1419686813;cdt.managedbuild.tool.gnu.c.compiler.base.722788587;cdt.managedbuild.tool.gnu.c.compiler.input.1689255940">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               </scannerConfigBuildInfo>
+               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1127317690;cdt.managedbuild.toolchain.gnu.base.1127317690.1419686813;cdt.managedbuild.tool.gnu.cpp.compiler.base.1291574951;cdt.managedbuild.tool.gnu.cpp.compiler.input.292701683">
+                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+               </scannerConfigBuildInfo>
+       </storageModule>
+</cproject>
similarity index 91%
copy from src/agent/subagents/tuxedo/.project
copy to src/agent/libnxtux/.project
index 0b576e2..1777901 100644 (file)
@@ -1,10 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>tuxedo</name>
+       <name>libnxtux</name>
        <comment></comment>
        <projects>
                <project>libnetxms</project>
-               <project>libnxagent</project>
        </projects>
        <buildSpec>
                <buildCommand>
@@ -28,7 +27,7 @@
        </natures>
        <filteredResources>
                <filter>
-                       <id>1467963858975</id>
+                       <id>1467975328355</id>
                        <name></name>
                        <type>6</type>
                        <matcher>
@@ -37,7 +36,7 @@
                        </matcher>
                </filter>
                <filter>
-                       <id>1467963858983</id>
+                       <id>1467975328361</id>
                        <name></name>
                        <type>6</type>
                        <matcher>
@@ -46,7 +45,7 @@
                        </matcher>
                </filter>
                <filter>
-                       <id>1467963858989</id>
+                       <id>1467975328367</id>
                        <name></name>
                        <type>6</type>
                        <matcher>
diff --git a/src/agent/libnxtux/.settings/language.settings.xml b/src/agent/libnxtux/.settings/language.settings.xml
new file mode 100644 (file)
index 0000000..0cf696a
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project>
+       <configuration id="cdt.managedbuild.toolchain.gnu.base.1127317690" name="Default">
+               <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+                       <provider class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" name="CDT User Setting Entries" prefer-non-shared="true"/>
+                       <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
+                       <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
+                       <provider-reference id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" ref="shared-provider"/>
+                       <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+               </extension>
+       </configuration>
+</project>
diff --git a/src/agent/libnxtux/Makefile.am b/src/agent/libnxtux/Makefile.am
new file mode 100644 (file)
index 0000000..71ea48f
--- /dev/null
@@ -0,0 +1,10 @@
+SOURCES = nxtux.cpp
+
+lib_LTLIBRARIES = libnxtux.la
+
+libnxtux_la_SOURCES = $(SOURCES)
+libnxtux_la_CPPFLAGS=-I@top_srcdir@/include @TUXEDO_CPPFLAGS@
+libnxtux_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION) @TUXEDO_LDFLAGS@
+libnxtux_la_LIBADD = ../../libnetxms/libnetxms.la -ltux -lfml32 @TUXEDO_TPINIT@ @TUXEDO_LIBS@
+
+EXTRA_DIST = libnxtux.vcproj
diff --git a/src/agent/libnxtux/nxtux.cpp b/src/agent/libnxtux/nxtux.cpp
new file mode 100644 (file)
index 0000000..c40f003
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+** NetXMS Tuxedo helper library
+** Copyright (C) 2014-2016 Raden Solutions
+**
+** 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: nxtux.cpp
+**
+**/
+
+#include <nxtux.h>
+
+/**
+ * Connect count
+ */
+static int s_connectCount = 0;
+static MUTEX s_connectLock = MutexCreate();
+
+/**
+ * Connect to Tuxedo app
+ */
+bool LIBNXTUX_EXPORTABLE TuxedoConnect()
+{
+   bool success = true;
+   MutexLock(s_connectLock);
+   if (s_connectCount == 0)
+   {
+      if (tpinit(NULL) != -1)
+      {
+         s_connectCount++;
+      }
+      else
+      {
+         nxlog_debug(3, _T("tpinit() call failed (%hs)"), tpstrerrordetail(tperrno, 0));
+         success = false;
+      }
+   }
+   else
+   {
+      s_connectCount++;
+   }
+   MutexUnlock(s_connectLock);
+   return success;
+}
+
+/**
+ * Disconnect from Tuxedo app
+ */
+void LIBNXTUX_EXPORTABLE TuxedoDisconnect()
+{
+   MutexLock(s_connectLock);
+   if (s_connectCount > 0)
+   {
+      s_connectCount--;
+      if (s_connectCount == 0)
+         tpterm();
+   }
+   MutexUnlock(s_connectLock);
+}
+
+/**
+ * Helper function to get string field
+ */
+bool LIBNXTUX_EXPORTABLE CFgetString(FBFR32 *fb, FLDID32 fieldid, FLDOCC32 oc, char *buf, size_t size)
+{
+   FLDLEN32 len = (FLDLEN32)size;
+   if (CFget32(fb, fieldid, oc, buf, &len, FLD_STRING) == -1)
+   {
+      buf[0] = 0;
+      return false;
+   }
+   return true;
+}
+
+#ifdef _WIN32
+
+/**
+ * DLL entry point
+ */
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+       if (dwReason == DLL_PROCESS_ATTACH)
+               DisableThreadLibraryCalls(hInstance);
+       return TRUE;
+}
+
+#endif
index 0b576e2..f539914 100644 (file)
@@ -5,6 +5,7 @@
        <projects>
                <project>libnetxms</project>
                <project>libnxagent</project>
+               <project>libnxtux</project>
        </projects>
        <buildSpec>
                <buildCommand>
index e2fedc4..6eb7a63 100644 (file)
@@ -4,7 +4,7 @@ pkglib_LTLIBRARIES = tuxedo.la
 tuxedo_la_SOURCES = clients.cpp domain.cpp machines.cpp main.cpp queues.cpp servers.cpp services.cpp
 tuxedo_la_CPPFLAGS=-I@top_srcdir@/include @TUXEDO_CPPFLAGS@
 tuxedo_la_LDFLAGS = -module -avoid-version -export-symbols ../subagent.sym @TUXEDO_LDFLAGS@
-tuxedo_la_LIBADD = ../../libnxagent/libnxagent.la ../../../libnetxms/libnetxms.la -ltux -lfml32 @TUXEDO_LIBS@
+tuxedo_la_LIBADD = ../../libnxagent/libnxagent.la ../../libnxtux/libnxtux.la ../../../libnetxms/libnetxms.la -ltux -lfml32 @TUXEDO_LIBS@
 
 EXTRA_DIST = tuxedo.vcproj tuxedo_subagent.h
 
index e1b33e6..f5cf743 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** NetXMS Tuxedo subagent
-** Copyright (C) 2014 Raden Solutions
+** Copyright (C) 2014-2016 Raden Solutions
 **
 ** 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
@@ -46,68 +46,6 @@ LONG H_ServicesList(const TCHAR *param, const TCHAR *arg, StringList *value, Abs
 LONG H_ServicesTable(const TCHAR *param, const TCHAR *arg, Table *value, AbstractCommSession *session);
 
 /**
- * Connect count
- */
-static int s_connectCount = 0;
-static MUTEX s_connectLock = MutexCreate();
-
-/**
- * Connect to Tuxedo app
- */
-bool TuxedoConnect()
-{
-   bool success = true;
-   MutexLock(s_connectLock);
-   if (s_connectCount == 0)
-   {
-      if (tpinit(NULL) != -1)
-      {
-         s_connectCount++;
-      }
-      else
-      {
-         AgentWriteDebugLog(3, _T("Tuxedo: tpinit() call failed (%hs)"), tpstrerrordetail(tperrno, 0));
-         success = false;
-      }
-   }
-   else
-   {
-      s_connectCount++;
-   }
-   MutexUnlock(s_connectLock);
-   return success;
-}
-
-/**
- * Disconnect from Tuxedo app
- */
-void TuxedoDisconnect()
-{
-   MutexLock(s_connectLock);
-   if (s_connectCount > 0)
-   {
-      s_connectCount--;
-      if (s_connectCount == 0)
-         tpterm();
-   }
-   MutexUnlock(s_connectLock);
-}
-
-/**
- * Helper function to get string field
- */
-bool CFgetString(FBFR32 *fb, FLDID32 fieldid, FLDOCC32 oc, char *buf, size_t size)
-{
-   FLDLEN32 len = (FLDLEN32)size;
-   if (CFget32(fb, fieldid, oc, buf, &len, FLD_STRING) == -1)
-   {
-      buf[0] = 0;
-      return false;
-   }
-   return true;
-}
-
-/**
  * Subagent initialization
  */
 static BOOL SubAgentInit(Config *config)
@@ -127,7 +65,6 @@ static BOOL SubAgentInit(Config *config)
  */
 static void SubAgentShutdown()
 {
-   tpterm();
 }
 
 /**
index 0b170ab..b06d33c 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** NetXMS Tuxedo subagent
-** Copyright (C) 2014 Raden Solutions
+** Copyright (C) 2014-2016 Raden Solutions
 **
 ** 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
 #include <nms_common.h>
 #include <nms_util.h>
 #include <nms_agent.h>
-
-#undef getopt
-#include <atmi.h>
-#include <fml32.h> 
+#include <nxtux.h>
 #include <tpadm.h>
 
-bool TuxedoConnect();
-void TuxedoDisconnect();
-bool CFgetString(FBFR32 *fb, FLDID32 fieldid, FLDOCC32 oc, char *buf, size_t size);
-
 #endif
index 50d3287..fab8f8b 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
-** Server startup module
-** Copyright (C) 2003-2013 NetXMS Team
+** Development configuration helper
+** Copyright (C) 2003-2016 Raden Solutions
 **
 ** 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
@@ -27,7 +27,7 @@
 #include <getopt.h>
 #endif
 
-#define VALID_OPTIONS "bcCdDilLoOpPSuX"
+#define VALID_OPTIONS "bcCdDilLoOpPStTuUX"
 
 /**
  * Externals
@@ -42,6 +42,9 @@ extern const TCHAR *g_cxx;
 extern const TCHAR *g_ld;
 extern const TCHAR *g_perl;
 extern const TCHAR *g_serverLibs;
+extern const TCHAR *g_tuxedoCppFlags;
+extern const TCHAR *g_tuxedoLdFlags;
+extern const TCHAR *g_tuxedoLibs;
 
 /**
  * Show help
@@ -50,21 +53,24 @@ static void ShowHelp()
 {
        printf("Available options:\n");
 #if HAVE_DECL_GETOPT_LONG
-       printf("   -b, --bindir       Binary directory\n"
-              "   -o, --cc           C compiler\n"
-              "   -c, --cflags       C compiler flags\n"
-              "   -C, --cppflags     C/C++ compiler flags\n"
-              "   -u, --curl-libs    Linker flags for using cURL\n"
-              "   -O, --cxx          C++ compiler\n"
-              "   -X, --cxxflags     C++ compiler flags\n"
-              "   -d, --datadir      Data directory\n"
-              "   -D, --ld           Linker\n"
-              "   -l, --ldflags      Linker flags (all except -l)\n"
-              "   -L, --libdir       Library directory\n"
-              "   -i, --libs         Linker flags (only -l)\n"
-              "   -p, --perl         Perl interpreter\n"
-              "   -P, --prefix       Installation prefix\n"
-              "   -S, --server-libs  Linker flags for server binaries (only -l)\n"
+       printf("   -b, --bindir          Binary directory\n"
+              "   -o, --cc              C compiler\n"
+              "   -c, --cflags          C compiler flags\n"
+              "   -C, --cppflags        C/C++ compiler flags\n"
+              "   -u, --curl-libs       Linker flags for using cURL\n"
+              "   -O, --cxx             C++ compiler\n"
+              "   -X, --cxxflags        C++ compiler flags\n"
+              "   -d, --datadir         Data directory\n"
+              "   -D, --ld              Linker\n"
+              "   -l, --ldflags         Linker flags (all except -l)\n"
+              "   -L, --libdir          Library directory\n"
+              "   -i, --libs            Linker flags (only -l)\n"
+              "   -p, --perl            Perl interpreter\n"
+              "   -P, --prefix          Installation prefix\n"
+              "   -S, --server-libs     Linker flags for server binaries (only -l)\n"
+          "   -t, --tuxedo-cppflags Tuxedo related compiler flags\n"
+          "   -T, --tuxedo-ldflags  Tuxedo related linker flags (all except -l)\n"
+          "   -U, --tuxedo-libs     Tuxedo related linker flags (only -l)\n"
              );
 #else
        printf("   -b  Binary directory\n"
@@ -80,7 +86,10 @@ static void ShowHelp()
               "   -p  Perl interpreter\n"
               "   -P  Installation prefix\n"
               "   -S  Linker flags for server binaries (only -l)\n"
+          "   -t  Tuxedo related compiler flags\n"
+          "   -T  Tuxedo related linker flags (all except -l)\n"
               "   -u  Linker flags for using cURL\n"
+          "   -U  Tuxedo related linker flags (only -l)\n"
               "   -X  C++ compiler flags\n"
              );
 #endif
@@ -124,6 +133,9 @@ int main(int argc, char *argv[])
                { (char *)"perl", 0, NULL, 'p' },
                { (char *)"prefix", 0, NULL, 'P' },
                { (char *)"server-libs", 0, NULL, 'S' },
+               { (char *)"tuxedo-cppflags", 0, NULL, 't' },
+               { (char *)"tuxedo-ldflags", 0, NULL, 'T' },
+               { (char *)"tuxedo-libs", 0, NULL, 'U' },
                { NULL, 0, 0, 0 }
        };
 #endif
@@ -184,6 +196,12 @@ int main(int argc, char *argv[])
                        case 'S':
                                _tprintf(_T("%s\n"), g_serverLibs);
                                return 0;
+                       case 't':
+                               _tprintf(_T("%s\n"), g_tuxedoCppFlags);
+                               return 0;
+                       case 'T':
+                               _tprintf(_T("%s\n"), g_tuxedoLdFlags);
+                               return 0;
          case 'u':
 #if HAVE_LIBCURL
                                _tprintf(_T("-lcurl\n"));
@@ -191,6 +209,9 @@ int main(int argc, char *argv[])
                                _tprintf(_T("\n"));
 #endif
             return 0;
+                       case 'U':
+                               _tprintf(_T("%s\n"), g_tuxedoLibs);
+                               return 0;
          case 'X':
             PrintFlags(g_cxxFlags);
             return 0;