OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
handle_t binding_h,
test_pipe_t test_pipe,
error_status_t *status
)
{
char buffer[SBUFFSIZE];
int count;
char *cptr;
do
{
(*(test_pipe.pull))(test_pipe.state, buffer, \
SBUFFSIZE, &count);
for (cptr = buffer; cptr < buffer + count; cptr++)
putchar(*cptr);
} while (count > 0);
}
Using the buffer supplied by the manager, the test_pipe.pull routine unmarshals an
amount of data that is nonzero, but not more than the buffer can hold. There is no
guarantee that the buffer will be filled. The actual amount of data in the buffer is
indicated by the count parameter returned in the test_pipe.pull routine. This count
equals the number of test_pipe_t data elements in the buffer.
The test_pipe.pull routine signals the end of data in the pipe by returning a chunk whose
count is 0 (zero). Any attempt to pull data from the pipe after the zero-length chunk has
been encountered will cause an exception to be raised. The in pipes must be processed
in the order in which they occur in the operation signature. Attempting to pull data from
an in pipe before end-of-data on any preceding in pipe has been encountered will result
in an exception being raised. If the manager code attempts to write to an out pipe or
return control to the server stub before end-of-data has been encountered on the last in
pipe, an exception will be raised. (Note that there is no guarantee that chunks seen by
the manager will match the chunks supplied by the client’s pull routine.)
The client application code must supply pull and alloc routines and a pipe state. These
routines must work together to produce a sequence of pointers to chunks, of which only
the last is empty. In the following example, the client code provides a test_pipe.pull
routine that reads chunks of the input file into a buffer and returns a count of the chunk
size, returning a zero count when the end of the file is reached. The pipe state block is
used here simply as a convenient way to make the file state available to the pull routine.
Applications need not make any use of the pipe state.
/* Client declares types and routines */
typedef struct client_pipe_state_t {
idl_char *filename;
idl_boolean file_open;
int file_handle;
} client_pipe_state_t;
client_pipe_state_t client_in_pipe_state = {false, 0};
void client_pull(state,buf,esize,ecount)
16 − 26 Tandem Computers Incorporated 124245