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