OSF DCE Application Development Guide--Core Components

Topics in RPC Application Development
{
if ((str_ptr = popen(cmd, "r")) == NULL)
return;
while ((n = fread(buffer, sizeof(char), \
SBUFFSIZE, str_ptr)) > 0)
{
(*(test_pipe->push))(test_pipe->state, buffer, n);
}
(*(test_pipe->push))(test_pipe->state, buffer, 0);
fclose(str_ptr);
}
/* Here’s another method: list an arbitrary directory
* This time, we buffer the directory names as null-
* terminated strings of various lengths. The client
* will need to provide formatting of the output stream,
* for example, by substituting a CR for each NULL byte.
*/
/*
if ((dir_ptr = opendir(cmd)) == NULL)
{
printf("Can’t open directory %s0, cmd);
return;
}
while ((directory = readdir(dir_ptr)) != NULL)
{
if (directory->d_ino == 0)
continue;
(*(test_pipe->push))(test_pipe->state, \
directory->d_name,
strlen(directory->d_name)+1);
}
(*(test_pipe->push))(test_pipe->state, \
directory->d_name, 0);
closedir(dir_ptr);
*/
*status = error_status_ok;
}
The stub enforces well-behaved pipe filling by the manager by raising exceptions as
necessary. After all in pipes have been drained completely, the out pipes must be
completely filled, in order.
The client code uses the same declarations as in the input pipe example, except that
instead of using a client_pull routine it uses a test_push routine that prints out the
contents of each received buffer:
/*
* Our push routine prints each received buffer-full.
124245 Tandem Computers Incorporated 16 29