From 8a9ecd462b818ece811450f8912c44f50deaa733 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 19 Sep 2013 19:41:00 +0200 Subject: hacks to make the event log --- src/util/event.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/util/event.c') diff --git a/src/util/event.c b/src/util/event.c index ae5ca7b..e19fe28 100644 --- a/src/util/event.c +++ b/src/util/event.c @@ -22,12 +22,15 @@ #include #include +#include #include #include #include #include +#define STDIN_BUF_SIZE 1024 + static int incall_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux) { printf("EVENT: Incoming call type = %u\n", aux->u.call.type); @@ -288,3 +291,33 @@ int event_init(struct lgsm_handle *lh) return rc; } +int event_main(struct lgsm_handle *lgsmh) +{ + int rc; + char buf[STDIN_BUF_SIZE+1]; + fd_set readset; + int gsm_fd = lgsm_fd(lgsmh); + + FD_ZERO(&readset); + + while (1) { + FD_SET(gsm_fd, &readset); + + rc = select(gsm_fd+1, &readset, NULL, NULL, NULL); + if (rc <= 0) + break; + if (FD_ISSET(gsm_fd, &readset)) { + /* we've received something on the gsmd socket, pass it + * on to the library */ + rc = read(gsm_fd, buf, sizeof(buf)); + if (rc <= 0) { + printf("ERROR reading from gsm_fd\n"); + break; + } + rc = lgsm_handle_packet(lgsmh, buf, rc); + if (rc < 0) + printf("ERROR processing packet: %d(%s)\n", rc, strerror(-rc)); + } + } + return 0; +} -- cgit v1.2.3