home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / MACRO / CLIENT / CLIENT.C next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  3.0 KB  |  85 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: macro\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 macro example. The purpose of this
  24.  * example is to illustrate the use of expression macros.
  25.  */
  26.  
  27. #include <stdio.h>
  28. #include "macro.h"    /* client header file, created by the RPC compiler */
  29.  
  30. extern int _rpcerr_;    /* declare RPC error code */
  31.  
  32. /* Server_Name is used to set the process-binding variable.
  33.  * It must be defined as the name the server registers under.
  34.  */
  35. #define Server_Name  "example"
  36.  
  37. /* declare variable of type server_name for process binding */
  38. server_name sname;
  39.  
  40. main()
  41. {
  42.     int result;
  43.     struct record rp;
  44.     char *p;
  45.     extern char *strchr();
  46.  
  47.     sname = Server_Name;
  48.  
  49.     /* example of call to get_record() */
  50.  
  51.     printf("CLIENT: calling get_record(0)\n");
  52.     result = get_record(0, &rp);
  53.  
  54.     if (_rpcerr_) {        /* check RPC return code */
  55.         printf("CLIENT: RPC error %d in get_record(0) call\n",
  56.             _rpcerr_);
  57.         exit(1);
  58.     }
  59.  
  60.     /* add trailing null character to each string so they can be printed */
  61.     p = strchr(rp.buffer_1, rp.term_1);
  62.     *++p = '\0';
  63.     p = strchr(rp.r1.buffer_2, rp.term_2);
  64.     *++p = '\0';
  65.     p = strchr(rp.r1.r2.buffer_3, rp.term_3);
  66.     *++p = '\0';
  67.     p = strchr(rp.r1.r2.r3.buffer_4, rp.term_4);
  68.     *++p = '\0';
  69.     p = strchr(rp.r1.r2.r3.buffer_5, rp.term_5);
  70.     *++p = '\0';
  71.  
  72.     if (result == 0) {
  73.         printf("CLIENT: Record contents:\n");
  74.         printf("CLIENT: buffer_1:  '%s'\n", rp.buffer_1);
  75.         printf("CLIENT: buffer_2:  '%s'\n", rp.r1.buffer_2);
  76.         printf("CLIENT: buffer_3:  '%s'\n", rp.r1.r2.buffer_3);
  77.         printf("CLIENT: buffer_4:  '%s'\n", rp.r1.r2.r3.buffer_4);
  78.         printf("CLIENT: buffer_5:  '%s'\n", rp.r1.r2.r3.buffer_5);
  79.     } else {
  80.         printf("CLIENT: get_record error (%d)\n\n", result);
  81.     }
  82.  
  83.     exit(0);
  84. }
  85.