#include <stdio.h>
#include <aitrpc.h>
int aaa(void * const data, rpc_func_t *f, int in, rpc_val_t *iv)
{
RPC_CALLBACK_CHECK_ARGS(f, in);
printf("%s(%d): Piuk! %s\n", __func__, __LINE__, f->func_name);
return 0;
}
int BBB(void * const data, rpc_func_t *f, int in, rpc_val_t *iv)
{
rpc_val_t *v;
RPC_CALLBACK_CHECK_ARGS(f, in);
printf("%s(%d): Piuk! %s %d %s %d\n", __func__, __LINE__, f->func_name,
RPC_GET_I32(&iv[0]), RPC_GET_STR(&iv[1]), RPC_GET_U16(&iv[2]));
rpc_srv_declValsCall(f, 3);
rpc_srv_getValsCall(f, &v);
RPC_SET_BUF(&v[0], "00!oo", 6);
RPC_SET_I8(&v[1], 65);
RPC_SET_STR(&v[2], "Oho boho i cheburashka");
return 33;
}
int main()
{
rpc_srv_t *srv;
rpc_func_t *f;
srv = rpc_srv_initServer(100, 2, 1, 2, "0.0.0.0", 11111);
if (!srv) {
printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
return 1;
}
rpc_srv_registerCall(srv, NULL, "aaa", 0);
rpc_srv_registerCall(srv, NULL, "BBB", 3);
rpc_srv_registerCall(srv, NULL, "dummy", 1);
rpc_srv_registerCall(srv, NULL, "xYz", 2);
rpc_srv_unregisterCall(srv, NULL, "dummy");
for (f = srv->srv_funcs; f; f = f->func_next)
printf("func::name=%s args=%d\n", f->func_name, f->func_args);
switch (fork()) {
case -1:
return 1;
case 0:
setsid();
if (rpc_srv_execServer(srv) == -1) {
printf("error:: errno=%d %s\n", rpc_GetErrno(), rpc_GetError());
return 2;
}
break;
}
rpc_srv_endServer(srv);
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>