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 / dict / server.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  4.3 KB  |  109 lines

  1. /*************************************************************/
  2. /**                                                         **/
  3. /**                 Microsoft RPC Examples                  **/
  4. /**                 Dictionary Application                  **/
  5. /**          Copyright(c) Microsoft Corp. 1992-1996         **/
  6. /**                                                         **/
  7. /*************************************************************/
  8.  
  9. /*
  10.  *************************************************************************
  11.  *                                                                       *
  12.  * Remote dictionary example: server side                                *
  13.  *                                                                       *
  14.  * Description:                                                          *
  15.  * This is the driver for the server side remote dictionary              *
  16.  * (splay trees based) demo.  This is a standard server driver,          *
  17.  * and it works as follows:                                              *
  18.  *                                                                       *
  19.  *  o Call RpcCreateServer to initialize all data structures             *
  20.  *                                                                       *
  21.  *  o Initialize an appropriate protocol stack                           *
  22.  *                                                                       *
  23.  *  o Call RpcAddAddress to start listening on a transport address       *
  24.  *    (a named pipe in our case).                                        *
  25.  *                                                                       *
  26.  *  o Call RpcAddInterface to initialize interface specific structures   *
  27.  *    (such as dispatch table, etc.)                                     *
  28.  *                                                                       *
  29.  *  o Optionally advertise by calling RpcExport (not in this version)    *
  30.  *                                                                       *
  31.  *  o Loop forever...                                                    *
  32.  *                                                                       *
  33.  *************************************************************************
  34. */
  35.  
  36. #include <stdlib.h>
  37. #include <stdio.h>
  38. #include <ctype.h>
  39.  
  40. #include "replay.h"    // header file generated by MIDL compiler
  41. #include "dict0.h"
  42. #include "util0.h"
  43.  
  44.  
  45. void Usage()
  46. {
  47.   printf("Usage : server -e <endpoint>\n");
  48.   exit(1);
  49. }
  50.  
  51. void _CRTAPI1
  52. main(int argc, char *argv[])
  53. {
  54.     RPC_STATUS status;
  55.     unsigned char * pszProtocolSequence = "ncacn_np";
  56.     unsigned char * pszSecurity         = NULL;
  57.     unsigned char * pszEndpoint         = "\\pipe\\dict";
  58.     unsigned int    cMinCalls           = 1;
  59.     unsigned int    cMaxCalls           = 20;
  60.     unsigned int    fDontWait           = FALSE;
  61.     int i;
  62.  
  63.     printf ("Microsoft RPC demo Server - Splay (Binary) Tree DataBase\n");
  64.  
  65.     /* allow the user to override settings with command line switches */
  66.     for (i = 1; i < argc; i++) {
  67.         if ((*argv[i] == '-') || (*argv[i] == '/')) {
  68.             switch (tolower(*(argv[i]+1))) {
  69.             case 'e':
  70.                 pszEndpoint = argv[++i];
  71.                 break;
  72.             case 'h':
  73.             case '?':
  74.             default:
  75.                 Usage();
  76.             }
  77.         }
  78.         else
  79.             Usage();
  80.     }
  81.  
  82.     status = RpcServerUseProtseqEp(pszProtocolSequence,
  83.                                    cMaxCalls,
  84.                                    pszEndpoint,
  85.                                    pszSecurity);  // Security descriptor
  86.     if (status) {
  87.         printf("RpcServerUseProtseqEp returned 0x%x\n", status);
  88.         exit(status);
  89.     }
  90.  
  91.     status = RpcServerRegisterIf(dict_ServerIfHandle,  // interface to register
  92.                                  NULL,   // MgrTypeUuid
  93.                                  NULL);  // MgrEpv; null means use default
  94.     if (status) {
  95.         printf("RpcServerRegisterIf returned 0x%x\n", status);
  96.         exit(status);
  97.     }
  98.  
  99.     printf("Calling RpcServerListen\n");
  100.     status = RpcServerListen(cMinCalls,
  101.                              cMaxCalls,
  102.                              fDontWait);
  103.     if (status) {
  104.         printf("RpcServerListen returned: 0x%x\n", status);
  105.         exit(status);
  106.     }
  107.  
  108. }
  109.