--- mstools/samples/rpc/handles/auto/autoc.c 2018/08/09 18:20:56 1.1.1.1 +++ mstools/samples/rpc/handles/auto/autoc.c 2018/08/09 18:24:20 1.1.1.3 @@ -1,64 +1,99 @@ /**************************************************************************** - Microsoft RPC Version 1.0 - Copyright Microsoft Corp. 1992 - Auto Example + Microsoft RPC Version 1.0 + Copyright Microsoft Corp. 1992 + Auto Example FILE: autoc.c - USAGE: client + + USAGE: autoc PURPOSE: Client side of RPC distributed application + FUNCTIONS: main() - binds to server and calls remote procedure - COMMENTS: - This distributed application uses auto handles. + + COMMENTS: This distributed application (time stamp) is implemented + using an auto handle. The client side of the application + does not care which server provides the time stamp; it + merely wants to get the time from any available server. + ****************************************************************************/ -#include -#include + #include +#include +#include #include -#include -#include "auto.h" +#include "auto.h" // header file generated by MIDL compiler + +#define PURPOSE \ +"This Microsoft RPC Version 1.0 sample program demonstrates\n\ +the use of the [auto_handle] attribute. For more information\n\ +about attributes and RPC API functions, see the RPC programming\n\ +guide and reference.\n\n" + +void Usage(char * pszProgramName) +{ + fprintf(stderr, "%s", PURPOSE); + fprintf(stderr, "Usage: %s\n", pszProgramName); + exit(1); +} -void main(void) +void _CRTAPI1 main(int argc, char **argv) { time_t t1; time_t t2; char * pszTime; + int i; + + /* allow the user to override settings with command line switches */ + for (i = 1; i < argc; i++) { + if ((*argv[i] == '-') || (*argv[i] == '/')) { + switch (tolower(*(argv[i]+1))) { + case 'h': + case '?': + default: + Usage(argv[0]); + } + } + else + Usage(argv[0]); + } + RpcTryExcept { - GetTime(&t1); // GetTime is a remote procedure - GetTime(&t2); + GetTime(&t1); // GetTime is a remote procedure + GetTime(&t2); - pszTime = ctime(&t1); - printf("time 1= %s\n", pszTime); + pszTime = ctime(&t1); + printf("time 1= %s\n", pszTime); - pszTime = ctime(&t2); - printf("time 2= %s\n", pszTime); + pszTime = ctime(&t2); + printf("time 2= %s\n", pszTime); - Shutdown(); // Shutdown is a remote procedure + Shutdown(); // Shutdown is a remote procedure } RpcExcept(1) { - printf("The RPC runtime library raised exception %d.\n", RpcExceptionCode()); - printf("Please verify that the server application and \n"); - printf("the locator service have been started."); + printf("The RPC runtime library raised an exception.\n"); + printf("Please verify that the server application and \n"); + printf("the locator service have been started."); } RpcEndExcept exit(0); -} +} // end main() -// ==================================================================== -// MIDL allocate and free -// ==================================================================== +/*********************************************************************/ +/* MIDL allocate and free */ +/*********************************************************************/ -void * MIDL_user_allocate(size_t len) +void __RPC_FAR * __RPC_API midl_user_allocate(size_t len) { return(malloc(len)); } -void MIDL_user_free(void * ptr) +void __RPC_API midl_user_free(void __RPC_FAR * ptr) { free(ptr); } -/* end \autoc.c */ +/* end file autoc.c */