OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
You can also define a context handle within a type declaration as a forward reference to
a structure type by tag, as follows:
typedef [context_handle] struct opaque_struct * opaque_ch_t;
Note that you do not need to define the structure type in the IDL file; it is a forward
reference to a structure whose definition can be included into the server code, either from
a private .h file or from a server IDL file. As a result, the structure type is opaque to the
client. This method of defining a context handle provides type checking and permits the
server code to avoid extensive casting when manipulating the context handle.
A structure type in a context handle type definition must be referenced by tag name and
not by type name. So, for example, the first of the following declarations is valid, while
the second is not:
typedef [context_handle] struct struct_tag * valid_ch_t;
/* valid */
typedef [context_handle] struct_type * invalid_ch_t;
/* error */
The following example illustrates context handles defined as untyped pointers and as
pointers to structures by tag name.
/* A context handle implemented as untyped pointer */
typedef [context_handle] void * void_ch_t;
/* A context handle implemented as a */
/* pointer to a structure by tag name */
typedef [context_handle] struct opaque_struct * opaque_ch_t;
/* Operations using both types of context handles */
void ch_oper(
[in] void_ch_t v1,
[in,out] void_ch_t *v2,
[out] void_ch_t *v3,
[in] opaque_ch_t *o2,
[out] opaque_ch_t *o3
);
void_ch_t void_ch_oper ([in] handle_t h);
opaque_ch_t opaque_ch_oper([in] handle_t h);
It is possible to define a structure type in a context handle in the IDL file; for example,
the following structure definition can either precede or follow the definition of
valid_ch_t in the example previously shown:
typedef struct struct_tag {long l;} struct_type;
17 60 Tandem Computers Incorporated 124245