version 1.78, 2013/03/22 15:54:29 |
version 1.79, 2013/03/24 09:27:20 |
|
|
|
|
/* Find the target client or report an error and return NULL. */ |
/* Find the target client or report an error and return NULL. */ |
struct client * |
struct client * |
cmd_find_client(struct cmd_ctx *ctx, const char *arg) |
cmd_find_client(struct cmd_ctx *ctx, const char *arg, int quiet) |
{ |
{ |
struct client *c; |
struct client *c; |
char *tmparg; |
char *tmparg; |
size_t arglen; |
size_t arglen; |
|
|
/* A NULL argument means the current client. */ |
/* A NULL argument means the current client. */ |
if (arg == NULL) |
if (arg == NULL) { |
return (cmd_current_client(ctx)); |
c = cmd_current_client(ctx); |
|
if (c == NULL && !quiet) |
|
ctx->error(ctx, "no clients"); |
|
return (c); |
|
} |
tmparg = xstrdup(arg); |
tmparg = xstrdup(arg); |
|
|
/* Trim a single trailing colon if any. */ |
/* Trim a single trailing colon if any. */ |
|
|
c = cmd_lookup_client(tmparg); |
c = cmd_lookup_client(tmparg); |
|
|
/* If no client found, report an error. */ |
/* If no client found, report an error. */ |
if (c == NULL) |
if (c == NULL && !quiet) |
ctx->error(ctx, "client not found: %s", tmparg); |
ctx->error(ctx, "client not found: %s", tmparg); |
|
|
free(tmparg); |
free(tmparg); |