File:  [WindowsNT SDKs] / mstools / samples / rpc / data / xmit / xmitp.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:24:25 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntsdk-nov-1993, ntsdk-jul-1993, HEAD
Microsoft Windows NT Build 511 (SDK Final Release) 07-24-1993

/****************************************************************************
                   Microsoft RPC Version 1.0
                Copyright Microsoft Corp. 1992
                         xmit Example

    FILE:       xmitp.c
    
    PURPOSE:    Remote procedures that are linked with the server
                side of RPC distributed application
    
    FUNCTIONS:  ModifyListProc() - changes the doubly-linked list
                Shutdown() - shuts down the server side
    
    COMMENTS:   Related to xmits.c

****************************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include "xmit.h"    // header file generated by MIDL compiler


/****************************************************************************

Function:   ModifyListProc

Parameters: pFirst : Pointer to the head of a doubly-linked list.

Returns:    none

Purpose:    Display the list passed to the function.
            For each element in the list, add another element.
            Display the modified list.

Comments:   This sample is meant to demonstrate a typical use of the
            transmit_as attribute:  A complex data structure is simplified
            for transmission over the network, restored on the server,
            then manipulated by the remote function on the server.
            The modified data is returned to the client.

            Calls InsertNewNode(param1, param2), a utility routine
            in xmits.c that creates a new node, assigns to it the
            value param1, and inserts it into the list after param2.

****************************************************************************/

DOUBLE_LINK_TYPE * InsertNewNode(short sValue, DOUBLE_LINK_TYPE * pPrevious);

void ModifyListProc(DOUBLE_LINK_TYPE * pFirst)
{
    DOUBLE_LINK_TYPE * pList = pFirst; 
    short newNumber;
    
    printf("ModifyListProc: Display contents of doubly linked list:\n");
    while (pList != NULL) {
         printf("pList @0x%x = %d, Next = 0x%x\n", 
                pList, pList->sNumber, pList->pNext);
         pList = pList->pNext;
    }

    printf("ModifyListProc: Add one node for every node in tree\n");
    for (pList = pFirst; pList != NULL; pList = pList->pNext) {
        newNumber = pList->sNumber + 1;
        pList = InsertNewNode(newNumber, pList);
    }

    printf("ModifyListProc: Display modified contents of doubly linked list:\n");
    for (pList = pFirst; pList != NULL; pList = pList->pNext) {
        printf("pList @0x%x = %d, Next = 0x%x\n", 
               pList, pList->sNumber, pList->pNext);
    }
}


/****************************************************************************

Function:   Shutdown

Parameters: none

Returns:    none

Purpose:    Make the server stop listening for client applications.

Comments:   The two NULL parameters passed to RpcServerUnregisterIf are
            a show of brute force:  they tell the function to turn
            off all registered interfaces.  See the RPC API function
            reference for more information about these functions.

****************************************************************************/

void Shutdown(void)
{
    RPC_STATUS status;

    printf("Calling RpcMgmtStopServerListening\n");
    status = RpcMgmtStopServerListening(NULL);
    printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
    if (status) {
        exit(status);
    }

    printf("Calling RpcServerUnregisterIf\n");
    status = RpcServerUnregisterIf(NULL, NULL, FALSE);
    printf("RpcServerUnregisterIf returned 0x%x\n", status);
    if (status) {
        exit(status);
    }
}

/* end file xmitp.c */

unix.superglobalmegacorp.com

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