hacks to make the event log
This commit is contained in:
parent
0b3c8902d9
commit
8a9ecd462b
|
@ -22,12 +22,15 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <common/linux_list.h>
|
||||
#include <libgsmd/libgsmd.h>
|
||||
#include <libgsmd/event.h>
|
||||
#include <libgsmd/sms.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
|
||||
extern int event_init(struct lgsm_handle *lh);
|
||||
extern int event_main(struct lgsm_handle *lh);
|
||||
|
|
|
@ -156,6 +156,9 @@ int main(int argc, char **argv)
|
|||
case MODE_SHELL:
|
||||
shell_main(lgsmh, shellwait);
|
||||
break;
|
||||
case MODE_EVENTLOG:
|
||||
event_main(lgsmh);
|
||||
break;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
|
Loading…
Reference in New Issue