Annotation of mstools/samples/rpc/handles/auto/autoc.c, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.