Added SMS sender subagent
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 24 Aug 2007 07:48:03 +0000 (07:48 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 24 Aug 2007 07:48:03 +0000 (07:48 +0000)
.gitattributes
configure.ac
include/nms_agent.h
netxms.dsw
src/agent/subagents/Makefile.am
src/agent/subagents/sms/Makefile.am [new file with mode: 0644]
src/agent/subagents/sms/main.cpp [new file with mode: 0644]
src/agent/subagents/sms/sender.cpp [new file with mode: 0644]
src/agent/subagents/sms/sms.dsp [new file with mode: 0644]
src/agent/subagents/sms/sms.dsw [new file with mode: 0644]
src/agent/subagents/sms/sms.h [new file with mode: 0644]

index 7172123..79b1768 100644 (file)
@@ -396,6 +396,12 @@ src/agent/subagents/skeleton/Makefile.nw -text
 src/agent/subagents/skeleton/skeleton.cpp -text
 src/agent/subagents/skeleton/skeleton.dsp -text
 src/agent/subagents/skeleton/skeleton.dsw -text
+src/agent/subagents/sms/Makefile.am -text
+src/agent/subagents/sms/main.cpp -text
+src/agent/subagents/sms/sender.cpp -text
+src/agent/subagents/sms/sms.dsp -text
+src/agent/subagents/sms/sms.dsw -text
+src/agent/subagents/sms/sms.h -text
 src/agent/subagents/sunos/Makefile.am -text
 src/agent/subagents/sunos/cpu.cpp -text
 src/agent/subagents/sunos/disk.cpp -text
index 3b31d4d..ab7a9f7 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.264 2007-08-03 15:40:20 victor Exp $
+# $Id: configure.ac,v 1.265 2007-08-24 07:48:02 victor Exp $
 #
 # NetXMS - Network Management System
 # Configure script
@@ -1272,6 +1272,7 @@ AC_CONFIG_FILES([
        src/agent/subagents/portCheck/Makefile
        src/agent/subagents/logscan/Makefile
        src/agent/subagents/ping/Makefile
+       src/agent/subagents/sms/Makefile
        src/agent/subagents/ups/Makefile
        src/agent/subagents/ecs/Makefile
        src/agent/subagents/odbcquery/Makefile
index 124a70c..396b5d1 100644 (file)
@@ -88,6 +88,7 @@
 #define ERR_CONNECT_FAILED          ((DWORD)910)
 #define ERR_MAILFORMED_COMMAND      ((DWORD)911)
 #define ERR_SOCKET_ERROR            ((DWORD)912)
+#define ERR_BAD_ARGUMENTS           ((DWORD)913)
 
 
 //
index 8143009..070563e 100644 (file)
@@ -798,6 +798,21 @@ Package=<4>
 
 ###############################################################################
 
+Project: "sms"=.\src\agent\subagents\sms\sms.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name libnetxms
+    End Project Dependency
+}}}
+
+###############################################################################
+
 Project: "sqlite"=.\src\server\dbdrv\sqlite\sqlite.dsp - Package Owner=<4>
 
 Package=<5>
