dce/rpc "client" api

Peter Samuelson peter at cadcamlab.org
Fri Aug 18 05:11:12 GMT 2000


[Jerry Carter]
> Luke, if this goes into TNG and everyone agrees on it, I will merge
> it into rpcclient in HEAD.  I need to keep rpcclient working as it is
> through the next release (and for testing in the meantime)

As a non-developer with no vote, I like Luke's infrastructure here.  It
feels much cleaner than ad-hoc switch statements.

> 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;

> Since you need things like ip_addr and port number for a TCP
> connection and a destination netbios name for an SMB connection, you
> can either (1) put all in the information needed to represent all
> possible connection environments (very bad idea), or (2) return a
> struct* and the struct contains a void* (same as what you have now).
> Anyone have a good idea of how to do this better?

Well, there's the X Window System's XEvent union:

  typedef union _XEvent {
    int type;
    XAnyEvent xany;
    XKeyEvent xkey;
    /*   [maybe 20 more entries]   */
    long pad[24];
  } XEvent;

Each of the structures in the union begins with "int type", which is
used to determine which struct you're really dealing with.

Anyway a union ptr might be better than a void ptr, though I'm not
fully convinced.  Unions do get annoying and have to be well-defined at
compile time (which *could* be a problem if you end up going the dlopen
route, though I understand that's not on the table just yet).

Peter




More information about the samba-technical mailing list