OSF DCE Application Development Guide--Introduction and Style Guide
RPC Parameters
All the callback routines are placed in a single module that is linked with both client and
server (in this case, for the test interface). As an alternative, the appropriate callbacks
could be declared separately within the client and server modules:
/*
* test_xmit.c:
*
* The routines required to implement a [transmit_as] type.
*/
#include "test.h"
/* The to_xmit routine must allocate all space for the transmitted
* type. In general, the stubs have no way to determine how to allocate
* space for the transmitted type. Here, for example, the to_xmit
* routine determines the size of a conformant array.
*/
void sparse_array_t_to_xmit(sparse_array_t *s_array,
compact_array_t **c_array
)
{
unsigned32 i,j;
unsigned32 csize;
/* Count up the number of nonzero elements in the sparse array */
for (i = 0, csize = 0; i < S_ARRAY_SIZE; i++)
{
if ((*s_array)[i] != 0)
{
csize++;
}
}
/* Allocate a structure to hold the compact array */
*c_array = (compact_array_t *)calloc(csize*2 + 1, sizeof(unsigned32));
((compact_array_t)**c_array).size = csize;
/* Fill in the compact array from the nonzero elements */
for (i=0,j=0; i < S_ARRAY_SIZE; i++)
{
if ((*s_array)[i] != 0)
{
((compact_array_t)**c_array).array[j].value = (*s_array)[i];
((compact_array_t)**c_array).array[j++].subscript = i;
}
}
}
124246 Tandem Computers Incorporated 6− 27










