OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
A manager routine that returns a context handle as an out parameter declares it as
my_handle_t *h;
The routine then sets the value of the handle as follows:
*h = &context_data;
A routine that refers to a context handle as an in parameter declares it as
my_handle_t h;
and dereferences the handle as follows:
context_data = (my_handle_t*)h;
For the in,out case, the routine uses the same declaration as in the out case, and
dereferences the handle as follows:
context_data = (my_handle_t*)*h;
The following extensive example shows a simple use of context handles. In the sample
code, the client requests a unit of storage from the server, using the store_open( ) call,
and receives a handle to the allocated storage. The store_read(), store_write(), and
store_set_ptr() routines allow the client to read from and write to specific locations in
the allocated storage. The store_close( ) routine releases the server resources.
16.3.1 Context Handles in the Interface
The .idl file declarations for the store interface are as follows:
/*
* store.idl
* A sample interface that demonstrates server maintained context.
* The client requests temporary storage of a specified size,
* and the server returns a handle that can be used to read and
* write to storage. The interface doesn’t care how the
* server implements the storage.
*/
[
uuid(0019b8c5-e8b5-1c84-9a41-0000c0d4de56),
pointer_default(ref),
version(1.0)
]
interface store
{
/* A context handle used to access remote storage: */
typedef [context_handle] void* store_handle_t;
16 − 12 Tandem Computers Incorporated 124245