home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n001 / 2.ddi / EXAMPLES / POINTER1 / SERVER / RPROC.C next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  2.5 KB  |  68 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: pointer1\server\rproc.c
  19.  *
  20.  * This example runs in the following environment:
  21.  *    NetWare RPC 1.0, NetWare 2.1 or higher, DOS 3.3
  22.  *
  23.  * This file contains the remote procedures for the pointer example.
  24.  */ 
  25.  
  26. #include <stdio.h>
  27. #include "pointer1.h"    /* server header file, created by the RPC compiler */
  28.  
  29. struct info names[] = {
  30.     { "Rocket", "Squirrel", 25 },
  31.     { "Bullwinkle", "Moose", 27 },
  32.     { "Dudley", "Doright", 34 }
  33. };
  34.  
  35. int
  36. get_data(data)
  37. struct info ***data;    /* address of sequence of pointers to structures */
  38. {
  39.     struct info **top;
  40.     int i;
  41.     extern char *malloc();
  42.  
  43.     printf("SERVER: get_data() called \n");
  44.  
  45.     /* allocate memory for sequence of pointers to structures; this
  46.      * memory will be deallocated via the exit statement in the RPC
  47.      * specification
  48.      */
  49.     if ((*data=(struct info **)malloc(10 * sizeof (struct info *))) ==
  50.         (struct info **)NULL) {
  51.         printf ("malloc failed! execution aborted\n");
  52.         exit (1);
  53.         }
  54.     top = *data;
  55.  
  56.     /* for each pointer in the sequence, assign it to point to a structure;
  57.      * each structure, for convenience, is not dynamically allocated, but
  58.      * is statically allocated and initialized above
  59.      */
  60.     for (i=0; i<3; i++) {
  61.         *top++ = &names[i];
  62.     }
  63.     /* the final pointer must be NULL */
  64.     *top = (struct info *)NULL;
  65.  
  66.     return (0);
  67. }
  68.