home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / LINK / CLIENT / CLIENT.C next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  3.6 KB  |  107 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: link\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 link example. This driver
  24.  * program calls the remote procedure add_record 3 times to build the 
  25.  * linked list and then prints out the linked list, first traversing 
  26.  * the list forward and then backward.  
  27.  */        
  28.  
  29. #include <stdio.h>
  30. #include "link.h"    /* client header file, created by the RPC compiler */
  31.  
  32. extern int _rpcerr_;    /* declare RPC error code */
  33.  
  34. /* Server_Name is used to set the process-binding variable.
  35.  * It must be defined as the name the server registers under.
  36.  */
  37. #define Server_Name  "example"
  38.  
  39. /* declare variable of type server_name for process binding */
  40. server_name sname;
  41.  
  42. struct customer *cust_list;    /* pointer to head of linked list */
  43.  
  44. main()
  45. {
  46.     struct customer *fp, *bp;
  47.     int result;
  48.  
  49.     sname = Server_Name;
  50.  
  51.     cust_list = (struct customer *)0;
  52.  
  53.     /* example of call to add_record() */
  54.  
  55.     printf("CLIENT: calling add_record()\n");
  56.     result = add_record("Ralph Cramden", "Brooklyn, NY", "555-3333");
  57.  
  58.     if (_rpcerr_) {        /* check RPC return code */
  59.         printf("CLIENT: RPC error %d in add_record() call\n",
  60.             _rpcerr_);
  61.         exit(1);
  62.     }
  63.     printf("CLIENT: add_record() returned %d\n\n", result);
  64.  
  65.     /* second call to add_record() */
  66.  
  67.     printf("CLIENT: calling add_record()\n");
  68.     result = add_record("Andy Taylor  ", "Mayberry, NC", "555-6789");
  69.  
  70.     if (_rpcerr_) {        /* check RPC return code */
  71.         printf("CLIENT: RPC error %d in add_record() call\n",
  72.             _rpcerr_);
  73.         exit(1);
  74.     }
  75.     printf("CLIENT: add_record() returned %d\n\n", result);
  76.  
  77.     /* third call to add_record() */
  78.  
  79.     printf("CLIENT: calling add_record()\n");
  80.     result = add_record("Fred Flintstone", "Bedrock", "555-2222");
  81.  
  82.     if (_rpcerr_) {        /* check RPC return code */
  83.         printf("CLIENT: RPC error %d in add_record() call\n",
  84.             _rpcerr_);
  85.         exit(1);
  86.     }
  87.     printf("CLIENT: add_record() returned %d\n\n", result);
  88.  
  89.     printf("\n\nCLIENT: Customer List (using forward links):\n");
  90.     bp=(struct customer *)0;
  91.  
  92.     for (fp = cust_list; fp != (struct customer *)0; fp = fp->c_next) {
  93.         printf("         %s  %s  %s\n", fp->c_name, 
  94.             fp->c_addr, fp->c_phone);
  95.         bp=fp;
  96.     }
  97.  
  98.     printf("\n\n\nCLIENT: Customer List (using backward links):\n");
  99.  
  100.     for ( ; bp != (struct customer *)0; bp = bp->c_prev) {
  101.         printf("         %s  %s  %s\n", bp->c_name, 
  102.             bp->c_addr, bp->c_phone);
  103.     }
  104.  
  105.     exit(0);
  106. }
  107.