summaryrefslogtreecommitdiff
path: root/source3/utils/net_rpc_shell.c
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-05-09 23:22:12 +0200
committerKai Blin <kai@samba.org>2008-05-10 09:22:27 +0200
commitf5769109447d8da0f09b102d444a816ad97a00dc (patch)
treefe7b470486ace083b3f48a54334a3db0bb9633d2 /source3/utils/net_rpc_shell.c
parent378527215e663c0c9d36c565a16723e0a1979ea0 (diff)
downloadsamba-f5769109447d8da0f09b102d444a816ad97a00dc.tar.gz
samba-f5769109447d8da0f09b102d444a816ad97a00dc.tar.bz2
samba-f5769109447d8da0f09b102d444a816ad97a00dc.zip
net: Remove globals
(This used to be commit 1e9319cf88b65a2a8d4f5099a1fe5297e405ed2e)
Diffstat (limited to 'source3/utils/net_rpc_shell.c')
-rw-r--r--source3/utils/net_rpc_shell.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c
index 7bd726e614..bfdfd4bf64 100644
--- a/source3/utils/net_rpc_shell.c
+++ b/source3/utils/net_rpc_shell.c
@@ -21,11 +21,12 @@
#include "includes.h"
#include "utils/net.h"
-static NTSTATUS rpc_sh_info(TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
+static NTSTATUS rpc_sh_info(struct net_context *c,
+ TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
struct rpc_pipe_client *pipe_hnd,
int argc, const char **argv)
{
- return rpc_info_internals(ctx->domain_sid, ctx->domain_name,
+ return rpc_info_internals(c, ctx->domain_sid, ctx->domain_name,
ctx->cli, pipe_hnd, mem_ctx,
argc, argv);
}
@@ -63,7 +64,8 @@ static char **completion_fn(const char *text, int start, int end)
return cmds;
}
-static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
+static NTSTATUS net_sh_run(struct net_context *c,
+ struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
int argc, const char **argv)
{
TALLOC_CTX *mem_ctx;
@@ -83,7 +85,7 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
return status;
}
- status = cmd->fn(mem_ctx, ctx, pipe_hnd, argc, argv);
+ status = cmd->fn(c, mem_ctx, ctx, pipe_hnd, argc, argv);
TALLOC_FREE(pipe_hnd);
@@ -92,10 +94,11 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
return status;
}
-static bool net_sh_process(struct rpc_sh_ctx *ctx,
+static bool net_sh_process(struct net_context *c,
+ struct rpc_sh_ctx *ctx,
int argc, const char **argv)
{
- struct rpc_sh_cmd *c;
+ struct rpc_sh_cmd *cmd;
struct rpc_sh_ctx *new_ctx;
NTSTATUS status;
@@ -120,22 +123,22 @@ static bool net_sh_process(struct rpc_sh_ctx *ctx,
}
if (strequal(argv[0], "help") || strequal(argv[0], "?")) {
- for (c = ctx->cmds; c->name != NULL; c++) {
+ for (cmd = ctx->cmds; cmd->name != NULL; cmd++) {
if (ctx != this_ctx) {
d_printf("%s ", ctx->whoami);
}
- d_printf("%-15s %s\n", c->name, c->help);
+ d_printf("%-15s %s\n", cmd->name, cmd->help);
}
return True;
}
- for (c = ctx->cmds; c->name != NULL; c++) {
- if (strequal(c->name, argv[0])) {
+ for (cmd = ctx->cmds; cmd->name != NULL; cmd++) {
+ if (strequal(cmd->name, argv[0])) {
break;
}
}
- if (c->name == NULL) {
+ if (cmd->name == NULL) {
/* None found */
d_fprintf(stderr, "%s: unknown cmd\n", argv[0]);
return True;
@@ -148,11 +151,11 @@ static bool net_sh_process(struct rpc_sh_ctx *ctx,
}
new_ctx->cli = ctx->cli;
new_ctx->whoami = talloc_asprintf(new_ctx, "%s %s",
- ctx->whoami, c->name);
- new_ctx->thiscmd = talloc_strdup(new_ctx, c->name);
+ ctx->whoami, cmd->name);
+ new_ctx->thiscmd = talloc_strdup(new_ctx, cmd->name);
- if (c->sub != NULL) {
- new_ctx->cmds = c->sub(new_ctx, ctx);
+ if (cmd->sub != NULL) {
+ new_ctx->cmds = cmd->sub(c, new_ctx, ctx);
} else {
new_ctx->cmds = NULL;
}
@@ -164,15 +167,15 @@ static bool net_sh_process(struct rpc_sh_ctx *ctx,
argc -= 1;
argv += 1;
- if (c->sub != NULL) {
+ if (cmd->sub != NULL) {
if (argc == 0) {
this_ctx = new_ctx;
return True;
}
- return net_sh_process(new_ctx, argc, argv);
+ return net_sh_process(c, new_ctx, argc, argv);
}
- status = net_sh_run(new_ctx, c, argc, argv);
+ status = net_sh_run(c, new_ctx, cmd, argc, argv);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "%s failed: %s\n", new_ctx->whoami,
@@ -202,7 +205,7 @@ static struct rpc_sh_cmd sh_cmds[6] = {
{ NULL, NULL, 0, NULL, NULL }
};
-int net_rpc_shell(int argc, const char **argv)
+int net_rpc_shell(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
struct rpc_sh_ctx *ctx;
@@ -218,7 +221,7 @@ int net_rpc_shell(int argc, const char **argv)
return -1;
}
- status = net_make_ipc_connection(0, &(ctx->cli));
+ status = net_make_ipc_connection(c, 0, &(ctx->cli));
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "Could not open connection: %s\n",
nt_errstr(status));
@@ -269,7 +272,7 @@ int net_rpc_shell(int argc, const char **argv)
}
if ((line[0] != '\n') &&
- (!net_sh_process(this_ctx, argc, argv))) {
+ (!net_sh_process(c, this_ctx, argc, argv))) {
SAFE_FREE(line);
break;
}