/* ** File name: GETSYI_CLNT_CALLRPC.C ** ** Copyright (c) 1991, by ** Process Software Corporation ** Framingham, Massachusetts ** ** This file along with GETSYI_CLNT_SUBS.C implement a client for the getsyi ** protocol. This particular client uses the RPC callrpc function. Although ** this client does not use the GETSYI_CLNT.C file that was generated by ** RPCGEN, it is still helpful to create a GETSYI.X file and use RPCGEN to ** create the GETSYI.H and GETSYI_XDR.C files. ** */ /* ** Include files */ #include /* status code definitions (SS$_OPINCOMPL) */ #include "TCPWARE_INCLUDE:RPC.H" #include "GETSYI.H" /* created by RPCGEN */ #include "GETSYI_DEF.H" /* ** Declare Functions */ longw parse_command_line(); void write_output(); /* ** Variables ** ** The transport that the client will use to contact the server. Since the ** callrpc RPC function must use UDP, do not allow the user to specify a ** transport. This is done by initially setting transport to the string "UDP". */ globaldef char transport[4] = {"UDP"}; /* ** The name of the server's host. An initial value of 0 allows the user to ** specify any host. */ globaldef char *host = 0; static readonly char usage[] = "Command format: getsyi [-d#] [-hhost] [-nnode] code [code...]\n"; /* **************************************** ** ** Main program ** ** Abstract: ** This client program demonstrates the use of the callrpc function. */ main( argc, argv) int argc; char *argv[]; { longw status; /* VMS status code */ int rpc_status; /* callrpc status code */ getsyi_args args; /* request sent to server */ getsyi_res results; /* reply received from server */ /* ** Parse the command line that the user entered. After this function call, the ** variable host points the name of the server's host and args contains all of ** the information that will be sent to the server. */ _error( status = parse_command_line( argc, argv, &args)) { if( status == SS$_BADPARAM) printf( usage); exit( status); } /* ** results must be zeroed so that xdr_getsyi_res will allocate the memory. ** Otherwise, xdr_getsyi_res assumes that results contains the addresses of ** valid buffers. */ bzero( &results, sizeof( results)); /* ** Unlike the clnt_call function, callrpc does not take a client handle. ** Instead it takes the information that is required to create the client ** handle. This include the hostname and the program and version numbers. */ if( rpc_status = callrpc( host, GETSYI_PROG, GETSYI_VERS_1, GETSYI_PROC_1, xdr_getsyi_args, &args, xdr_getsyi_res, &results) != 0) { printf( "Unable to call the server\n"); clnt_perrno( rpc_status); /* print why callrpc failed */ exit( SS$_OPINCOMPL); } /* ** Display the output for the user to see. */ write_output( &args, &results); exit( SS$_NORMAL); } /* end file GETSYI_CLNT_CALLRPC.C */