home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / ERROR / CLIENT / CLIENT.C next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  3.1 KB  |  78 lines

  1. /*                                                                            *
  2.  *                                                                            *
  3.  *                  Copyright 1987, 1988, 1989 Netwise, Inc.                  *
  4.  *                              All Rights Reserved                           *
  5.  *   This software contains information which is proprietary to and a trade   *
  6.  *   secret of Netwise, Inc. It is not to be used, reproduced, or disclosed   *
  7.  *   except as authorized in your license agreement.                          *
  8.  *                                                                            *
  9.  *                          Restricted Rights Legend                          *
  10.  *   Use, duplication,  or  disclosure  by the  Government  is  subject  to   *
  11.  *   restrictions as set forth in subparagraph (c)(1)(ii) of the Rights  in   *
  12.  *   Technical Data and  Computer Software clause  at 252.227-7013, or  the   *
  13.  *   equivalent Government clause for other agencies.                         *
  14.  *   Contractor: Netwise, Inc., Boulder, CO 80301 USA                         *
  15.  *                                                                            *
  16.  */ 
  17. /*                                                                            *
  18.  * File: error\client\client.c
  19.  *
  20.  * This example works in the following environments:
  21.  *    NetWare RPC 1.0, NetWare 2.1 or higher, DOS 3.3
  22.  *
  23.  * This is the driver program for the error example. The purpose of this
  24.  * example is to illustrate how to add custom code to a client stub. In
  25.  * this case, the custom code reports RPC errors using the return values 
  26.  * of a remote procedure call.
  27.  *
  28.  * This driver program calls the remote procedure update_key() and prints 
  29.  * the result. Refer to the error_i.rpc file (which is imported into the
  30.  * error.rpc file) to see how the client stub is customized.               
  31.  */ 
  32. #include <stdio.h>
  33. #include "error.h"    /* client header file, created by the RPC compiler */
  34.  
  35. extern int _rpcerr_;    /* declare RPC error code */
  36.  
  37. /* Server_Name is used to set the process-binding variable.
  38.  * It must be defined as the name the server registers under.
  39.  */
  40. #define Server_Name  "example"
  41.  
  42. /* declare variable of type server_name for process binding */
  43. server_name sname;
  44.  
  45. main()
  46. {
  47.     int current_key;
  48.     int result;
  49.  
  50.     sname = Server_Name;
  51.  
  52.     current_key = 0;
  53.  
  54.     /* Example of call to update_key() */
  55.     printf("CLIENT: update_key called \n");
  56.     result = update_key(¤t_key);
  57.  
  58.     if (result == 0) {
  59.         printf("CLIENT: update_key() returned key %d\n",current_key);
  60.     } else {
  61.         /* Note that RPC errors will be reported here also */
  62.         printf("CLIENT: update_key error (%d)\n", result);
  63.     }
  64.  
  65.     /* Example of another call to update_key() */
  66.     printf("CLIENT: update_key called again\n");
  67.     result = update_key(¤t_key);
  68.  
  69.     if (result == 0) {
  70.         printf("CLIENT: update_key() returned key %d\n",current_key);
  71.     } else {
  72.         /* Note that RPC errors will be reported here also */
  73.         printf("CLIENT: update_key error (%d)\n", result);
  74.     }
  75.  
  76.     exit(0);
  77. }
  78.