cli_NetSessionEnum with additional parameter

seanmkim at aim.com seanmkim at aim.com
Wed Jan 31 23:22:14 GMT 2007


 Hello,
 
 I was wondering why some of functions in clirap2.c have "void *state" as the last parameter
 to be passed to their callback functions and others don't. I find it very useful when you need to
 have another callback function that uses results you get from executions of these functions.
 
 I had this kind of need in cli_NetSessionEnum function calls but it didn't allow me to do so
 unlike other functios such as cli_NetGroupGetUsers.
 So I created another function, cli_NetSessionEnum2 which is pretty much the same as cli_NetSessionEnum
 except for that it has one more parameter for itself and the callback function and it passes it to its callback function.
 
 
 int cli_NetSessionEnum2(struct cli_state *cli, void (*fn)(char *, char *, uint16, uint16, uint16, uint, uint, uint, char *, void *), void *state)
 ...
 ...
 ... 
 if (rdata) {
 if (res == 0 || res == ERRmoredata) {
 int i, converter, count;
 
 p = rparam + WORDSIZE;
 GETWORD(p, converter);
 GETWORD(p, count);
 
 for (i=0,p=rdata;i<count;i++) {
 pstring wsname, username, clitype_name;
 uint16 num_conns, num_opens, num_users;
 unsigned int sess_time, idle_time, user_flags;
 
 GETSTRINGP(p, wsname, rdata, converter);
 GETSTRINGP(p, username, rdata, converter);
 GETWORD(p, num_conns);
 GETWORD(p, num_opens);
 GETWORD(p, num_users);
 GETDWORD(p, sess_time);
 GETDWORD(p, idle_time);
 GETDWORD(p, user_flags);
 GETSTRINGP(p, clitype_name, rdata, converter);
 
 fn(wsname, username, num_conns, num_opens, num_users, sess_time,
 idle_time, user_flags, clitype_name, state);
 }
 
 } else {
 DEBUG(4,("NetSessionEnum2 res=%d\n", res));
 }
 } else {
 DEBUG(4,("NetSessionEnum2 no data returned\n"));
 }
 ...
 ...
 ...
 
 It will be nice to have this in the next release. I just thought I would share.
 
 Thanks,
    
 Sean(a.k.a. Minsung) Kim 
________________________________________________________________________
Check Out the new free AIM(R) Mail -- 2 GB of storage and industry-leading spam and email virus protection.


More information about the samba-technical mailing list