Changeset 93302ef for protocols/python/src
- Timestamp:
- 2013-03-18T21:36:08Z (12 years ago)
- Children:
- 26f3b5f
- Parents:
- e38c6d8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/python/src/bpython.c
re38c6d8 r93302ef 27 27 #include "bytesobject.h" 28 28 29 static PyObject * bpython_register_protocol(PyObject *self, PyObject *args) 30 { 31 const char *command; 32 int sts; 33 34 if (!PyArg_ParseTuple(args, "s", &command)) 35 return NULL; 36 sts = system(command); 37 return Py_BuildValue("i", sts); 38 } 39 40 static PyMethodDef BpythonMethods[] = { 41 {"register_protocol", bpython_register_protocol, METH_VARARGS, 42 "Register a protocol."}, 43 {NULL, NULL, 0, NULL} /* Sentinel */ 44 }; 45 46 PyMODINIT_FUNC initbpython(void) 47 { 48 PyImport_AddModule("bpython"); 49 Py_InitModule("bpython", BpythonMethods); 50 } 51 52 29 53 static void load_pyfile(char * path, PyObject * main_dict) { 30 54 FILE * pyfile; … … 35 59 printf("Loading python file %s\n", path); 36 60 pyfile = fopen(path, "r"); 61 37 62 /* Copy main dict to make sure that separate plugins 38 63 run in separate environments */ 39 64 PyObject * main_dict_copy = PyDict_Copy(main_dict); 65 66 /* Run the python file */ 40 67 PyRun_File(pyfile, path, Py_file_input, main_dict_copy, main_dict_copy); 41 68 … … 81 108 PyRun_SimpleString("print 'Python initialised!'\n"); 82 109 110 /* Add our static module */ 111 initbpython(); 112 83 113 /* Get a reference to the main module. */ 84 114 PyObject* main_module = PyImport_AddModule("__main__");
Note: See TracChangeset
for help on using the changeset viewer.