|
|
1.1.1.4 ! root 1: /**************************************************************************** ! 2: Microsoft RPC Version 1.0 ! 3: Copyright Microsoft Corp. 1992 ! 4: mandel Example ! 5: ! 6: FILE: server.c ! 7: ! 8: USAGE: server -p protocol_sequence ! 9: -e endpoint ! 10: -m max calls ! 11: -n min calls ! 12: -f flag for RpcServerListen ! 13: ! 14: PURPOSE: Server side of RPC distributed application mandel 1.1 root 15: 1.1.1.4 ! root 16: FUNCTIONS: main() - registers interface and listen for clients ! 17: ! 18: ****************************************************************************/ ! 19: ! 20: #include <stdlib.h> ! 21: #include <stdio.h> ! 22: #include <ctype.h> ! 23: #include "mdlrpc.h" // header file generated by MIDL compiler 1.1 root 24: 25: 1.1.1.3 root 26: void Usage(char * pszProgramName) 27: { 28: fprintf(stderr, "Usage: %s\n", pszProgramName); 29: fprintf(stderr, " -p protocol_sequence\n"); 30: fprintf(stderr, " -e endpoint\n"); 31: fprintf(stderr, " -m maxcalls\n"); 32: fprintf(stderr, " -n mincalls\n"); 33: fprintf(stderr, " -f flag_wait_op\n"); 34: exit(1); 35: } 36: 37: void _CRTAPI1 main(int argc, char * argv[]) 1.1 root 38: { 39: RPC_STATUS status; 1.1.1.3 root 40: unsigned char * pszProtocolSequence = "ncacn_np"; 1.1.1.4 ! root 41: unsigned char * pszSecurity = NULL; ! 42: unsigned char * pszEndpoint = "\\pipe\\mandel"; ! 43: unsigned int cMinCalls = 1; ! 44: unsigned int cMaxCalls = 20; ! 45: unsigned int fDontWait = FALSE; 1.1.1.3 root 46: int i; 47: 1.1.1.4 ! root 48: /* allow the user to override settings with command line switches */ 1.1.1.3 root 49: for (i = 1; i < argc; i++) { 1.1.1.4 ! root 50: if ((*argv[i] == '-') || (*argv[i] == '/')) { ! 51: switch (tolower(*(argv[i]+1))) { ! 52: case 'p': // protocol sequence ! 53: pszProtocolSequence = argv[++i]; ! 54: break; ! 55: case 'e': ! 56: pszEndpoint = argv[++i]; ! 57: break; ! 58: case 'm': ! 59: cMaxCalls = (unsigned int) atoi(argv[++i]); ! 60: break; ! 61: case 'n': ! 62: cMinCalls = (unsigned int) atoi(argv[++i]); ! 63: break; ! 64: case 'f': ! 65: fDontWait = (unsigned int) atoi(argv[++i]); ! 66: break; ! 67: case 'h': ! 68: case '?': ! 69: default: ! 70: Usage(argv[0]); ! 71: } ! 72: } ! 73: else ! 74: Usage(argv[0]); 1.1.1.3 root 75: } 1.1 root 76: 1.1.1.3 root 77: status = RpcServerUseProtseqEp(pszProtocolSequence, 1.1.1.4 ! root 78: cMaxCalls, 1.1.1.2 root 79: pszEndpoint, 1.1.1.4 ! root 80: pszSecurity); // Security descriptor 1.1.1.2 root 81: printf("RpcServerUseProtseqEp returned 0x%x\n", status); 1.1 root 82: if (status) { 1.1.1.4 ! root 83: exit(status); 1.1 root 84: } 85: 1.1.1.4 ! root 86: status = RpcServerRegisterIf(mdlrpc_ServerIfHandle, // interface to register ! 87: NULL, // MgrTypeUuid ! 88: NULL); // MgrEpv; null means use default 1.1.1.2 root 89: printf("RpcServerRegisterIf returned 0x%x\n", status); 1.1 root 90: if (status) { 1.1.1.4 ! root 91: exit(status); 1.1 root 92: } 1.1.1.3 root 93: 1.1.1.2 root 94: printf("Calling RpcServerListen\n"); 1.1.1.4 ! root 95: status = RpcServerListen(cMinCalls, ! 96: cMaxCalls, ! 97: fDontWait); 1.1.1.3 root 98: printf("RpcServerListen returned: 0x%x\n", status); 99: if (status) { 1.1.1.4 ! root 100: exit(status); 1.1.1.3 root 101: } 1.1 root 102: 1.1.1.3 root 103: if (fDontWait) { 1.1.1.4 ! root 104: printf("Calling RpcMgmtWaitServerListen\n"); ! 105: status = RpcMgmtWaitServerListen(); // wait operation ! 106: printf("RpcMgmtWaitServerListen returned: 0x%x\n", status); ! 107: if (status) { ! 108: exit(status); ! 109: } 1.1.1.3 root 110: } 1.1 root 111: 1.1.1.4 ! root 112: } // end main() ! 113: 1.1 root 114: 1.1.1.4 ! root 115: /*********************************************************************/ ! 116: /* MIDL allocate and free */ ! 117: /*********************************************************************/ 1.1 root 118: 1.1.1.4 ! root 119: void __RPC_FAR * __RPC_API midl_user_allocate(size_t len) 1.1.1.2 root 120: { 1.1.1.4 ! root 121: return(malloc(len)); 1.1.1.2 root 122: } 123: 1.1.1.4 ! root 124: void __RPC_API midl_user_free(void __RPC_FAR * ptr) 1.1.1.2 root 125: { 1.1.1.4 ! root 126: free(ptr); 1.1.1.2 root 127: } 1.1 root 128: 1.1.1.2 root 129: /* end server.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.