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 / callback / callp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-11  |  1.5 KB  |  56 lines

  1. /****************************************************************************
  2.                    Microsoft RPC Version 2.0
  3.            Copyright Microsoft Corp. 1992, 1993, 1994- 1996
  4.                       Callback Example
  5.  
  6.     FILE:       callp.c
  7.  
  8.     PURPOSE:    Remote procedures that are linked with the server
  9.                 side of RPC distributed application
  10.  
  11.     FUNCTIONS:  Fibonacci() -
  12.  
  13.     COMMENTS:   This sample program generates a Fibonacci number by
  14.                 static callback.
  15.  
  16. ****************************************************************************/
  17.  
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include "call.h"    // header file generated by MIDL compiler
  21.  
  22. short Fibonacci(short n)
  23. {
  24.     short nsub1, nsub2;
  25.  
  26.     printf("Fibonacci() called with value %d\n", n);
  27.     if ((n == 0) || (n == 1))
  28.         return(1);
  29.     else {
  30.         nsub1 = n - 1;
  31.         nsub2 = n - 2;
  32.         return(Fibonacci2(nsub1) + Fibonacci2(nsub2));
  33.     }
  34. }
  35.  
  36. void Shutdown(void)
  37. {
  38.     RPC_STATUS status;
  39.  
  40.     printf("calling RpcMgmtStopServerListening\n");
  41.     status = RpcMgmtStopServerListening(NULL);
  42.     printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
  43.     if (status) {
  44.         exit(status);
  45.     }
  46.  
  47.     printf("calling RpcServerUnregisterIf\n");
  48.     status = RpcServerUnregisterIf(NULL, NULL, FALSE);
  49.     printf("RpcServerUnregisterIf returned 0x%x\n", status);
  50.     if (status) {
  51.         exit(status);
  52.     }
  53. }
  54.  
  55. /* end file callp.c */
  56.