|
|
1.1 ! root 1: /**************************************************************************** ! 2: Microsoft RPC Version 1.0 ! 3: Copyright Microsoft Corp. 1992 ! 4: Doctor Example ! 5: ! 6: FILE: Doctors.c ! 7: USAGE: doctors -n network_address ! 8: -p protocol_sequence ! 9: -e endpoint ! 10: -o options ! 11: -u uuid ! 12: PURPOSE: Server side of RPC distributed application Doctor ! 13: FUNCTIONS: main() - registers server as RPC server ! 14: COMMENTS: RPC version of an example program provided with: ! 15: Microsoft LISP Artificial Intelligence Programming ! 16: Environment for the MS-DOS Operating System ! 17: Portions Copyright (C) Microsoft Corporation 1986 ! 18: Copyright (C) Soft Warehouse, Inc.1979,1980,1982,1983,1985,1986 ! 19: Converted from LISP to C by David Bullock ! 20: Copyright (C) Microsoft Corporation 1992 ! 21: ****************************************************************************/ ! 22: #include <stdlib.h> ! 23: #include <windows.h> ! 24: #include <string.h> ! 25: #include <stdio.h> ! 26: #include <ctype.h> ! 27: #include <rpc.h> // RPC data structures and APIs ! 28: #include "doctor.h" // header file generated by MIDL compiler ! 29: ! 30: #define PURPOSE \ ! 31: "This Microsoft RPC Version 1.0 sample program demonstrates\n\ ! 32: the use of the [string] and [size_is] attributes. For more\n\ ! 33: information about attributes and RPC API functions, see the\n\ ! 34: RPC programming guide and reference.\n\n" ! 35: ! 36: void Usage(char * pszProgramName) ! 37: { ! 38: fprintf(stderr, "%s", PURPOSE); ! 39: fprintf(stderr, "Usage: %s\n", pszProgramName); ! 40: fprintf(stderr, " -p protocol_sequence\n"); ! 41: fprintf(stderr, " -n network_address\n"); ! 42: fprintf(stderr, " -e endpoint\n"); ! 43: fprintf(stderr, " -o options\n"); ! 44: fprintf(stderr, " -u uuid\n"); ! 45: exit(1); ! 46: } ! 47: ! 48: void main(int argc, char * argv[]) ! 49: { ! 50: RPC_STATUS status; ! 51: unsigned char * pszUuid = "12345678-1234-1234-1234-123456789ABC"; ! 52: unsigned char * pszProtocolSequence = "ncacn_np"; ! 53: unsigned char * pszNetworkAddress = NULL; ! 54: unsigned char * pszEndpoint = "\\pipe\\doctor"; ! 55: unsigned char * pszOptions = NULL; ! 56: unsigned char * pszStringBinding = NULL; ! 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 'n': // network address ! 67: pszNetworkAddress = argv[++i]; ! 68: break; ! 69: case 'e': ! 70: pszEndpoint = argv[++i]; ! 71: break; ! 72: case 'o': ! 73: pszOptions = argv[++i]; ! 74: break; ! 75: case 'u': ! 76: pszUuid = 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: 1, // maximum concurrent calls ! 90: pszEndpoint, ! 91: 0); ! 92: if (status) { ! 93: printf("RpcServerUseProtseqEp returned 0x%x\n", status); ! 94: exit(2); ! 95: } ! 96: ! 97: status = RpcServerRegisterIf(doctor_ServerIfHandle, 0, 0); ! 98: if (status) { ! 99: printf("RpcServerRegisterIf returned 0x%x\n", status); ! 100: exit(2); ! 101: } ! 102: ! 103: printf("The doctor is in.\n"); ! 104: status = RpcServerListen(1, ! 105: 12345); ! 106: if (status) { ! 107: printf("RpcServerListen returned: 0x%x\n", status); ! 108: exit(2); ! 109: } ! 110: ! 111: } /* end main() */ ! 112: ! 113: ! 114: // ==================================================================== ! 115: // MIDL allocate and free ! 116: // ==================================================================== ! 117: ! 118: void * MIDL_user_allocate(size_t len) ! 119: { ! 120: return(malloc(len)); ! 121: } ! 122: ! 123: void MIDL_user_free(void * ptr) ! 124: { ! 125: free(ptr); ! 126: } ! 127: /* end Doctor\server.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.