Annotation of 43BSDReno/sys/nfs/TEST/billboard/src/billboard_rpc.c, revision 1.1

1.1     ! root        1: /*
        !             2:  ******************************************************************************
        !             3:  *
        !             4:  * Module: billboard_rpc.c
        !             5:  *
        !             6:  * Description: billboard_rpc.c
        !             7:  *             Conatins routines that handle RPC calls.
        !             8:  *
        !             9:  * Functions:
        !            10:  *     bb_call_rpc(func_p, arg_p)
        !            11:  *     _get_handle()
        !            12:  *
        !            13:  * Notes:
        !            14:  *
        !            15:  ******************************************************************************
        !            16:  */
        !            17: /*
        !            18:  ******************************************************************************
        !            19:  * Include Files
        !            20:  ******************************************************************************
        !            21:  */
        !            22: #include <stdio.h>
        !            23: #include <rpc/rpc.h>
        !            24: #include "common.h"
        !            25: #include "protocol.h"
        !            26: 
        !            27: 
        !            28: /*
        !            29:  ******************************************************************************
        !            30:  * Manifest Constants
        !            31:  ******************************************************************************
        !            32:  */
        !            33: #define        _SERVER_NAME            "BB_SERVER"     /* environment variable to
        !            34:                                                   set the billboard server 
        !            35:                                                   name */
        !            36: #define        _SERVER_NAME_LEN        64
        !            37: 
        !            38: /*
        !            39:  ******************************************************************************
        !            40:  * Global Declarations
        !            41:  ******************************************************************************
        !            42:  */
        !            43: CLIENT *client_handle_p;               /* request client handle */
        !            44: char   server_name[_SERVER_NAME_LEN];  /* name of the billboard server */
        !            45: 
        !            46: /*
        !            47:  ******************************************************************************
        !            48:  * Function Declarations
        !            49:  ******************************************************************************
        !            50:  */
        !            51: static CLIENT  *_get_handle();
        !            52: char           *bb_call_rpc();
        !            53: 
        !            54: /*
        !            55:  ******************************************************************************
        !            56:  *
        !            57:  * Function: bb_call_rpc
        !            58:  *
        !            59:  * Description:
        !            60:  *     Gets client handle and does the remote procedure call.
        !            61:  *
        !            62:  * Input:
        !            63:  *     func_p -- address of remote procedure 
        !            64:  *     arg_p -- input arguments to the remote procedure
        !            65:  *
        !            66:  * Output:
        !            67:  *
        !            68:  * Returns:
        !            69:  *     result of the RPC call
        !            70:  *
        !            71:  * Side Effects:
        !            72:  *
        !            73:  * Notes:
        !            74:  *
        !            75:  ******************************************************************************
        !            76:  */
        !            77: char *
        !            78: bb_call_rpc(func_p, arg_p)
        !            79: char   *(*func_p)();
        !            80: char   *arg_p;
        !            81: {
        !            82: 
        !            83:        /*
        !            84:         * gets client handle
        !            85:         */
        !            86:        if (client_handle_p == NULL)
        !            87:                client_handle_p= _get_handle();
        !            88: 
        !            89:        /*
        !            90:         * do the RPC call
        !            91:         */
        !            92:        return((char *)(*func_p)(arg_p, client_handle_p));
        !            93: }
        !            94: 
        !            95: 
        !            96: /*
        !            97:  ******************************************************************************
        !            98:  *
        !            99:  * Function: _get_handle
        !           100:  *
        !           101:  * Description:
        !           102:  *     Gets client handle for the RPC call.
        !           103:  *     The server name may be specified in the environment      
        !           104:  *     variable BB_SERVER, otherwise, the user will be prompted 
        !           105:  *     for one.                                                
        !           106:  *
        !           107:  * Input:
        !           108:  *
        !           109:  * Output:
        !           110:  *
        !           111:  * Returns:
        !           112:  *     client handle
        !           113:  *
        !           114:  * Side Effects:
        !           115:  *
        !           116:  * Notes:
        !           117:  *
        !           118:  ******************************************************************************
        !           119:  */
        !           120: static
        !           121: CLIENT *
        !           122: _get_handle()
        !           123: {
        !           124: char   *server_p;
        !           125: char   buffer[BB_MAX_LINE_LEN];
        !           126: char   *getenv();
        !           127: CLIENT         *cl_handle_p;
        !           128: 
        !           129:        /*
        !           130:         * gets the server name from the environment variable, if not specified
        !           131:         * the user will be prompted
        !           132:         */
        !           133:        if ((server_p= getenv(_SERVER_NAME)) == NULL) {
        !           134:                printf("Server name: ");
        !           135:                gets(buffer);
        !           136:                sscanf(buffer, "%s", server_name);              
        !           137:        } else
        !           138:                strcpy(server_name, server_p);
        !           139: 
        !           140:        /*
        !           141:         * gets a client handle
        !           142:         */
        !           143:        if ((cl_handle_p= clnt_create(server_name, BILLBOARD_PROG, 
        !           144:                                        BILLBOARD_VERS, "tcp")) == NULL) {
        !           145:                clnt_pcreateerror(server_name);
        !           146:                exit(1);
        !           147:        }
        !           148: 
        !           149:        return(cl_handle_p);
        !           150: }
        !           151: 

unix.superglobalmegacorp.com

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