/* waveserver.c This simple aplication passes it's first argument to the Wave RPC server, and prints whatever Wave returns to stdout. If the Wave server can not be accessed it attempts to restart it. */ #include #include #include "wave_rpc_extern.h" #include "waveserver.h" UT_VAR *call_wave(); UT_VAR *ut_retval; /* pointer to UT_VAR */ static UT_VAR ut_arr[5]; UT_VAR *ut_params[2] = { &ut_arr[0], &ut_arr[1] }; char *str; int main(argc, argv) int argc; char *argv[]; { char *key; key = argv[1]; /* check if the server is up */ if ( call_server( key ) ) { fprintf(stderr,"Restarting server...\n"); system(START_CMD); /* now check again to see if it came up */ if ( call_server( key ) ) { /* didn't make it */ fprintf(stderr,"Error - Server unreachable\n"); } } } /* call the server */ int call_server( key ) char *key; { /* Put keyword in a ut_var */ ut_params[0]->type = TYP_STRING; ut_params[0]->element_size = sizeof(char); ut_params[0]->value.string = key; /* Call the server */ ut_retval = CALL_SERVER(ut_params); if (ut_retval->type == TYP_ERROR) { /* fprintf (stderr, "Error calling server\n"); */ return (1); } str = ut_retval->value.string; printf("%s",str); return(0); }