LCOV - code coverage report
Current view: top level - examples/lowlevel - rpc_clnt.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 17 0
Test Date: 2025-11-11 10:26:08 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /********************************************************************\
       2              : 
       3              :   Name:         rpc_clnt.c
       4              :   Created by:   Stefan Ritt
       5              : 
       6              :   Contents:     Mini RPC client program for test purposes.
       7              : 
       8              :   $Id$
       9              : 
      10              : \********************************************************************/
      11              : 
      12              : #include "midas.h"
      13              : #include <stdio.h>
      14              : 
      15              : /* user RPC ID's must start after RPC_MIN_ID */
      16              : #define RPC_MYTEST RPC_MIN_ID
      17              : 
      18              : /* define MYTEST function with some parameters, 
      19              :    must match definition on server */
      20              : RPC_LIST rpc_list[] = {
      21              : 
      22              :    {RPC_MYTEST, "rpc_mytest",
      23              :     {{TID_UINT8, RPC_IN}
      24              :      ,
      25              :      {TID_UINT16, RPC_IN}
      26              :      ,
      27              :      {TID_INT32, RPC_IN}
      28              :      ,
      29              :      {TID_FLOAT, RPC_IN}
      30              :      ,
      31              :      {TID_DOUBLE, RPC_IN}
      32              :      ,
      33              :      {TID_UINT8, RPC_OUT}
      34              :      ,
      35              :      {TID_UINT16, RPC_OUT}
      36              :      ,
      37              :      {TID_INT32, RPC_OUT}
      38              :      ,
      39              :      {TID_FLOAT, RPC_OUT}
      40              :      ,
      41              :      {TID_DOUBLE, RPC_OUT}
      42              :      ,
      43              :      {0}
      44              :      }
      45              :     }
      46              :    ,
      47              : 
      48              :    {0}
      49              : 
      50              : };
      51              : 
      52              : /*------------------------------------------------------------------*/
      53              : 
      54            0 : int main()
      55              : {
      56              :    char host_name[80];
      57              :    HNDLE hConn;
      58              :    INT status;
      59              :    BYTE b;
      60              :    WORD w;
      61              :    INT i;
      62              :    float f;
      63              :    double d;
      64              : 
      65            0 :    printf("Remote host name: ");
      66            0 :    ss_gets(host_name, sizeof(host_name));
      67              : 
      68              :    /* register this as an RPC client with rpc_list */
      69            0 :    rpc_register_client("MYCLIENT", rpc_list);
      70              : 
      71              :    /* connect to RPC server */
      72            0 :    status = rpc_client_connect(host_name, 1750, "", &hConn);
      73            0 :    if (status != RPC_SUCCESS) {
      74            0 :       printf("Cannot connect to RPC server running on %s at port 1750.\n", host_name);
      75            0 :       return 0;
      76              :    }
      77              : 
      78            0 :    f = 3.5f;
      79            0 :    d = 4.5;
      80              : 
      81              :    /* rpc_mytest just doubles numbers */
      82            0 :    rpc_client_call(hConn, RPC_MYTEST, 1, 2, 3l, f, d, &b, &w, &i, &f, &d);
      83              : 
      84            0 :    printf("\nResult should be:  2 4 6 7.0 9.0\n");
      85            0 :    printf("Result is:         %d %d %d %1.1f %1.1lf\n", b, w, i, f, d);
      86              : 
      87            0 :    printf("\nhit return...");
      88            0 :    b = getchar();
      89              : 
      90              :    /* disconnect this client from server */
      91            0 :    rpc_client_disconnect(hConn, FALSE);
      92            0 :    return 1;
      93              : }
        

Generated by: LCOV version 2.0-1