|
|
1.1 ! root 1: /**************************************************************************** ! 2: Microsoft RPC Version 1.0 ! 3: Copyright Microsoft Corp. 1992 ! 4: Auto Example ! 5: ! 6: FILE: autos.c ! 7: USAGE: server ! 8: PURPOSE: Server side of RPC distributed application Auto ! 9: FUNCTIONS: main() - registers server as RPC server ! 10: COMMENTS: Server side of auto handle example program. ! 11: ! 12: ****************************************************************************/ ! 13: #include <stdlib.h> ! 14: #include <string.h> ! 15: #include <stdio.h> ! 16: #include <rpc.h> // RPC data structures and APIs ! 17: #include "auto.h" // header file generated by MIDL compiler ! 18: ! 19: void Usage(char * pszProgramName) ! 20: { ! 21: fprintf(stderr, "Usage: %s\n", pszProgramName); ! 22: fprintf(stderr, " -p protocol_sequence\n"); ! 23: fprintf(stderr, " -e endpoint\n"); ! 24: exit(1); ! 25: } ! 26: ! 27: void main(int argc, char * argv[]) ! 28: { ! 29: RPC_STATUS status; ! 30: RPC_BINDING_VECTOR * pBindingVector; ! 31: ! 32: unsigned char * pszEndpoint = "\\pipe\\auto"; ! 33: unsigned char * pszProtocolSequence = "ncacn_np"; ! 34: int i; ! 35: ! 36: // allow the user to override settings with command line switches ! 37: for (i = 1; i < argc; i++) { ! 38: if ((*argv[i] == '-') || (*argv[i] == '/')) { ! 39: switch (tolower(*(argv[i]+1))) { ! 40: case 'p': // protocol sequence ! 41: pszProtocolSequence = argv[++i]; ! 42: break; ! 43: case 'e': ! 44: pszEndpoint = argv[++i]; ! 45: break; ! 46: case 'h': ! 47: case '?': ! 48: default: ! 49: Usage(argv[0]); ! 50: } ! 51: } ! 52: else ! 53: Usage(argv[0]); ! 54: } ! 55: ! 56: ! 57: status = RpcServerUseProtseqEp(pszProtocolSequence, ! 58: 1, // maximum concurrent calls ! 59: pszEndpoint, ! 60: 0); ! 61: printf("RpcServerUseProtseqEp returned 0x%x\n", status); ! 62: if (status) { ! 63: exit(2); ! 64: } ! 65: ! 66: status = RpcServerRegisterIf(autoh_ServerIfHandle, 0, 0); ! 67: printf("RpcServerRegisterIf returned 0x%x\n", status); ! 68: if (status) { ! 69: exit(2); ! 70: } ! 71: ! 72: status = RpcServerInqBindings(&pBindingVector); ! 73: printf("RpcServerInqBindings returned 0x%x\n", status); ! 74: if (status) { ! 75: exit(2); ! 76: } ! 77: ! 78: status = RpcNsBindingExport(RPC_C_NS_SYNTAX_DEFAULT, /* name syntax */ ! 79: "/.:/Autohandle_sample", /* name */ ! 80: autoh_ServerIfHandle, ! 81: pBindingVector, ! 82: NULL); /* UUID vector */ ! 83: printf("RpcNsBindingExport returned 0x%x\n", status); ! 84: if (status) { ! 85: exit(2); ! 86: } ! 87: ! 88: printf("Calling RpcServerListen\n"); ! 89: status = RpcServerListen(1, ! 90: 20); ! 91: printf("RpcServerListen returned: 0x%x\n", status); ! 92: if (status) { ! 93: exit(2); ! 94: } ! 95: ! 96: } /* end main() */ ! 97: ! 98: // ==================================================================== ! 99: // MIDL allocate and free ! 100: // ==================================================================== ! 101: ! 102: ! 103: void * MIDL_user_allocate(size_t len) ! 104: { ! 105: return(malloc(len)); ! 106: } ! 107: ! 108: void MIDL_user_free(void * ptr) ! 109: { ! 110: free(ptr); ! 111: } ! 112: ! 113: /* end autos.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.