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