index 1299ebf..56057a2 100644 (file)
@@ -14,4 +14,4 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-SUBDIRS = skeleton winnt win9x winperf netware portCheck ping ups ecs ${SUBAGENT_DIRS} ${UNSTABLE_SUBAGENT_DIRS}
+SUBDIRS = skeleton winnt win9x winperf netware portCheck ping sms ups ecs ${SUBAGENT_DIRS} ${UNSTABLE_SUBAGENT_DIRS}
diff --git a/src/agent/subagents/sms/Makefile.am b/src/agent/subagents/sms/Makefile.am
new file mode 100644 (file)
index 0000000..728ab02
--- /dev/null
@@ -0,0 +1,13 @@
+INCLUDES=-I@top_srcdir@/include
+
+lib_LTLIBRARIES = libnsm_sms.la
+libnsm_sms_la_SOURCES = main.cpp sender.cpp
+libnsm_sms_la_LDFLAGS = ../../../libnetxms/libnetxms.la
+
+EXTRA_DIST = sms.h sms.dsw sms.dsp
+
+install-exec-hook:
+       if test "x`uname -s`" = "xAIX" ; then \
+               rm -f $(libdir)/libnsm_sms.so.0 ; \
+               $(AR) x $(libdir)/libnsm_sms.a $(libdir)/libnsm_sms.so.0 ; \
+       fi
diff --git a/src/agent/subagents/sms/main.cpp b/src/agent/subagents/sms/main.cpp
new file mode 100644 (file)
index 0000000..2e09501
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+** NetXMS SMS sender subagent
+** Copyright (C) 2007 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: main.cpp
+**
+**/
+
+#include "sms.h"
+
+
+//
+// Global variables
+//
+
+TCHAR g_szDeviceModel[256] = _T("<unknown>");
+
+
+//
+// Configuration file template
+//
+
+static TCHAR m_szDevice[256];
+static NX_CFG_TEMPLATE cfgTemplate[] =
+{
+       { _T("Device"), CT_STRING, 0, 0, 255, 0, m_szDevice },
+       { _T(""), CT_END_OF_LIST, 0, 0, 0, 0, NULL }
+};
+
+
+//
+// Handler for SMS.SerialConfig and SMS.DeviceModel
+//
+
+static LONG H_StringConst(TCHAR *pszParam, TCHAR *pArg, TCHAR *pValue)
+{
+       ret_string(pValue, pArg);
+       return SYSINFO_RC_SUCCESS;
+}
+
+
+//
+// Handler for SMS.Send action
+//
+
+static LONG H_SendSMS(TCHAR *pszAction, NETXMS_VALUES_LIST *pArgs, TCHAR *pData)
+{
+       if (pArgs->dwNumStrings < 2)
+               return ERR_BAD_ARGUMENTS;
+
+       return SendSMS(pArgs->ppStringList[0], pArgs->ppStringList[1]) ? ERR_SUCCESS : ERR_INTERNAL_ERROR;
+}
+
+
+//
+// Subagent initialization
+//
+
+static BOOL SubAgentInit(TCHAR *pszConfigFile)
+{
+       DWORD dwResult;
+
+       // Load configuration
+       dwResult = NxLoadConfig(pszConfigFile, _T("SMS"), cfgTemplate, FALSE);
+       if (dwResult == NXCFG_ERR_OK)
+       {
+               if (!InitSender(m_szDevice))
+                       return FALSE;
+       }
+
+       return dwResult == NXCFG_ERR_OK;
+}
+
+
+//
+// Called by master agent at unload
+//
+
+static void SubAgentShutdown(void)
+{
+       ShutdownSender();
+}
+
+
+//
+// Subagent information
+//
+
+static NETXMS_SUBAGENT_PARAM m_parameters[] =
+{
+       { _T("SMS.DeviceModel"), H_StringConst, g_szDeviceModel, DCI_DT_STRING, _T("Current serial port configuration") },
+       { _T("SMS.SerialConfig"), H_StringConst, m_szDevice, DCI_DT_STRING, _T("Current serial port configuration") }
+};
+static NETXMS_SUBAGENT_ACTION m_actions[] =
+{
+       { _T("SMS.Send"), H_SendSMS, NULL, _T("Send SMS") }
+};
+
+static NETXMS_SUBAGENT_INFO m_info =
+{
+       NETXMS_SUBAGENT_INFO_MAGIC,
+       _T("SMS"), _T(NETXMS_VERSION_STRING),
+       SubAgentInit, SubAgentShutdown, NULL,
+       sizeof(m_parameters) / sizeof(NETXMS_SUBAGENT_PARAM),
+       m_parameters,
+       0, NULL,
+       sizeof(m_actions) / sizeof(NETXMS_SUBAGENT_ACTION),
+       m_actions,
+};
+
+
+//
+// Entry point for NetXMS agent
+//
+
+DECLARE_SUBAGENT_ENTRY_POINT(SMS)
+{
+       *ppInfo = &m_info;
+       return TRUE;
+}
+
+
+//
+// DLL entry point
+//
+
+#ifdef _WIN32
+
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+       if (dwReason == DLL_PROCESS_ATTACH)
+               DisableThreadLibraryCalls(hInstance);
+       return TRUE;
+}
+
+#endif
diff --git a/src/agent/subagents/sms/sender.cpp b/src/agent/subagents/sms/sender.cpp
new file mode 100644 (file)
index 0000000..99dc5b7
--- /dev/null
@@ -0,0 +1,215 @@
+/* $Id: sender.cpp,v 1.1 2007-08-24 07:48:03 victor Exp $ */
+/*
+** NetXMS SMS sender subagent
+** Copyright (C) 2007 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: sender.cpp
+**
+**/
+
+#include "sms.h"
+
+
+//
+// Static data
+//
+
+static Serial m_serial;
+
+
+//
+// Initialize sender
+// pszInitArgs format: portname,speed,databits,parity,stopbits
+//
+
+BOOL InitSender(TCHAR *pszInitArgs)
+{
+       bool bRet = false;
+       char *portName;
+       
+       if (pszInitArgs == NULL || *pszInitArgs == 0)
+       {
+#ifdef _WIN32
+               portName = strdup(_T("COM1:"));
+#else
+               portName = strdup(_T("/dev/ttyS0"));
+#endif
+       }
+       else
+       {
+               portName = strdup(pszInitArgs);
+       }
+       
+       NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS Sender: initializing GSM modem at %s", pszInitArgs);
+       
+       char *p;
+       int portSpeed = 9600;
+       int dataBits = 8;
+       int parity = NOPARITY;
+       int stopBits = ONESTOPBIT;
+       
+       if ((p = strchr(portName, ',')) != NULL)
+       {
+               *p = 0; p++;
+               int tmp = atoi(p);
+               if (tmp != 0)
+               {
+                       portSpeed = tmp;
+                       
+                       if ((p = strchr(p, ',')) != NULL)
+                       {
+                               *p = 0; p++;
+                               tmp = atoi(p);
+                               if (tmp >= 5 && tmp <= 8)
+                               {
+                                       dataBits = tmp;
+                                       
+                                       // parity
+                                       if ((p = strchr(p, ',')) != NULL)
+                                       {
+                                               *p = 0; p++;
+                                               switch (tolower(*p))
+                                               {
+                                               case 'n': // none
+                                                       parity = NOPARITY;
+                                                       break;
+                                               case 'o': // odd
+                                                       parity = ODDPARITY;
+                                                       break;
+                                               case 'e': // even
+                                                       parity = EVENPARITY;
+                                                       break;
+                                               }
+                                               
+                                               // stop bits
+                                               if ((p = strchr(p, ',')) != NULL)
+                                               {
+                                                       *p = 0; p++;
+                                                       
+                                                       if (*p == '2')
+                                                       {
+                                                               stopBits = TWOSTOPBITS;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       switch (parity)
+       {
+       case ODDPARITY:
+               p = "ODD";
+               break;
+       case EVENPARITY:
+               p = "EVEN";
+               break;
+       default:
+               p = "NONE";
+               break;
+       }
+       NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS init: port={%s}, speed=%d, data=%d, parity=%s, stop=%d",
+                       portName, portSpeed, dataBits, p, stopBits == TWOSTOPBITS ? 2 : 1);
+       
+       bRet = m_serial.Open(pszInitArgs);
+       if (bRet)
+       {
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS Sender: port opened");
+               m_serial.SetTimeout(1000);
+               m_serial.Set(portSpeed, dataBits, parity, stopBits);
+               
+               // enter PIN: AT+CPIN="xxxx"
+               // register network: AT+CREG1
+               
+               char szTmp[128];
+               m_serial.Write("ATZ\r\n", 5); // init modem && read user prefs
+               m_serial.Read(szTmp, 128); // read OK
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS init: ATZ sent, got {%s}", szTmp);
+               m_serial.Write("ATE0\r\n", 6); // disable echo
+               m_serial.Read(szTmp, 128); // read OK
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS init: ATE0 sent, got {%s}", szTmp);
+               m_serial.Write("ATI3\r\n", 6); // read vendor id
+               m_serial.Read(szTmp, 128); // read version
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS init: ATI3 sent, got {%s}", szTmp);
+               
+               if (stricmp(szTmp, "ERROR") != 0)
+               {
+                       char *sptr, *eptr;
+                       
+                       for(sptr = szTmp; (*sptr != 0) && ((*sptr == '\r') || (*sptr == '\n') || (*sptr == ' ') || (*sptr == '\t')); sptr++);
+                       for(eptr = sptr; (*eptr != 0) && (*eptr != '\r') && (*eptr != '\n'); eptr++);
+                       *eptr = 0;
+                       nx_strncpy(g_szDeviceModel, sptr, 256);
+                       NxWriteAgentLog(EVENTLOG_INFORMATION_TYPE, _T("SMS Sender: GSM modem initialized (Device=\"%s\" Model=\"%s\")"), pszInitArgs, sptr);
+               }
+       }
+       else
+       {
+               NxWriteAgentLog(EVENTLOG_WARNING_TYPE, "SMS Sender: Unable to open serial port (%s)", pszInitArgs);
+       }
+       
+       if (portName != NULL)
+       {
+               free(portName);
+       }
+       
+       return bRet;
+}
+
+
+//
+// Send SMS
+//
+
+BOOL SendSMS(TCHAR *pszPhoneNumber, TCHAR *pszText)
+{
+       if (pszPhoneNumber != NULL && pszText != NULL)
+       {
+               char szTmp[128];
+               
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS send: to {%s}: {%s}", pszPhoneNumber, pszText);
+               
+               m_serial.Write("ATZ\r\n", 5); // init modem && read user prefs
+               m_serial.Read(szTmp, 128); // read OK
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS send: ATZ sent, got {%s}", szTmp);
+               m_serial.Write("ATE0\r\n", 5); // disable echo
+               m_serial.Read(szTmp, 128); // read OK
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS send: ATE0 sent, got {%s}", szTmp);
+               m_serial.Write("AT+CMGF=1\r\n", 11); // =1 - text message
+               m_serial.Read(szTmp, 128); // read OK
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS send: AT+CMGF=1 sent, got {%s}", szTmp);
+               snprintf(szTmp, sizeof(szTmp), "AT+CMGS=\"%s\"\r\n", pszPhoneNumber);
+               m_serial.Write(szTmp, strlen(szTmp)); // set number
+               snprintf(szTmp, sizeof(szTmp), "%s%c\r\n", pszText, 0x1A);
+               m_serial.Write(szTmp, strlen(szTmp)); // send text, end with ^Z
+               m_serial.Read(szTmp, 128); // read +CMGS:ref_num
+               NxWriteAgentLog(EVENTLOG_DEBUG_TYPE, "SMS send: AT+CMGS + message body sent, got {%s}", szTmp);
+       }
+       
+       return true;
+}
+
+
+//
+// Shutdown sender
+//
+
+void ShutdownSender(void)
+{
+       m_serial.Close();
+}
diff --git a/src/agent/subagents/sms/sms.dsp b/src/agent/subagents/sms/sms.dsp
new file mode 100644 (file)
index 0000000..390eb46
--- /dev/null
@@ -0,0 +1,217 @@
+# Microsoft Developer Studio Project File - Name="sms" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=sms - Win32 Debug AMD64
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "sms.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "sms.mak" CFG="sms - Win32 Debug AMD64"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "sms - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "sms - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "sms - Win32 Release AMD64" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "sms - Win32 Debug AMD64" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "sms - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib hid.lib setupapi.lib /nologo /dll /machine:I386 /out:"Release/sms.nsm" /libpath:"..\..\..\libnetxms\Release"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copy files
+PostBuild_Cmds=copy Release\sms.nsm C:\NetXMS\bin
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "sms - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib hid.lib setupapi.lib /nologo /dll /debug /machine:I386 /out:"Debug/sms.nsm" /pdbtype:sept /libpath:"..\..\..\libnetxms\Debug"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copy files
+PostBuild_Cmds=copy Debug\sms.nsm ..\..\..\..\bin
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "sms - Win32 Release AMD64"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "sms___Win32_Release_AMD64"
+# PROP BASE Intermediate_Dir "sms___Win32_Release_AMD64"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release64"
+# PROP Intermediate_Dir "Release64"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /O2 /I "..\..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /D "__64BIT__" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib hid.lib setupapi.lib /nologo /dll /machine:I386 /out:"Release/sms.nsm" /libpath:"..\..\..\libnetxms\Release"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib hid.lib setupapi.lib bufferoverflowU.lib /nologo /dll /machine:I386 /out:"Release64/sms.nsm" /libpath:"..\..\..\libnetxms\Release64" /machine:AMD64
+# SUBTRACT LINK32 /pdb:none
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copy files
+PostBuild_Cmds=copy Release64\sms.nsm C:\NetXMS\bin64
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "sms - Win32 Debug AMD64"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "sms___Win32_Debug_AMD64"
+# PROP BASE Intermediate_Dir "sms___Win32_Debug_AMD64"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug64"
+# PROP Intermediate_Dir "Debug64"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /ZI /Od /I "..\..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /Zi /Od /I "..\..\..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "sms_EXPORTS" /D "__64BIT__" /FD /GZ /Wp64 /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib hid.lib setupapi.lib /nologo /dll /debug /machine:I386 /out:"Debug/sms.nsm" /pdbtype:sept /libpath:"..\..\..\libnetxms\Debug"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libnetxms.lib ws2_32.lib hid.lib setupapi.lib bufferoverflowU.lib /nologo /dll /debug /machine:I386 /out:"Debug64/sms.nsm" /pdbtype:sept /libpath:"..\..\..\libnetxms\Debug64" /machine:AMD64
+# SUBTRACT LINK32 /pdb:none
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Desc=Copy files
+PostBuild_Cmds=copy Debug64\sms.nsm ..\..\..\..\bin64
+# End Special Build Tool
+
+!ENDIF 
+
+# Begin Target
+
+# Name "sms - Win32 Release"
+# Name "sms - Win32 Debug"
+# Name "sms - Win32 Release AMD64"
+# Name "sms - Win32 Debug AMD64"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\main.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\sender.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE="..\..\..\..\include\netxms-version.h"
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\include\nms_agent.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\include\nms_common.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\include\nms_threads.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\include\nms_util.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\sms.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/src/agent/subagents/sms/sms.dsw b/src/agent/subagents/sms/sms.dsw
new file mode 100644 (file)
index 0000000..8176455
--- /dev/null
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "sms"=.\sms.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/src/agent/subagents/sms/sms.h b/src/agent/subagents/sms/sms.h
new file mode 100644 (file)
index 0000000..20f3ca7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+** NetXMS UPS management subagent
+** Copyright (C) 2006 Victor Kirhenshtein
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: sms.h
+**
+**/
+
+#ifndef _sms_h_
+#define _sms_h_
+
+#include <nms_common.h>
+#include <nms_util.h>
+#include <nms_agent.h>
+
+
+//
+// Functions
+//
+
+BOOL InitSender(TCHAR *pszInitArgs);
+void ShutdownSender(void);
+BOOL SendSMS(TCHAR *pszPhoneNumber, TCHAR *pszText);
+
+
+//
+// Global variables
+//
+
+extern TCHAR g_szDeviceModel[];
+
+
+#endif