spammify.c: Replace spam_doc with NULL
[cpython-extension.git] / spammify.c
1 #include <Python.h>
2 #include <stdlib.h>
3
4 static PyObject *
5 spam_system(PyObject *self, PyObject *args)
6 {
7         const char *command;
8         int sts;
9
10         if (!PyArg_ParseTuple(args, "s", &command))
11                 return NULL;
12         sts = system(command);
13         return PyLong_FromLong(sts);
14 }
15
16 static PyMethodDef SpamMethods[] = {
17         {"system",  spam_system, METH_VARARGS,
18          "Execute a shell command."},
19         {NULL, NULL, 0, NULL}        /* Sentinel */
20 };
21
22 static struct PyModuleDef spammodule = {
23         PyModuleDef_HEAD_INIT,
24         "spam",   /* name of module */
25         NULL,     /* module documentation, may be NULL */
26         0,        /* size of per-interpreter state of the module */
27         SpamMethods
28 };
29
30 PyMODINIT_FUNC
31 PyInit_spam(void)
32 {
33         return PyModule_Create(&spammodule);
34 }