|
|
1.1 root 1: /**************************************************************************** 1.1.1.3 ! root 2: Microsoft RPC Version 1.0 ! 3: Copyright Microsoft Corp. 1992 ! 4: Auto Example ! 5: ! 6: FILE: autoc.c ! 7: ! 8: USAGE: autoc ! 9: ! 10: PURPOSE: Client side of RPC distributed application ! 11: ! 12: FUNCTIONS: main() - binds to server and calls remote procedure ! 13: ! 14: COMMENTS: This distributed application (time stamp) is implemented ! 15: using an auto handle. The client side of the application ! 16: does not care which server provides the time stamp; it ! 17: merely wants to get the time from any available server. ! 18: 1.1 root 19: ****************************************************************************/ 1.1.1.3 ! root 20: 1.1 root 21: #include <stdlib.h> 1.1.1.3 ! root 22: #include <stdio.h> ! 23: #include <ctype.h> 1.1 root 24: #include <time.h> 1.1.1.3 ! root 25: #include "auto.h" // header file generated by MIDL compiler 1.1 root 26: 1.1.1.2 root 27: #define PURPOSE \ 28: "This Microsoft RPC Version 1.0 sample program demonstrates\n\ 29: the use of the [auto_handle] attribute. For more information\n\ 30: about attributes and RPC API functions, see the RPC programming\n\ 31: guide and reference.\n\n" 32: 33: void Usage(char * pszProgramName) 34: { 35: fprintf(stderr, "%s", PURPOSE); 36: fprintf(stderr, "Usage: %s\n", pszProgramName); 37: exit(1); 38: } 39: 40: void _CRTAPI1 main(int argc, char **argv) 1.1 root 41: { 42: time_t t1; 43: time_t t2; 44: char * pszTime; 1.1.1.2 root 45: int i; 46: 1.1.1.3 ! root 47: /* allow the user to override settings with command line switches */ 1.1.1.2 root 48: for (i = 1; i < argc; i++) { 1.1.1.3 ! root 49: if ((*argv[i] == '-') || (*argv[i] == '/')) { ! 50: switch (tolower(*(argv[i]+1))) { ! 51: case 'h': ! 52: case '?': ! 53: default: ! 54: Usage(argv[0]); ! 55: } ! 56: } ! 57: else ! 58: Usage(argv[0]); 1.1.1.2 root 59: } 60: 1.1 root 61: RpcTryExcept { 1.1.1.3 ! root 62: GetTime(&t1); // GetTime is a remote procedure ! 63: GetTime(&t2); 1.1 root 64: 1.1.1.3 ! root 65: pszTime = ctime(&t1); ! 66: printf("time 1= %s\n", pszTime); 1.1 root 67: 1.1.1.3 ! root 68: pszTime = ctime(&t2); ! 69: printf("time 2= %s\n", pszTime); 1.1 root 70: 1.1.1.3 ! root 71: Shutdown(); // Shutdown is a remote procedure 1.1 root 72: } 73: RpcExcept(1) { 1.1.1.3 ! root 74: printf("The RPC runtime library raised an exception.\n"); ! 75: printf("Please verify that the server application and \n"); ! 76: printf("the locator service have been started."); 1.1 root 77: } 78: RpcEndExcept 79: 80: exit(0); 81: 1.1.1.3 ! root 82: } // end main() 1.1 root 83: 84: 1.1.1.3 ! root 85: /*********************************************************************/ ! 86: /* MIDL allocate and free */ ! 87: /*********************************************************************/ 1.1 root 88: 1.1.1.3 ! root 89: void __RPC_FAR * __RPC_API midl_user_allocate(size_t len) 1.1 root 90: { 91: return(malloc(len)); 92: } 93: 1.1.1.3 ! root 94: void __RPC_API midl_user_free(void __RPC_FAR * ptr) 1.1 root 95: { 96: free(ptr); 97: } 98: 1.1.1.3 ! root 99: /* end file autoc.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.