/* ** File name: GETSYI_SVC_REG.C ** ** Copyright (c) 1991, by ** Process Software Corporation ** Framingham, Massachusetts */ /* ** Include files */ #include #include "TCPWARE_INCLUDE:RPC.H" #include "GETSYI.H" #include "GETSYI_DEF.H" /* ** Declare Functions */ extern thread_info *parse_rpc_args(); extern void encode_rpc_res(); /* **************************************** ** ** Main program ** ** Abstract: ** The main program for the server when using the registerrpc RPC ** function. This server uses only the UDP transport. */ main() { /* ** The server will use non-privileged ports. */ oncrpc_set_char( RPCCHAR__DEFPORTS, &RPCPORTS__NORMAL); if( registerrpc( GETSYI_PROG, GETSYI_VERS_1, GETSYI_PROC_1, getsyi_proc_1_1, xdr_getsyi_args, xdr_getsyi_res) < 0) { printf( "registerrpc failed\n"); exit( SS$_ABORT); } svc_run(); } /* end the main program */ /* **************************************** ** ** Function: getsyi_proc_1_1() ** ** Abstract: ** This routine converts the VAX format RPC arguments into the form that ** SYS$GETSYI expects, calls SYS$GETSYIW, converts the results into VAX ** format RPC results, and returns the address of these results to the ** dispatch routine. The dispatch routine is internal to the registerrpc ** function. ** ** This function does not receive the server handle, so it cannot send an ** error to the client. All errors are indicated by returning a 0 to the ** dispatch. If the RPC procedure returns a void, an error cannot be ** returned to registerrpc. ** ** Return value: ** The address of the results or 0 if a severe error occurred. */ getsyi_res *getsyi_proc_1_1( argsp) getsyi_args *argsp; { int i; DSC *node; thread_info *ti; /* ** These variables are used to contain the results that will be sent to the ** client. They must be static. */ static getsyi_res results; static char message[ 256+1]; static char rslt_str[ MAX_ITEM_CODES][ MAX_STRING_LEN+1]; static result rslt_array[ MAX_ITEM_CODES] = {0}; /* ** The first time that the server is called it will set up the array rslt_str ** to contain the addresses of all of the result strings in the array ** rslt_array. */ if( rslt_array[0] == 0) for( i = MAX_ITEM_CODES-1; i >= 0; --i) rslt_array[i] = rslt_str[i]; /* ** Convert the strings that the client sent into the integers that SYS$GETSYI ** expects. This function also sets up other information that will be used ** when converting the results into string to send to the client. */ if( (ti = parse_rpc_args( argsp)) == 0) return( 0); /* registerrpc will handle the errors */ ti->ti_xprt = 0; /* set to 0 since it does not apply here */ ti->ti_rqstp = 0; /* set to 0 since it does not apply here */ ti->ti_args = argsp; /* save the arguments */ /* ** parse_rpc_args returns errors in ti->ti_results.gsr_status. */ _error( ti->ti_results.gsr_status) { results = ti->ti_results; goto all_done; } /* ** If the client did not send a node string, pass a NULL pointer to SYS$GETSYI. */ if( ti->ti_node.dsc$w_length == 0) node = 0; else node = &ti->ti_node; results.gsr_status = sys$getsyiw( 0, 0, node, ti->ti_getsyi_args, &ti->ti_iosb, 0, 0); /* ** If the call was successful, get the status from the iosb. */ _success( results.gsr_status) results.gsr_status = ti->ti_iosb.val[0]; all_done: /* ** The status code determines whether a message or an array of results will be ** sent to the client. */ _success( results.gsr_status) results.getsyi_res_u.gsr_info.gsi_results.gsi_results_val = rslt_array; else results.getsyi_res_u.gsr_msg = message; encode_rpc_res( ti, &results); /* ** Free the thread information that parse_rpc_args allocated. */ free_vm( ti); return( &results); } /* end function getsyi_proc_1_1() */ /* end file GETSYI_SVC_REG.C */