home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / rpc / data / xmit / xmitp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-11  |  3.7 KB  |  112 lines

  1. /****************************************************************************
  2.                    Microsoft RPC Version 2.0
  3.            Copyright Microsoft Corp. 1992, 1993, 1994- 1996
  4.                          xmit Example
  5.  
  6.     FILE:       xmitp.c
  7.  
  8.     PURPOSE:    Remote procedures that are linked with the server
  9.                 side of RPC distributed application
  10.  
  11.     FUNCTIONS:  ModifyListProc() - changes the doubly-linked list
  12.                 Shutdown() - shuts down the server side
  13.  
  14.     COMMENTS:   Related to xmits.c
  15.  
  16. ****************************************************************************/
  17.  
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include "xmit.h"    // header file generated by MIDL compiler
  21.  
  22.  
  23. /****************************************************************************
  24.  
  25. Function:   ModifyListProc
  26.  
  27. Parameters: pFirst : Pointer to the head of a doubly-linked list.
  28.  
  29. Returns:    none
  30.  
  31. Purpose:    Display the list passed to the function.
  32.             For each element in the list, add another element.
  33.             Display the modified list.
  34.  
  35. Comments:   This sample is meant to demonstrate a typical use of the
  36.             transmit_as attribute:  A complex data structure is simplified
  37.             for transmission over the network, restored on the server,
  38.             then manipulated by the remote function on the server.
  39.             The modified data is returned to the client.
  40.  
  41.             Calls InsertNewNode(param1, param2), a utility routine
  42.             in xmits.c that creates a new node, assigns to it the
  43.             value param1, and inserts it into the list after param2.
  44.  
  45. ****************************************************************************/
  46.  
  47. DOUBLE_LINK_TYPE * InsertNewNode(short sValue, DOUBLE_LINK_TYPE * pPrevious);
  48.  
  49. void ModifyListProc(DOUBLE_LINK_TYPE * pFirst)
  50. {
  51.     DOUBLE_LINK_TYPE * pList = pFirst;
  52.     short newNumber;
  53.  
  54.     printf("ModifyListProc: Display contents of doubly linked list:\n");
  55.     while (pList != NULL) {
  56.          printf("pList @0x%x = %d, Next = 0x%x\n",
  57.                 pList, pList->sNumber, pList->pNext);
  58.          pList = pList->pNext;
  59.     }
  60.  
  61.     printf("ModifyListProc: Add one node for every node in tree\n");
  62.     for (pList = pFirst; pList != NULL; pList = pList->pNext) {
  63.         newNumber = pList->sNumber + 1;
  64.         pList = InsertNewNode(newNumber, pList);
  65.     }
  66.  
  67.     printf("ModifyListProc: Display modified contents of doubly linked list:\n");
  68.     for (pList = pFirst; pList != NULL; pList = pList->pNext) {
  69.         printf("pList @0x%x = %d, Next = 0x%x\n",
  70.                pList, pList->sNumber, pList->pNext);
  71.     }
  72. }
  73.  
  74.  
  75. /****************************************************************************
  76.  
  77. Function:   Shutdown
  78.  
  79. Parameters: none
  80.  
  81. Returns:    none
  82.  
  83. Purpose:    Make the server stop listening for client applications.
  84.  
  85. Comments:   The two NULL parameters passed to RpcServerUnregisterIf are
  86.             a show of brute force:  they tell the function to turn
  87.             off all registered interfaces.  See the RPC API function
  88.             reference for more information about these functions.
  89.  
  90. ****************************************************************************/
  91.  
  92. void Shutdown(void)
  93. {
  94.     RPC_STATUS status;
  95.  
  96.     printf("Calling RpcMgmtStopServerListening\n");
  97.     status = RpcMgmtStopServerListening(NULL);
  98.     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
  99.     if (status) {
  100.         exit(status);
  101.     }
  102.  
  103.     printf("Calling RpcServerUnregisterIf\n");
  104.     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
  105.     printf("RpcServerUnregisterIf returned 0x%x\n", status);
  106.     if (status) {
  107.         exit(status);
  108.     }
  109. }
  110.  
  111. /* end file xmitp.c */
  112.