Annotation of libaitio/example/test_n2.c, revision 1.2.6.4
1.2 misho 1: #include <stdio.h>
1.2.6.1 misho 2: #include <string.h>
1.2 misho 3: #include <aitio.h>
4:
5:
6: int
7: main(int argc, char **argv)
8: {
9: io_sockaddr_t addr = { 0 };
1.2.6.1 misho 10: ait_val_t v, *val = NULL;
11:
12: AIT_SET_DATA(val, "shits hit the fan! --- shits with Merudia ...\n", 47);
13: printf("GET DATA = %p %s t=%d l=%d\n", val, AIT_GET_DATA(val), AIT_TYPE(val), AIT_LEN(val));
1.2.6.2 misho 14: AIT_SET_DATA(val, argv[1], strlen(argv[1]) + 1);
15: AIT_FREE_VAL(val);
16: AIT_SET_DATA(val, argv[1], strlen(argv[1]) + 1);
17: printf("GET DATA = %p %s t=%d l=%d\n", val, AIT_GET_DATA(val), AIT_TYPE(val), AIT_LEN(val));
1.2.6.1 misho 18: AIT_FREE_VAL(val);
1.2.6.4 ! misho 19: free(val);
1.2 misho 20:
21: if (!io_gethostbyname(argv[1], 1234, &addr)) {
22: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
23: return 1;
24: }
25:
26: if (!io_n2addr(&addr, &v)) {
27: printf("Error:: #%d - %s\n", io_GetErrno(), io_GetError());
28: return 2;
29: }
30:
31: printf("Address is %s port is %u\n", AIT_GET_STR(&v), io_n2port(&addr));
32:
33: AIT_FREE_VAL(&v);
34: return 0;
35: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>