/[projects]/smsdaemon/plugins/ShellExecPlugin.cpp
ViewVC logotype

Contents of /smsdaemon/plugins/ShellExecPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86 - (show annotations) (download)
Mon Jun 16 07:39:56 2008 UTC (15 years, 11 months ago) by torben
File size: 972 byte(s)
daemon.cpp: do not ignore child signals

util.(h|cpp): make a safe replacement for system(3) call
ShellExecPlugin.cpp: use this safer replacement


1 #include "ShellExecPlugin.h"
2 #include "GsmModem.h"
3
4 #include "util.h"
5
6 ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters)
7 : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ),
8 _exeCommand(exeCommand),
9 _allowParameters(allowParameters)
10 {
11 }
12
13 void ShellExecPlugin::Execute(IGsmModem& modem, SMS& sms)
14 {
15 std::string command = _exeCommand;
16
17 if (_allowParameters)
18 {
19 std::string parameters = GetSmsData(sms);
20
21 parameters = Util::str_replace(parameters, "||");
22 parameters = Util::str_replace(parameters, "&&");
23 parameters = Util::str_replace(parameters, ";");
24 parameters = Util::str_replace(parameters, "'");
25 parameters = Util::str_replace(parameters, "\"");
26
27 command += " ";
28 command += parameters;
29 }
30 int retval = Util::my_system( command.c_str() );
31
32 std::string message;
33 if (retval == -1)
34 message = "Error";
35 else
36 message = "OK";
37
38 modem.SendSms(sms.sender, message, false );
39 }

  ViewVC Help
Powered by ViewVC 1.1.20