aura  0.1
 All Data Structures Functions Variables Modules Pages
dummy-async-by-id.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 pingcb(struct aura_node *dev, int status, struct aura_buffer *retbuf, void *arg)
16 {
17  numevt++;
18  printf("Event number %d with result %d arg %lld!\n", numevt, status, (long long unsigned int) arg);
19  if (arg != (void *) ARG2)
20  exit(1);
21  aura_hexdump("Out buffer", retbuf->data, retbuf->size);
22  if (numevt==4) {
23  printf("Breaking the loop\n");
25  }
26 }
27 
28 int main() {
29  slog_init(NULL, 18);
30 
31  int ret;
32  struct aura_node *n = aura_open("dummy", NULL);
33  aura_wait_status(n, AURA_STATUS_ONLINE);
34 
35  ret = aura_start_call_raw(n, 2, calldonecb, (void *) ARG, 0x0102);
36  if (ret !=0)
37  return ret;
38 
39  ret = aura_set_event_callback_raw(n, 5, pingcb, (void *) ARG2);
40  printf("event handler set with ret %d\n", ret);
42  printf("Closing the shop...");
43  aura_close(n);
44 
45  return 0;
46 }
47 
48 
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
int aura_set_event_callback_raw(struct aura_node *node, int id, void(*calldonecb)(struct aura_node *dev, int status, struct aura_buffer *ret, void *arg), void *arg)
Definition: aura.c:505
struct aura_node * aura_open(const char *name, const char *opts)
Definition: aura.c:34
int aura_start_call_raw(struct aura_node *node, int id, void(*calldonecb)(struct aura_node *dev, int status, struct aura_buffer *ret, void *arg), void *arg,...)
Definition: aura.c:462
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
char * data
Definition: aura.h:347