Annotation of libaitrpc/example/tsrv.c, revision 1.1.1.1.2.1
1.1 misho 1: #include <stdio.h>
2: #include <aitrpc.h>
3:
4:
5: int aaa(void * const data, rpc_func_t *f, int in, rpc_val_t *iv)
6: {
7: RPC_CALLBACK_CHECK_ARGS(f, in);
8:
9: printf("%s(%d): Piuk! %s\n", __func__, __LINE__, f->func_name);
10: return 0;
11: }
12:
13: int BBB(void * const data, rpc_func_t *f, int in, rpc_val_t *iv)
14: {
15: rpc_val_t *v;
16:
17: RPC_CALLBACK_CHECK_ARGS(f, in);
18:
19: printf("%s(%d): Piuk! %s %d %s %d\n", __func__, __LINE__, f->func_name,
20: RPC_GET_I32(&iv[0]), RPC_GET_STR(&iv[1]), RPC_GET_U16(&iv[2]));
21:
22: rpc_srv_declValsCall(f, 3);
23: rpc_srv_getValsCall(f, &v);
24: RPC_SET_BUF(&v[0], "00!oo", 6);
25: RPC_SET_I8(&v[1], 65);
26: RPC_SET_STR(&v[2], "Oho boho i cheburashka");
27: return 33;
28: }
29:
30: int main()
31: {
32: rpc_srv_t *srv;
33: rpc_func_t *f;
34:
35: srv = rpc_srv_initServer(100, 2, 1, 2, "0.0.0.0", 11111);
36: if (!srv) {
37: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
38: return 1;
39: }
40:
41: rpc_srv_registerCall(srv, NULL, "aaa", 0);
42: rpc_srv_registerCall(srv, NULL, "BBB", 3);
43: rpc_srv_registerCall(srv, NULL, "dummy", 1);
44: rpc_srv_registerCall(srv, NULL, "xYz", 2);
45:
46: rpc_srv_unregisterCall(srv, NULL, "dummy");
47:
48: for (f = srv->srv_funcs; f; f = f->func_next)
49: printf("func::name=%s args=%d\n", f->func_name, f->func_args);
50:
1.1.1.1.2.1! misho 51: if (!fork()) {
! 52: setsid();
1.1 misho 53:
1.1.1.1.2.1! misho 54: if (rpc_srv_execServer(srv) == -1) {
! 55: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 56: return 2;
! 57: }
1.1 misho 58: }
59:
60: rpc_srv_endServer(srv);
61: return 0;
62: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>