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