forked from smilejay/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjaymodule.c
More file actions
38 lines (31 loc) · 825 Bytes
/
jaymodule.c
File metadata and controls
38 lines (31 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <Python.h>
static PyObject * jay_hello(PyObject *self, PyObject *args) {
const char *person;
int sts;
if (!PyArg_ParseTuple(args, "s", &person))
return NULL;
printf("Hello, %s. I'm Jay.\n", person );
return Py_None;
/*
sts = printf("Hello, %s. I'm Jay.\n", person );
return Py_BuildValue("i", sts);
*/
}
static PyMethodDef JayMethods[] = {
{"hello", jay_hello, METH_VARARGS,
"Say hello to a person from Jay."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyMODINIT_FUNC initjay(void) {
PyImport_AddModule("jay");
(void) Py_InitModule("jay", JayMethods);
}
int main(int argc, char *argv[]) {
/* Pass argv[0] to the Python interpreter */
Py_SetProgramName(argv[0]);
/* Initialize the Python interpreter. Required. */
Py_Initialize();
/* Add a static module */
initjay();
Py_Exit(0);
}