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