dce/rpc "client" api
Elrond
elrond at samba.org
Fri Aug 18 08:33:54 GMT 2000
On Fri, Aug 18, 2000 at 12:11:12AM -0500, Peter Samuelson wrote:
[...]
> > I think the void* return value is the only way to generically pass
> > back information from the functions unless they all share a state
> > information for representing a connection.
>
> void* is horrible for documentation and readability, unfortunately. It
> gives no clue as to what is supposed to be behind the pointer. Yes,
> it's supposed to be opaque, but you could still typedef it:
>
> typedef void* rpcconnstate;
The other way is the one, that Gtk+ uses. It's a nice
thing. (At least I like it).
struct _GtkObject
{
/* This is a pointer to the function table */
GtkObjectClass *klass;
/* other basic stuff */
/* reference count.
* refer to the file docs/refcounting.txt on this issue.
*/
guint ref_count;
};
typedef struct _GtkObject GtkObject;
(next one modified to show stuff)
struct _GtkAdjustment
{
GtkObject object;
gfloat lower;
gfloat upper;
gfloat value;
gfloat step_increment;
gfloat page_increment;
gfloat page_size;
};
struct _GtkAdjustmentClass
{
GtkObjectClass parent_class;
void (* changed) (GtkAdjustment *adjustment);
void (* value_changed) (GtkAdjustment *adjustment);
};
I think, this is one of the nicest ways of doing OO in C.
Gtk+ also has a lot of tools to do the Casts and verify the
casts are done in the right way (casting a GtkAdjustment to
a GtkObject is fine, the other way round gets you a big
warning)
So what I would propose:
There's only one public function for each transport, the
connect function, it returns a pointer to a struct, that
mainly contains a pointer to your function table
(cli_connect_fns).
You can then have a nice wrapper
void cli_connection_free(cli_rpc_info *con)
{
if (con->cli_connect_fns->cli_connection_free)
con->cli_connect_fns->cli_connection_free(con);
DEBUG(0, ("..."));
}
Just another way of doing it.
Elrond
More information about the samba-technical
mailing list