Files
CMake/Tests/FindPython/spam.c
Kitware Robot 0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00

42 lines
980 B
C

#define Py_LIMITED_API 3
#include <Python.h>
static PyObject* spam_system(PyObject* self, PyObject* args)
{
char const* command;
int sts;
if (!PyArg_ParseTuple(args, "s", &command))
return NULL;
sts = system(command);
/* return PyLong_FromLong(sts); */
return Py_BuildValue("i", sts);
}
static PyMethodDef SpamMethods[] = {
{ "system", spam_system, METH_VARARGS, "Execute a shell command." },
{ NULL, NULL, 0, NULL } /* Sentinel */
};
#if defined(PYTHON2)
PyMODINIT_FUNC initspam2(void)
{
(void)Py_InitModule("spam2", SpamMethods);
}
#endif
#if defined(PYTHON3)
static struct PyModuleDef spammodule = {
PyModuleDef_HEAD_INIT, "spam3", /* name of module */
NULL, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
SpamMethods
};
PyMODINIT_FUNC PyInit_spam3(void)
{
return PyModule_Create(&spammodule);
}
#endif