aura  0.1
 All Data Structures Functions Variables Modules Pages
dummy-async.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);
13 
14 }
15 
16 static int numevt=0;
17 void pingcb(struct aura_node *dev, int status, struct aura_buffer *retbuf, void *arg)
18 {
19  numevt++;
20  printf("Event number %d with result %d arg %lld!\n", numevt, status, (long long unsigned int) arg);
21  if (arg != (void *) ARG2)
22  exit(1);
23  aura_hexdump("Out buffer", retbuf->data, retbuf->size);
24  if (numevt==4) {
25  printf("Breaking the loop\n");
27  }
28 }
29 
30 int main() {
31  slog_init(NULL, 18);
32 
33  int ret;
34  struct aura_node *n = aura_open("dummy", NULL);
35  aura_wait_status(n, AURA_STATUS_ONLINE);
36 
37  ret = aura_start_call(n, "echo_u16", calldonecb, (void *) ARG, 0x0102);
38  printf("call started with ret %d\n", ret);
39  if (ret !=0)
40  return ret;
41 
42  ret = aura_set_event_callback(n, "ping", pingcb, (void *) ARG2);
43  printf("event handler set with ret %d\n", ret);
45  printf("Closing teh shop...");
46 
47  aura_close(n);
48 
49  return 0;
50 }
51 
52 
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
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
int aura_set_event_callback(struct aura_node *node, const char *event, void(*calldonecb)(struct aura_node *dev, int status, struct aura_buffer *ret, void *arg), void *arg)
Definition: aura.c:536