Annotation of mstools/samples/rpc/data/xmit/xmits.c, revision 1.1.1.3

1.1       root        1: /****************************************************************************
1.1.1.3 ! root        2:                    Microsoft RPC Version 1.0
        !             3:                 Copyright Microsoft Corp. 1992
        !             4:                         xmit Example
        !             5: 
        !             6:     FILE:       xmits.c
        !             7:     
        !             8:     USAGE:      xmits  -p protocol_sequence
        !             9:                        -e endpoint
        !            10:                        -m max calls
        !            11:                        -n min calls
        !            12:                        -f flag for RpcServerListen
        !            13: 
        !            14:     PURPOSE:    Server side of RPC distributed application xmit
        !            15:     
        !            16:     FUNCTIONS:  main() - registers server as RPC server
        !            17: 
        !            18:     COMMENTS:   This sample program generates a linked list to
        !            19:                 demonstrate how the list can be transmitted over
        !            20:                 the network more efficiently as a sized array.
        !            21:                 The pointers are rebuilt on the server side.
        !            22: 
        !            23:                 The [transmit_as] attribute (used in the typedef of
        !            24:                 DOUBLE_LINK_TYPE in the file XMIT.IDL) requires the
        !            25:                 four user-supplied functions whose names start with
        !            26:                 the name of the presented type, DOUBLE_LINK_TYPE.
        !            27: 
        !            28:                 The [in, out] attributes applied to remote procedure
        !            29:                 parameters require the two user-supplied functions
        !            30:                 midl_user_allocate and midl_user_free.
        !            31: 
        !            32:                 The other functions are utilities that are used to
        !            33:                 build or display the data structures.
1.1       root       34: 
                     35: ****************************************************************************/
1.1.1.3 ! root       36: 
1.1       root       37: #include <stdlib.h>
                     38: #include <stdio.h>
                     39: #include <ctype.h>
1.1.1.3 ! root       40: #include "xmit.h"     // header file generated by MIDL compiler
        !            41: #include "xmitu.h"    // Function prototypes for utility functions
1.1       root       42: 
                     43: #define PURPOSE \
                     44: "This Microsoft RPC Version 1.0 sample program demonstrates\n\
                     45: the use of the [transmit_as] attribute. For more information\n\
                     46: about the attributes and the RPC API functions, see the\n\
                     47: RPC programming guide and reference.\n\n"
                     48: 
                     49: void Usage(char * pszProgramName)
                     50: {
                     51:     fprintf(stderr, "%s", PURPOSE);
                     52:     fprintf(stderr, "Usage:  %s\n", pszProgramName);
                     53:     fprintf(stderr, " -p protocol_sequence\n");
                     54:     fprintf(stderr, " -e endpoint\n");
1.1.1.2   root       55:     fprintf(stderr, " -m maxcalls\n");
                     56:     fprintf(stderr, " -n mincalls\n");
                     57:     fprintf(stderr, " -f flag_wait_op\n");
1.1       root       58:     exit(1);
                     59: }
                     60: 
                     61: /* main:  register the interface, start listening for clients */
1.1.1.2   root       62: void _CRTAPI1 main(int argc, char * argv[])
1.1       root       63: {
                     64:     RPC_STATUS status;
                     65:     unsigned char * pszProtocolSequence = "ncacn_np";
1.1.1.3 ! root       66:     unsigned char * pszSecurity         = NULL;
        !            67:     unsigned char * pszEndpoint         = "\\pipe\\xmit";
        !            68:     unsigned int    cMinCalls           = 1;
        !            69:     unsigned int    cMaxCalls           = 20;
        !            70:     unsigned int    fDontWait           = FALSE;
1.1       root       71:     int i;
                     72: 
1.1.1.3 ! root       73:     /* allow the user to override settings with command line switches */
1.1       root       74:     for (i = 1; i < argc; i++) {
1.1.1.3 ! root       75:         if ((*argv[i] == '-') || (*argv[i] == '/')) {
        !            76:             switch (tolower(*(argv[i]+1))) {
        !            77:             case 'p':  // protocol sequence
        !            78:                 pszProtocolSequence = argv[++i];
        !            79:                 break;
        !            80:             case 'e':
        !            81:                 pszEndpoint = argv[++i];
        !            82:                 break;
        !            83:             case 'm':
        !            84:                 cMaxCalls = (unsigned int) atoi(argv[++i]);
        !            85:                 break;
        !            86:             case 'n':
        !            87:                 cMinCalls = (unsigned int) atoi(argv[++i]);
        !            88:                 break;
        !            89:             case 'f':
        !            90:                 fDontWait = (unsigned int) atoi(argv[++i]);
        !            91:                 break;
        !            92:             case 'h':
        !            93:             case '?':
        !            94:             default:
        !            95:                 Usage(argv[0]);
        !            96:             }
        !            97:         }
        !            98:         else
        !            99:             Usage(argv[0]);
1.1       root      100:     }
                    101: 
                    102:     status = RpcServerUseProtseqEp(pszProtocolSequence,
1.1.1.3 ! root      103:                                    cMaxCalls,  
1.1       root      104:                                    pszEndpoint,
1.1.1.3 ! root      105:                                    pszSecurity);  // Security descriptor
1.1       root      106:     printf("RpcServerUseProtseqEp returned 0x%x\n", status);
                    107:     if (status) {
1.1.1.3 ! root      108:         exit(status);
1.1       root      109:     }
                    110: 
1.1.1.3 ! root      111:     status = RpcServerRegisterIf(xmit_ServerIfHandle,  // interface to register
        !           112:                                  NULL,   // MgrTypeUuid
        !           113:                                  NULL);  // MgrEpv; null means use default
1.1       root      114:     printf("RpcServerRegisterIf returned 0x%x\n", status);
                    115:     if (status) {
1.1.1.3 ! root      116:         exit(status);
1.1       root      117:     }
                    118: 
                    119:     printf("Calling RpcServerListen\n");
1.1.1.2   root      120:     status = RpcServerListen(cMinCalls,
1.1.1.3 ! root      121:                              cMaxCalls,
        !           122:                              fDontWait);
1.1       root      123:     printf("RpcServerListen returned: 0x%x\n", status);
                    124:     if (status) {
1.1.1.3 ! root      125:         exit(status);
1.1.1.2   root      126:     }
                    127: 
                    128:     if (fDontWait) {
1.1.1.3 ! root      129:         printf("Calling RpcMgmtWaitServerListen\n");
        !           130:         status = RpcMgmtWaitServerListen();  //  wait operation
        !           131:         printf("RpcMgmtWaitServerListen returned: 0x%x\n", status);
        !           132:         if (status) {
        !           133:             exit(status);
        !           134:         }
1.1       root      135:     }
                    136: 
1.1.1.3 ! root      137: }  // end main() 
1.1.1.2   root      138: 
1.1.1.3 ! root      139: /* end file xmits.c */

unix.superglobalmegacorp.com

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