aboutsummaryrefslogtreecommitdiff
path: root/lib/base/console.cpp
diff options
context:
space:
mode:
authorghost <andreas.monzner@multimedia-labs.de>2008-10-31 13:07:01 +0100
committerAndreas Oberritter <obi@saftware.de>2008-11-06 01:52:03 +0100
commit19ce1123c780a9475e2f158712da6e73fa543e9c (patch)
treeb87da56c335eb04f3450076becbcae2d1f981515 /lib/base/console.cpp
parentf69b4f8dbed8ff96260b951cf8cecd76fa85423b (diff)
downloadenigma2-19ce1123c780a9475e2f158712da6e73fa543e9c.tar.gz
enigma2-19ce1123c780a9475e2f158712da6e73fa543e9c.zip
add possibility to call eConsoleAppContainer execute with unlimited count of arguments
when its called with single argument, then /bin/sh is started else not
Diffstat (limited to 'lib/base/console.cpp')
-rw-r--r--lib/base/console.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/lib/base/console.cpp b/lib/base/console.cpp
index a12cb5e2..25318cc9 100644
--- a/lib/base/console.cpp
+++ b/lib/base/console.cpp
@@ -476,11 +476,37 @@ eConsolePy_running(eConsolePy* self)
static PyObject *
eConsolePy_execute(eConsolePy* self, PyObject *argt)
{
- const char *str;
- if (PyArg_ParseTuple(argt, "s", &str))
- return PyInt_FromLong(self->cont->execute(str));
- PyErr_SetString(PyExc_TypeError,
- "argument is not a string");
+ Py_ssize_t argc = PyTuple_Size(argt);
+ if (argc > 1)
+ {
+ const char *argv[argc + 1];
+ int argpos=0;
+ while(argpos < argc)
+ {
+ PyObject *arg = PyTuple_GET_ITEM(argt, argpos);
+ if (!PyString_Check(arg))
+ {
+ char err[255];
+ if (argpos)
+ snprintf(err, 255, "arg %d is not a string", argpos);
+ else
+ snprintf(err, 255, "cmd is not a string!");
+ PyErr_SetString(PyExc_TypeError, err);
+ return NULL;
+ }
+ argv[argpos++] = PyString_AsString(arg);
+ }
+ argv[argpos] = 0;
+ return PyInt_FromLong(self->cont->execute(argv[0], argv));
+ }
+ else
+ {
+ const char *str;
+ if (PyArg_ParseTuple(argt, "s", &str))
+ return PyInt_FromLong(self->cont->execute(str));
+ PyErr_SetString(PyExc_TypeError,
+ "cmd is not a string!");
+ }
return NULL;
}