Annotation of mstools/samples/rpc/dict/server.c, revision 1.1.1.2

1.1       root        1: /*************************************************************/
                      2: /**                                                         **/
                      3: /**                 Microsoft RPC Examples                  **/
                      4: /**                 Dictionary Application                  **/
1.1.1.2 ! root        5: /**             Copyright(c) Microsoft Corp. 1992           **/
1.1       root        6: /**                                                         **/
                      7: /*************************************************************/
                      8: 
                      9: /*
                     10:  *************************************************************************
                     11:  * Remote dictionary example: server side                                *
                     12:  *                                                                       *
                     13:  * Created:                                 Dov Harel   12/??/1990       *
                     14:  * Modified to use context_handle           Donna Liu    3/??/1991       *
                     15:  * Further modifications / documentation    Dov Harel    5/1/1991        *
                     16:  *                                                                       *
                     17:  * Description:                                                          *
                     18:  * This is the driver for the server side remote dictionary              *
                     19:  * (splay trees based) demo.  This is a standard server driver,          *
                     20:  * and it works as follows:                                              *
                     21:  *                                                                       *
                     22:  *  o Call RpcCreateServer to initialize all data structures             *
                     23:  *                                                                       *
                     24:  *  o Initialize an appropriate protocol stack                           *
                     25:  *                                                                       *
                     26:  *  o Call RpcAddAddress to start listening on a transport address       *
                     27:  *    (a named pipe in our case).                                        *
                     28:  *                                                                       *
                     29:  *  o Call RpcAddInterface to initialize interface specific structures   *
                     30:  *    (such as dispatch table, etc.)                                     *
                     31:  *                                                                       *
                     32:  *  o Optionally advertise by calling RpcExport (not in this version)    *
                     33:  *                                                                       *
                     34:  *  o Loop forever...                                                    *
                     35:  *                                                                       *
                     36:  *************************************************************************
                     37: */
                     38: 
1.1.1.2 ! root       39: #define INCL_DOS
        !            40: 
1.1       root       41: #include <stdio.h>
                     42: #include <malloc.h>
                     43: #include <stdlib.h>
                     44: #include <string.h>
                     45: #include <ctype.h>
                     46: 
                     47: #include <rpc.h>
1.1.1.2 ! root       48: 
1.1       root       49: #include "dict0.h"
                     50: #include "replay.h"
                     51: #include "util0.h"
                     52: 
1.1.1.2 ! root       53: #ifdef AUTOHANDLE
        !            54: #include "nsi.h"
        !            55: #endif
        !            56: 
1.1       root       57: void exit(int);
                     58: 
                     59: void Usage()
                     60: {
                     61:   printf("Usage : server -a<address>\n");
                     62:   exit(1);
                     63: }
                     64: 
                     65: void
                     66: main(int argc, char *argv[])
                     67: {
                     68:   int                   argscan;
1.1.1.2 ! root       69:   unsigned char *       InterfaceAddress = "\\pipe\\dict";
1.1       root       70:   RPC_STATUS            status;
1.1.1.2 ! root       71:     RPC_BINDING_VECTOR * RpcBindingVector;
1.1       root       72: 
1.1.1.2 ! root       73:   printf ("Microsoft RPC demo Server - Splay (Binary) Tree DataBase\n");
1.1       root       74: 
                     75:   for (argscan = 1; argscan < argc; argscan++)
                     76:     {
                     77:       if (argv[argscan][0] == '-')
                     78:         {
                     79:           switch (argv[argscan][1])
                     80:             {
                     81:               case 'a':
                     82:               case 'A':
                     83:                 InterfaceAddress = &(argv[argscan][2]);
                     84:                 break;
                     85:               default:
                     86:                 Usage();
                     87:             }
                     88:         }
                     89:       else
                     90:         Usage();
                     91:     }
                     92: 
1.1.1.2 ! root       93:     if (status = RpcServerRegisterIf(dict_ServerIfHandle, 0, 0))
        !            94:         {
        !            95:        printf("Error in RpcServerRegisterIf: %x", status);
        !            96:         return;
        !            97:         }
1.1       root       98: 
1.1.1.2 ! root       99:     if (status = RpcServerUseProtseqEp((unsigned char *) "ncacn_np", 1,
        !           100:                 InterfaceAddress, 0))
        !           101:         {
        !           102:        printf("Error in RpcServerUseProtseqEp: %x", status);
        !           103:         return;
        !           104:         }
1.1       root      105: 
1.1.1.2 ! root      106: #ifdef AUTOHANDLE
1.1       root      107: 
1.1.1.2 ! root      108:     if (status = RpcServerInqBindings(&RpcBindingVector))
        !           109:         {
        !           110:        printf("Error in RpcServerInqBindings: %x", status);
        !           111:         return;
        !           112:         }
1.1       root      113: 
1.1.1.2 ! root      114:     if (status = RpcNsiBindExport(0, 0, dict_ServerIfHandle,
        !           115:         RpcBindingVector, 0))
        !           116:         {
        !           117:        printf("Error in RpcNsiBindExport: %x", status);
        !           118:         return;
        !           119:         }
1.1       root      120: 
                    121: /*
                    122:   printf ("server exported\n");
                    123: 
                    124:  * The above is required for advertising that the server is serving
                    125:  * a particular interface (using a locator or alternatively a
                    126:  * directory service / name service).  Strictly equired for clients
                    127:  * using auto_handle.
                    128: 
                    129: */
                    130: 
1.1.1.2 ! root      131: #endif
1.1       root      132: 
                    133: 
1.1.1.2 ! root      134:     printf ("Server Entering Listen Mode...\n");
        !           135: 
        !           136:     if (status = RpcServerListen(1, 10))
        !           137:         {
        !           138:        printf("Error in RpcServerListen: %x", status);
        !           139:         return;
        !           140:         }
        !           141: 
1.1       root      142: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.