diff options
author | Andrew Tridgell <tridge@samba.org> | 1997-10-26 07:32:02 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1997-10-26 07:32:02 +0000 |
commit | 4bf5c03b18f88b566f3ac12cc4b3a9c5c96fd35d (patch) | |
tree | 9864b22eaffe3f177b48b560361a5058aa56130f /source/libsmb/clientgen.c | |
parent | 1b17455066098104b9b0907a58195328c6467d71 (diff) | |
download | samba-4bf5c03b18f88b566f3ac12cc4b3a9c5c96fd35d.tar.gz |
The browse synchronisation code in nmbsync.c now uses the clientgen.c
code, which means we don't have to link with a fake getpass routine
and we don't have a whole pile of global variables that really have
nothing to do with nmbd and were there to keep the client code happy.
The code should function identically to what it did before (hopefully
it was correct)
The only thing that now uses the horrible clientutil.c code is
smbclient.
Diffstat (limited to 'source/libsmb/clientgen.c')
-rw-r--r-- | source/libsmb/clientgen.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c index 7cd2ef69036..b6ad1611ace 100644 --- a/source/libsmb/clientgen.c +++ b/source/libsmb/clientgen.c @@ -313,6 +313,79 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) } +/**************************************************************************** +call a NetServerEnum for the specified workgroup and servertype mask. +This function then calls the specified callback function for each name returned. + +The callback function takes 3 arguments: the machine name, the server type and +the comment. +****************************************************************************/ +BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, + void (*fn)(char *, uint32, char *)) +{ + char *rparam = NULL; + char *rdata = NULL; + int rdrcnt,rprcnt; + char *p; + pstring param; + int uLevel = 1; + int count = -1; + + /* send a SMBtrans command with api NetServerEnum */ + p = param; + SSVAL(p,0,0x68); /* api number */ + p += 2; + strcpy(p,"WrLehDz"); + p = skip_string(p,1); + + strcpy(p,"B16BBDz"); + + p = skip_string(p,1); + SSVAL(p,0,uLevel); + SSVAL(p,2,BUFFER_SIZE); + p += 4; + SIVAL(p,0,stype); + p += 4; + + pstrcpy(p, workgroup); + p = skip_string(p,1); + + if (cli_api(cli, + PTR_DIFF(p,param), /* param count */ + 8, /*data count */ + 0, /* mprcount */ + BUFFER_SIZE, /* mdrcount */ + &rprcnt,&rdrcnt, + param, NULL, + &rparam,&rdata)) { + int res = SVAL(rparam,0); + int converter=SVAL(rparam,2); + int i; + + if (res == 0) { + count=SVAL(rparam,4); + p = rdata; + + for (i = 0;i < count;i++, p += 26) { + char *sname = p; + int comment_offset = IVAL(p,22) & 0xFFFF; + char *cmnt = comment_offset?(rdata+comment_offset-converter):""; + + stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; + + fn(sname, stype, cmnt); + } + } + } + + if (rparam) free(rparam); + if (rdata) free(rdata); + + return(count > 0); +} + + + static struct { int prot; |