Annotation of libaitrpc/example/tsrv.c, revision 1.1.1.1.2.2
1.1 misho 1: #include <stdio.h>
2: #include <aitrpc.h>
3:
4:
1.1.1.1.2.2! misho 5: int aaa(rpc_func_t *f, int in, rpc_val_t *iv)
1.1 misho 6: {
1.1.1.1.2.2! misho 7: RPC_CALLBACK_CHK_NUM_ARGS(f, in);
1.1 misho 8:
9: printf("%s(%d): Piuk! %s\n", __func__, __LINE__, f->func_name);
10: return 0;
11: }
12:
1.1.1.1.2.2! misho 13: int BBB(rpc_func_t *f, int in, rpc_val_t *iv)
1.1 misho 14: {
15: rpc_val_t *v;
16:
1.1.1.1.2.2! misho 17: RPC_CALLBACK_CHK_NUM_ARGS(f, in);
1.1 misho 18:
1.1.1.1.2.2! misho 19: printf("%s(%d): Piuk! %s %d %s\n", __func__, __LINE__, f->func_name,
! 20: RPC_GET_I32(&iv[0]), RPC_GET_STR(&iv[1]));
1.1 misho 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:
1.1.1.1.2.2! misho 41: if (rpc_srv_initBLOBServer(srv, 0, "/tmp")) {
! 42: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
! 43: return 1;
! 44: }
! 45:
1.1 misho 46: rpc_srv_registerCall(srv, NULL, "aaa", 0);
47: rpc_srv_registerCall(srv, NULL, "BBB", 3);
48: rpc_srv_registerCall(srv, NULL, "dummy", 1);
49: rpc_srv_registerCall(srv, NULL, "xYz", 2);
50:
51: rpc_srv_unregisterCall(srv, NULL, "dummy");
52:
53: for (f = srv->srv_funcs; f; f = f->func_next)
54: printf("func::name=%s args=%d\n", f->func_name, f->func_args);
55:
1.1.1.1.2.1 misho 56: if (!fork()) {
57: setsid();
1.1 misho 58:
1.1.1.1.2.1 misho 59: if (rpc_srv_execServer(srv) == -1) {
60: printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
61: return 2;
62: }
1.1 misho 63: }
64:
1.1.1.1.2.2! misho 65: rpc_srv_endBLOBServer(srv);
1.1 misho 66: rpc_srv_endServer(srv);
67: return 0;
68: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>