diff options
author | Gerald Carter <jerry@samba.org> | 2000-07-03 04:28:29 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2000-07-03 04:28:29 +0000 |
commit | 33f6a1d9bb7ffed681085261a78d5ef4297f73de (patch) | |
tree | 378dd3cb3e7d5993def55602686ab994f78a2f00 /source3/rpc_client/ncalrpc_l_use.c | |
parent | 8d429db41075618372b6a18e7d4eb064f7839467 (diff) | |
download | samba-33f6a1d9bb7ffed681085261a78d5ef4297f73de.tar.gz samba-33f6a1d9bb7ffed681085261a78d5ef4297f73de.tar.bz2 samba-33f6a1d9bb7ffed681085261a78d5ef4297f73de.zip |
first pass at merging rpcclient from TNG to HEAD. You can get a
semi-connection and a rpcclient prompt, but no functionality there yet.
Will be a few more days on that.
--jerry
(This used to be commit 269051aa0c52728278a1d290148564f11cf7f189)
Diffstat (limited to 'source3/rpc_client/ncalrpc_l_use.c')
-rw-r--r-- | source3/rpc_client/ncalrpc_l_use.c | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/source3/rpc_client/ncalrpc_l_use.c b/source3/rpc_client/ncalrpc_l_use.c new file mode 100644 index 0000000000..81ade8e1a6 --- /dev/null +++ b/source3/rpc_client/ncalrpc_l_use.c @@ -0,0 +1,127 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + SMB client generic functions + Copyright (C) Andrew Tridgell 1994-1999 + Copyright (C) Luke Kenneth Casson Leighton 1996-1999 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#define NO_SYSLOG + +#include "includes.h" +#include "rpc_parse.h" + +extern int DEBUGLEVEL; + +struct ncalrpc_use +{ + struct msrpc_local *cli; + uint32 num_users; +}; + +static struct ncalrpc_use **clis = NULL; +static uint32 num_clis = 0; + +/**************************************************************************** +terminate client connection +****************************************************************************/ +static void ncalrpc_use_free(struct ncalrpc_use *cli) +{ + if (cli->cli != NULL) + { + if (cli->cli->initialised) + { + ncalrpc_l_shutdown(cli->cli); + } + free(cli->cli); + } + + free(cli); +} + +/**************************************************************************** +delete a client state +****************************************************************************/ +BOOL ncalrpc_l_use_del(const char *pipe_name, + const vuser_key * key, + BOOL force_close, BOOL *connection_closed) +{ + int i; + + if (strnequal("\\PIPE\\", pipe_name, 6)) + { + pipe_name = &pipe_name[6]; + } + + DEBUG(10, ("ncalrpc_l_use_del: %s. [%d,%x] force close: %s\n", + pipe_name, key->pid, key->vuid, BOOLSTR(force_close))); + + if (connection_closed != NULL) + { + *connection_closed = False; + } + + for (i = 0; i < num_clis; i++) + { + char *ncalrpc_name = NULL; + + if (clis[i] == NULL) + continue; + if (clis[i]->cli == NULL) + continue; + + ncalrpc_name = clis[i]->cli->pipe_name; + + if (strnequal("\\PIPE\\", pipe_name, 6)) + { + ncalrpc_name = &ncalrpc_name[6]; + } + + DEBUG(10, ("connection: %s [%d,%x]", ncalrpc_name, + clis[i]->cli->nt.key.pid, + clis[i]->cli->nt.key.vuid)); + + if (!strequal(ncalrpc_name, pipe_name)) + continue; + + if (key->pid != clis[i]->cli->nt.key.pid || + key->vuid != clis[i]->cli->nt.key.vuid) + { + continue; + } + /* decrement number of users */ + clis[i]->num_users--; + + DEBUG(10, ("idx: %i num_users now: %d\n", + i, clis[i]->num_users)); + + if (force_close || clis[i]->num_users == 0) + { + ncalrpc_use_free(clis[i]); + clis[i] = NULL; + if (connection_closed != NULL) + { + *connection_closed = True; + } + } + return True; + } + + return False; +} + + |