aura  0.1
 All Data Structures Functions Variables Modules Pages
dummy-unhandled-evt.c
1 #include <aura/aura.h>
2 
3 #define ARG 100500
4 #define ARG2 100502
5 
6 void calldonecb(struct aura_node *dev, int status, struct aura_buffer *retbuf, void *arg)
7 {
8  printf("Call done with result %d arg %lld!\n", status, (long long unsigned int) arg);
9  if (arg != (void *) ARG)
10  exit(1);
11  aura_hexdump("Out buffer", retbuf->data, retbuf->size);
12 }
13 
14 static int numevt=0;
15 void unhandled_cb(struct aura_node *dev,
16  struct aura_buffer *retbuf,
17  void *arg)
18 {
19  const struct aura_object *o = aura_get_current_object(dev);
20  numevt++;
21  printf("Unhandled event name %s %d with arg %lld!\n",
22  o->name, numevt, (long long unsigned int) arg);
23  if (arg != (void *) ARG2)
24  exit(1);
25 
26  aura_hexdump("Out buffer", retbuf->data, retbuf->size);
27  if (numevt==4) {
28  printf("Breaking the loop\n");
30  }
31 }
32 
33 int main() {
34  slog_init(NULL, 18);
35 
36  int ret;
37  struct aura_node *n = aura_open("dummy", NULL);
38  aura_wait_status(n, AURA_STATUS_ONLINE);
39 
40  ret = aura_start_call(n, "echo_u16", calldonecb, (void *) ARG, 0x0102);
41  printf("call started with ret %d\n", ret);
42  if (ret !=0)
43  return ret;
44 
45  aura_unhandled_evt_cb(n, unhandled_cb, (void *) ARG2);
46  printf("event handler set with ret %d\n", ret);
48  printf("Closing teh shop...");
49  aura_close(n);
50 
51  return 0;
52 }
53 
54 
void aura_handle_events_forever(struct aura_eventloop *loop)
Definition: eventloop.c:187
void aura_wait_status(struct aura_node *node, int status)
Definition: aura.c:607
struct aura_eventloop * aura_eventloop_get_data(struct aura_node *node)
Definition: aura.c:243
struct aura_node * aura_open(const char *name, const char *opts)
Definition: aura.c:34
int size
Definition: aura.h:337
const struct aura_object * aura_get_current_object(struct aura_node *node)
Obtain the pointer to the current aura_object.
Definition: aura.c:226
void aura_unhandled_evt_cb(struct aura_node *node, void(*cb)(struct aura_node *node, struct aura_buffer *buf, void *arg), void *arg)
Definition: aura.c:314
void aura_eventloop_break(struct aura_eventloop *loop)
Definition: eventloop.c:244
void aura_close(struct aura_node *node)
Definition: aura.c:102
int aura_start_call(struct aura_node *node, const char *name, void(*calldonecb)(struct aura_node *dev, int status, struct aura_buffer *ret, void *arg), void *arg,...)
Definition: aura.c:564
char * data
Definition: aura.h:347