Created
February 24, 2013 22:25
-
-
Save neuro-sys/5025991 to your computer and use it in GitHub Desktop.
tedious and fuckly error checking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char * py_call_module(char * name, struct irc_t * irc) | |
| { | |
| struct py_module_t * mod; | |
| PyObject * p_args; | |
| PyObject * p_val; | |
| char * ret; | |
| if (!(mod = g_hash_table_lookup(mod_hash_map, name))) | |
| return NULL; | |
| if (!(p_args = PyTuple_New(2))) | |
| return NULL; | |
| if (!(p_val = PyString_FromString(irc->from))) | |
| return NULL; | |
| if (PyTuple_SetItem(p_args, 0, p_val) != 0) | |
| return NULL; | |
| if (!(p_val = PyString_FromString(irc->request))) | |
| return NULL; | |
| if (PyTuple_SetItem(p_args, 1, p_val) != 0) | |
| return NULL; | |
| if (!(p_val = PyObject_CallObject(mod->pFunc, p_args))) | |
| return NULL; | |
| if(!(ret = PyString_AsString(p_val))) | |
| return NULL; | |
| return strdup(PyString_AsString(p_val)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment