Annotation of mstools/samples/rpc/whello/whellos.c, revision 1.1

1.1     ! root        1: /****************************************************************************
        !             2:                          Microsoft RPC Version 1.0
        !             3:                         Copyright Microsoft Corp. 1992
        !             4:                                whello Example
        !             5: 
        !             6:     FILE:      whellos.c
        !             7:     USAGE:      server
        !             8:     PURPOSE:   Server side of RPC distributed application whello
        !             9:     FUNCTIONS:  main() - registers server as RPC server
        !            10:     COMMENTS:
        !            11:     This distributed application prints "hello, world" on the server.
        !            12:     This version features a client that manages its connection to
        !            13:     the server. It uses the binding handle whello_IfHandle that is defined
        !            14:     in the generated header file whello.h.
        !            15: ****************************************************************************/
        !            16: #include <stdlib.h>
        !            17: #include <windows.h>
        !            18: #include <string.h>
        !            19: #include <stdio.h>
        !            20: #include <ctype.h>
        !            21: #include <rpc.h>    // RPC data structures and APIs
        !            22: #include "whello.h"    // header file generated by MIDL compiler
        !            23: 
        !            24: void Usage(char * pszProgramName)
        !            25: {
        !            26:     fprintf(stderr, "Usage:  %s\n", pszProgramName);
        !            27:     fprintf(stderr, " -p protocol_sequence\n");
        !            28:     fprintf(stderr, " -n network_address\n");
        !            29:     fprintf(stderr, " -e endpoint\n");
        !            30:     fprintf(stderr, " -o options\n");
        !            31:     fprintf(stderr, " -u uuid\n");
        !            32:     exit(1);
        !            33: }
        !            34: 
        !            35: void main(int argc, char * argv[])
        !            36: {
        !            37:     RPC_STATUS status;
        !            38:     unsigned char * pszUuid = "12345678-1234-1234-1234-123456789ABC";
        !            39:     unsigned char * pszProtocolSequence = "ncacn_np";
        !            40:     unsigned char * pszNetworkAddress   = NULL;
        !            41:     unsigned char * pszEndpoint        = "\\pipe\\whello";
        !            42:     unsigned char * pszOptions          = NULL;
        !            43:     unsigned char * pszStringBinding    = NULL;
        !            44:     int i;
        !            45: 
        !            46:     // allow the user to override settings with command line switches
        !            47:     for (i = 1; i < argc; i++) {
        !            48:        if ((*argv[i] == '-') || (*argv[i] == '/')) {
        !            49:            switch (tolower(*(argv[i]+1))) {
        !            50:                case 'p':  // protocol sequence
        !            51:                    pszProtocolSequence = argv[++i];
        !            52:                    break;
        !            53:                case 'n':  // network address
        !            54:                    pszNetworkAddress = argv[++i];
        !            55:                    break;
        !            56:                case 'e':
        !            57:                    pszEndpoint = argv[++i];
        !            58:                    break;
        !            59:                case 'o':
        !            60:                    pszOptions = argv[++i];
        !            61:                    break;
        !            62:                case 'u':
        !            63:                    pszUuid = argv[++i];
        !            64:                    break;
        !            65:                case 'h':
        !            66:                case '?':
        !            67:                default:
        !            68:                    Usage(argv[0]);
        !            69:            }
        !            70:        }
        !            71:        else
        !            72:            Usage(argv[0]);
        !            73:     }
        !            74: 
        !            75:     status = RpcServerUseProtseqEp(pszProtocolSequence,
        !            76:                                    1, // maximum concurrent calls
        !            77:                                    pszEndpoint,
        !            78:                                   0);
        !            79:     printf("RpcServerUseProtseqEp returned 0x%x\n", status);
        !            80:     if (status) {
        !            81:         exit(2);
        !            82:     }
        !            83: 
        !            84:     status = RpcServerRegisterIf(whello_ServerIfHandle, 0, 0);
        !            85:     printf("RpcServerRegisterIf returned 0x%x\n", status);
        !            86:     if (status) {
        !            87:         exit(2);
        !            88:     }
        !            89: 
        !            90:     printf("Calling RpcServerListen\n");
        !            91:     status = RpcServerListen(1,
        !            92:                             200);
        !            93:     printf("RpcServerListen returned: 0x%x\n", status);
        !            94:     if (status) {
        !            95:         exit(2);
        !            96:     }
        !            97: 
        !            98: } /* end main() */
        !            99: 
        !           100: // ====================================================================
        !           101: //                MIDL allocate and free
        !           102: // ====================================================================
        !           103: 
        !           104: 
        !           105: void * MIDL_user_allocate(size_t len)
        !           106: {
        !           107:     return(malloc(len));
        !           108: }
        !           109: 
        !           110: void MIDL_user_free(void * ptr)
        !           111: {
        !           112:     free(ptr);
        !           113: }
        !           114: 
        !           115: /* end whello\server.c */
        !           116: 

unix.superglobalmegacorp.com

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