|
|
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 Usage()
58: {
59: printf("Usage : server -a<address>\n");
60: exit(1);
61: }
62:
1.1.1.3 ! root 63: void _CRTAPI1
1.1 root 64: main(int argc, char *argv[])
65: {
66: int argscan;
1.1.1.2 root 67: unsigned char * InterfaceAddress = "\\pipe\\dict";
1.1 root 68: RPC_STATUS status;
1.1.1.2 root 69: RPC_BINDING_VECTOR * RpcBindingVector;
1.1 root 70:
1.1.1.2 root 71: printf ("Microsoft RPC demo Server - Splay (Binary) Tree DataBase\n");
1.1 root 72:
73: for (argscan = 1; argscan < argc; argscan++)
74: {
75: if (argv[argscan][0] == '-')
76: {
77: switch (argv[argscan][1])
78: {
79: case 'a':
80: case 'A':
81: InterfaceAddress = &(argv[argscan][2]);
82: break;
83: default:
84: Usage();
85: }
86: }
87: else
88: Usage();
89: }
90:
1.1.1.2 root 91: if (status = RpcServerRegisterIf(dict_ServerIfHandle, 0, 0))
92: {
93: printf("Error in RpcServerRegisterIf: %x", status);
94: return;
95: }
1.1 root 96:
1.1.1.2 root 97: if (status = RpcServerUseProtseqEp((unsigned char *) "ncacn_np", 1,
98: InterfaceAddress, 0))
99: {
100: printf("Error in RpcServerUseProtseqEp: %x", status);
101: return;
102: }
1.1 root 103:
1.1.1.2 root 104: #ifdef AUTOHANDLE
1.1 root 105:
1.1.1.2 root 106: if (status = RpcServerInqBindings(&RpcBindingVector))
107: {
108: printf("Error in RpcServerInqBindings: %x", status);
109: return;
110: }
1.1 root 111:
1.1.1.2 root 112: if (status = RpcNsiBindExport(0, 0, dict_ServerIfHandle,
113: RpcBindingVector, 0))
114: {
115: printf("Error in RpcNsiBindExport: %x", status);
116: return;
117: }
1.1 root 118:
119: /*
120: printf ("server exported\n");
121:
122: * The above is required for advertising that the server is serving
123: * a particular interface (using a locator or alternatively a
124: * directory service / name service). Strictly equired for clients
125: * using auto_handle.
126:
127: */
128:
1.1.1.2 root 129: #endif
1.1 root 130:
131:
1.1.1.2 root 132: printf ("Server Entering Listen Mode...\n");
133:
1.1.1.3 ! root 134: if (status = RpcServerListen(1, 10, 0))
1.1.1.2 root 135: {
136: printf("Error in RpcServerListen: %x", status);
137: return;
138: }
139:
1.1 root 140: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.