mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Use option print function for info messages as well.
This commit is contained in:
parent
e3c3d746f7
commit
6b37b2d79d
@ -67,6 +67,7 @@ void
|
|||||||
set_option_string(struct cmd_ctx *ctx, struct options *oo,
|
set_option_string(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value, int append)
|
const struct set_option_entry *entry, char *value, int append)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
char *oldvalue, *newvalue;
|
char *oldvalue, *newvalue;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
@ -80,8 +81,9 @@ set_option_string(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
} else
|
} else
|
||||||
newvalue = value;
|
newvalue = value;
|
||||||
|
|
||||||
options_set_string(oo, entry->name, "%s", newvalue);
|
o = options_set_string(oo, entry->name, "%s", newvalue);
|
||||||
ctx->info(ctx, "set option: %s -> %s", entry->name, newvalue);
|
ctx->info(
|
||||||
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
|
|
||||||
if (newvalue != value)
|
if (newvalue != value)
|
||||||
xfree(newvalue);
|
xfree(newvalue);
|
||||||
@ -91,6 +93,7 @@ void
|
|||||||
set_option_number(struct cmd_ctx *ctx, struct options *oo,
|
set_option_number(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value)
|
const struct set_option_entry *entry, char *value)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
long long number;
|
long long number;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
|
||||||
@ -104,14 +107,17 @@ set_option_number(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
ctx->error(ctx, "value is %s: %s", errstr, value);
|
ctx->error(ctx, "value is %s: %s", errstr, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
options_set_number(oo, entry->name, number);
|
|
||||||
ctx->info(ctx, "set option: %s -> %lld", entry->name, number);
|
o = options_set_number(oo, entry->name, number);
|
||||||
|
ctx->info(
|
||||||
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_option_key(struct cmd_ctx *ctx, struct options *oo,
|
set_option_key(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value)
|
const struct set_option_entry *entry, char *value)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
@ -123,15 +129,17 @@ set_option_key(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
ctx->error(ctx, "unknown key: %s", value);
|
ctx->error(ctx, "unknown key: %s", value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
options_set_number(oo, entry->name, key);
|
|
||||||
ctx->info(ctx,
|
o = options_set_number(oo, entry->name, key);
|
||||||
"set option: %s -> %s", entry->name, key_string_lookup_key(key));
|
ctx->info(
|
||||||
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_option_colour(struct cmd_ctx *ctx, struct options *oo,
|
set_option_colour(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value)
|
const struct set_option_entry *entry, char *value)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
int colour;
|
int colour;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
@ -144,15 +152,16 @@ set_option_colour(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
options_set_number(oo, entry->name, colour);
|
o = options_set_number(oo, entry->name, colour);
|
||||||
ctx->info(ctx,
|
ctx->info(
|
||||||
"set option: %s -> %s", entry->name, colour_tostring(colour));
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
|
set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value)
|
const struct set_option_entry *entry, char *value)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
int attr;
|
int attr;
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
@ -165,15 +174,16 @@ set_option_attributes(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
options_set_number(oo, entry->name, attr);
|
o = options_set_number(oo, entry->name, attr);
|
||||||
ctx->info(ctx,
|
ctx->info(
|
||||||
"set option: %s -> %s", entry->name, attributes_tostring(attr));
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_option_flag(struct cmd_ctx *ctx, struct options *oo,
|
set_option_flag(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value)
|
const struct set_option_entry *entry, char *value)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
if (value == NULL || *value == '\0')
|
if (value == NULL || *value == '\0')
|
||||||
@ -193,15 +203,16 @@ set_option_flag(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options_set_number(oo, entry->name, flag);
|
o = options_set_number(oo, entry->name, flag);
|
||||||
ctx->info(ctx,
|
ctx->info(
|
||||||
"set option: %s -> %s", entry->name, flag ? "on" : "off");
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_option_choice(struct cmd_ctx *ctx, struct options *oo,
|
set_option_choice(struct cmd_ctx *ctx, struct options *oo,
|
||||||
const struct set_option_entry *entry, char *value)
|
const struct set_option_entry *entry, char *value)
|
||||||
{
|
{
|
||||||
|
struct options_entry *o;
|
||||||
const char **choicep;
|
const char **choicep;
|
||||||
int n, choice = -1;
|
int n, choice = -1;
|
||||||
|
|
||||||
@ -227,7 +238,7 @@ set_option_choice(struct cmd_ctx *ctx, struct options *oo,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
options_set_number(oo, entry->name, choice);
|
o = options_set_number(oo, entry->name, choice);
|
||||||
ctx->info(ctx,
|
ctx->info(
|
||||||
"set option: %s -> %s", entry->name, entry->choices[choice]);
|
ctx, "set option: %s -> %s", o->name, set_option_print(entry, o));
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ options_remove(struct options *oo, const char *name)
|
|||||||
xfree(o);
|
xfree(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printflike3
|
struct options_entry *printflike3
|
||||||
options_set_string(struct options *oo, const char *name, const char *fmt, ...)
|
options_set_string(struct options *oo, const char *name, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
@ -115,6 +115,7 @@ options_set_string(struct options *oo, const char *name, const char *fmt, ...)
|
|||||||
o->type = OPTIONS_STRING;
|
o->type = OPTIONS_STRING;
|
||||||
xvasprintf(&o->str, fmt, ap);
|
xvasprintf(&o->str, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
return (o);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -129,7 +130,7 @@ options_get_string(struct options *oo, const char *name)
|
|||||||
return (o->str);
|
return (o->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
struct options_entry *
|
||||||
options_set_number(struct options *oo, const char *name, long long value)
|
options_set_number(struct options *oo, const char *name, long long value)
|
||||||
{
|
{
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
@ -143,7 +144,7 @@ options_set_number(struct options *oo, const char *name, long long value)
|
|||||||
|
|
||||||
o->type = OPTIONS_NUMBER;
|
o->type = OPTIONS_NUMBER;
|
||||||
o->num = value;
|
o->num = value;
|
||||||
|
return (o);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long
|
long long
|
||||||
|
5
tmux.h
5
tmux.h
@ -1159,10 +1159,11 @@ void options_free(struct options *);
|
|||||||
struct options_entry *options_find1(struct options *, const char *);
|
struct options_entry *options_find1(struct options *, const char *);
|
||||||
struct options_entry *options_find(struct options *, const char *);
|
struct options_entry *options_find(struct options *, const char *);
|
||||||
void options_remove(struct options *, const char *);
|
void options_remove(struct options *, const char *);
|
||||||
void printflike3 options_set_string(
|
struct options_entry *printflike3 options_set_string(
|
||||||
struct options *, const char *, const char *, ...);
|
struct options *, const char *, const char *, ...);
|
||||||
char *options_get_string(struct options *, const char *);
|
char *options_get_string(struct options *, const char *);
|
||||||
void options_set_number(struct options *, const char *, long long);
|
struct options_entry *options_set_number(
|
||||||
|
struct options *, const char *, long long);
|
||||||
long long options_get_number(struct options *, const char *);
|
long long options_get_number(struct options *, const char *);
|
||||||
|
|
||||||
/* environ.c */
|
/* environ.c */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user