diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2006-12-07 14:29:44 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2006-12-07 14:29:44 +0000 |
commit | 6f7473acfbd74e2d909ddb9759ed4f0770a6f6a0 (patch) | |
tree | ddb3e1fc497f1a9f053d94067166212bd1b966ac /gpspacket.c | |
parent | 7bb0b51be8a295bcf9f9400c9ce9a5e878ce0a00 (diff) | |
download | gpsd-6f7473acfbd74e2d909ddb9759ed4f0770a6f6a0.tar.gz |
This version works of gpspacket.c works and allows us to set a callback.
Diffstat (limited to 'gpspacket.c')
-rw-r--r-- | gpspacket.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/gpspacket.c b/gpspacket.c index 97c5a458..8dd4d857 100644 --- a/gpspacket.c +++ b/gpspacket.c @@ -15,7 +15,7 @@ static PyObject *report_callback = NULL; void gpsd_report(int errlevel UNUSED, const char *fmt, ... ) { char buf[BUFSIZ]; - PyObject *args, *result; + PyObject *args; va_list ap; if (!report_callback) /* no callback defined, exit early */ @@ -30,14 +30,12 @@ void gpsd_report(int errlevel UNUSED, const char *fmt, ... ) (void)vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - args = Py_BuildValue("(s)", buf); + args = Py_BuildValue("(is)", errlevel, buf); if (!args) return; - result = PyObject_Call(report_callback, args, NULL); + PyObject_Call(report_callback, args, NULL); Py_DECREF(args); - if (!result) - return; } static PyTypeObject Getter_Type; @@ -73,16 +71,15 @@ static PyObject * Getter_get(GetterObject *self, PyObject *args) { int fd; - ssize_t type; if (!PyArg_ParseTuple(args, "i;missing or invalid file descriptor argument to gpspacket.get", &fd)) return NULL; - type = packet_get(fd, &self->getter); + packet_get(fd, &self->getter); if (PyErr_Occurred()) return NULL; - return Py_BuildValue("(i, s)", type, self->getter.outbuffer); + return Py_BuildValue("(i, s)", self->getter.type, self->getter.outbuffer); } static PyObject * @@ -236,14 +233,6 @@ initgpspacket(void) /* Create the module and add the functions */ m = Py_InitModule3("gpspacket", gpspacket_methods, module_doc); - if (ErrorObject == NULL) { - ErrorObject = PyErr_NewException("gpspacket.error", NULL, NULL); - if (ErrorObject == NULL) - return; - } - Py_INCREF(ErrorObject); - PyModule_AddObject(m, "error", ErrorObject); - PyModule_AddIntConstant(m, "BAD_PACKET", BAD_PACKET); PyModule_AddIntConstant(m, "COMMENT_PACKET", COMMENT_PACKET); PyModule_AddIntConstant(m, "NMEA_PACKET", NMEA_PACKET); |