--- mstools/samples/rpc/handles/auto/autoc.c 2018/08/09 18:20:56 1.1 +++ mstools/samples/rpc/handles/auto/autoc.c 2018/08/09 18:22:05 1.1.1.2 @@ -1,13 +1,13 @@ /**************************************************************************** - 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 + FILE: autoc.c + USAGE: client - PURPOSE: Client side of RPC distributed application - FUNCTIONS: main() - binds to server and calls remote procedure + PURPOSE: Client side of RPC distributed application + FUNCTIONS: main() - binds to server and calls remote procedure COMMENTS: This distributed application uses auto handles. ****************************************************************************/ @@ -18,27 +18,56 @@ #include #include "auto.h" -void main(void) +#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 _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 @@ -61,4 +90,4 @@ void MIDL_user_free(void * ptr) free(ptr); } -/* end \autoc.c */ +/* end autoc.c */