libmsrpc for Samba 3

derrell at derrell at
Wed Jul 20 13:54:03 GMT 2005

"Gerald (Jerry) Carter" <jerry at> writes:

> In Samba 3, I have this:
> WERROR cli_spoolss_open_printer_ex( struct cli_state *cli, ....)
> {
> 	....
> ~        make_spoolss_q_open_printer_ex( &in, printername, datatype,
> 		access_required, station, username );
> 	            in, out,
> 	            qbuf, rbuf,
> 	            spoolss_io_q_open_printer_ex,
> 	            spoolss_io_r_open_printer_ex,
> 	            WERR_GENERAL_FAILURE );
> 	memcpy( pol, &out.handle, sizeof(POLICY_HND) );
> 	return out.status;
> }
> The make_spoolss_q_open_printer_ex() call does what you
> do by assigning the structure elements necessary for
> the outgoing call.  So what you call the client interface
> the the CLI_DO_RPC macro I've used above.
> This is the cooresponding code from Samba 4:
>       = talloc_asprintf(ctx,
> 				  "\\\\%s",
> 				  dcerpc_server_name(ctx->p));
>          = NULL;
>       = 0;
> 	op.out.handle           = &ctx->server_handle;
> 	status = dcerpc_spoolss_OpenPrinter(ctx->p, ctx, &op);
> What I'm still considering is whether or not this
> low level API is really best for application writers.
> I'm just not totally convinced yet, but am still thinking
> about it.  Parts of it I like but parts of it I'm still
> pondering.  At least now I do know that I understand your
> original suggestion.

Having spent many, many years working with networking protocol software, I
have encountered and worked with both methods many times.  I refer to the
Samba 4 method as "control block" in that one passes a control block structure
to each function rather than numerous parameters.  I have found the control
block method to be *far* easier to work with.  When I've worked with the
parameter method, I would often end up putting a comment next to each
parameter (so that it ends up looking like the control block method anyway)
just to keep myself sane.  I've found that it's just too hard to keep track of
what each parameter is otherwise.

I'd definitely vote for using control blocks rather than numerous parameters.



More information about the samba-technical mailing list