|
|
1.1 root 1: /****************************************************************************
2: Microsoft RPC Version 1.0
3: Copyright Microsoft Corp. 1992
4: Discriminated Union Example
5:
6: FILE: dunions.c
7: USAGE: server
8: PURPOSE: Server side of RPC distributed application dunion
9: FUNCTIONS: main() - registers server as RPC server
10: COMMENTS:
11: ****************************************************************************/
12: #include <stdlib.h>
13: #include <windows.h>
14: #include <string.h>
15: #include <stdio.h>
16: #include <ctype.h>
17: #include <rpc.h> // RPC data structures and APIs
18: #include "dunion.h" // header file generated by MIDL compiler
19:
20: void Usage(char * pszProgramName)
21: {
22: fprintf(stderr, "Usage: %s\n", pszProgramName);
23: fprintf(stderr, " -p protocol_sequence\n");
24: fprintf(stderr, " -n network_address\n");
25: fprintf(stderr, " -e endpoint\n");
26: fprintf(stderr, " -o options\n");
27: fprintf(stderr, " -u uuid\n");
28: exit(1);
29: }
30:
31: void main(int argc, char * argv[])
32: {
33: RPC_STATUS status;
34: unsigned char * pszUuid = "12345678-1234-1234-1234-123456789ABC";
35: unsigned char * pszProtocolSequence = "ncacn_np";
36: unsigned char * pszNetworkAddress = NULL;
37: unsigned char * pszEndpoint = "\\pipe\\dunion";
38: unsigned char * pszOptions = NULL;
39: unsigned char * pszStringBinding = NULL;
40: int i;
41:
42: // allow the user to override settings with command line switches
43: for (i = 1; i < argc; i++) {
44: if ((*argv[i] == '-') || (*argv[i] == '/')) {
45: switch (tolower(*(argv[i]+1))) {
46: case 'p': // protocol sequence
47: pszProtocolSequence = argv[++i];
48: break;
49: case 'n': // network address
50: pszNetworkAddress = argv[++i];
51: break;
52: case 'e':
53: pszEndpoint = argv[++i];
54: break;
55: case 'o':
56: pszOptions = argv[++i];
57: break;
58: case 'u':
59: pszUuid = argv[++i];
60: break;
61: case 'h':
62: case '?':
63: default:
64: Usage(argv[0]);
65: }
66: }
67: else
68: Usage(argv[0]);
69: }
70:
71: status = RpcServerUseProtseqEp(pszProtocolSequence,
72: 1, // maximum concurrent calls
73: pszEndpoint,
74: 0);
75: printf("RpcServerUseProtseqEp returned 0x%x\n", status);
76: if (status) {
77: exit(2);
78: }
79:
80: status = RpcServerRegisterIf(dunion_ServerIfHandle, 0, 0);
81: printf("RpcServerRegisterIf returned 0x%x\n", status);
82: if (status) {
83: exit(2);
84: }
85:
86: printf("Calling RpcServerListen\n");
87: status = RpcServerListen(1,
88: 20);
89: printf("RpcServerListen returned: 0x%x\n", status);
90: if (status) {
91: exit(2);
92: }
93:
94: } /* end main() */
95:
96: // ====================================================================
97: // MIDL allocate and free
98: // ====================================================================
99:
100:
101: void * MIDL_user_allocate(size_t len)
102: {
103: return(malloc(len));
104: }
105:
106: void MIDL_user_free(void * ptr)
107: {
108: free(ptr);
109: }
110:
111: /* end dunions.c */
112:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.