Ticket #6117: spammodule.c
File spammodule.c, 500 bytes (added by artur_spruce@…, 19 years ago) |
---|
Line | |
---|---|
1 | #include <Python.h> |
2 | |
3 | static PyObject * |
4 | spam_system(PyObject *self, PyObject *args) |
5 | { |
6 | const char *command; |
7 | int sts; |
8 | |
9 | if (!PyArg_ParseTuple(args, "s", &command)) |
10 | return NULL; |
11 | sts = system(command); |
12 | return Py_BuildValue("i", sts); |
13 | } |
14 | |
15 | static PyMethodDef SpamMethods[] = { |
16 | {"system", spam_system, METH_VARARGS, |
17 | "Execute a shell command."}, |
18 | {NULL, NULL, 0, NULL} /* Sentinel */ |
19 | }; |
20 | |
21 | PyMODINIT_FUNC |
22 | initspam(void) |
23 | { |
24 | Py_InitModule("spam", SpamMethods); |
25 | } |
26 |