version 1.51, 2011/04/05 19:37:01 |
version 1.52, 2012/01/21 08:40:09 |
|
|
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_ctx *, |
struct options_entry *cmd_set_option_number(struct cmd *, struct cmd_ctx *, |
const struct options_table_entry *, struct options *, |
const struct options_table_entry *, struct options *, |
const char *); |
const char *); |
struct options_entry *cmd_set_option_keys(struct cmd *, struct cmd_ctx *, |
struct options_entry *cmd_set_option_key(struct cmd *, struct cmd_ctx *, |
const struct options_table_entry *, struct options *, |
const struct options_table_entry *, struct options *, |
const char *); |
const char *); |
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_ctx *, |
struct options_entry *cmd_set_option_colour(struct cmd *, struct cmd_ctx *, |
|
|
case OPTIONS_TABLE_NUMBER: |
case OPTIONS_TABLE_NUMBER: |
o = cmd_set_option_number(self, ctx, oe, oo, value); |
o = cmd_set_option_number(self, ctx, oe, oo, value); |
break; |
break; |
case OPTIONS_TABLE_KEYS: |
case OPTIONS_TABLE_KEY: |
o = cmd_set_option_keys(self, ctx, oe, oo, value); |
o = cmd_set_option_key(self, ctx, oe, oo, value); |
break; |
break; |
case OPTIONS_TABLE_COLOUR: |
case OPTIONS_TABLE_COLOUR: |
o = cmd_set_option_colour(self, ctx, oe, oo, value); |
o = cmd_set_option_colour(self, ctx, oe, oo, value); |
|
|
return (options_set_number(oo, oe->name, ll)); |
return (options_set_number(oo, oe->name, ll)); |
} |
} |
|
|
/* Set a keys option. */ |
/* Set a key option. */ |
struct options_entry * |
struct options_entry * |
cmd_set_option_keys(unused struct cmd *self, struct cmd_ctx *ctx, |
cmd_set_option_key(unused struct cmd *self, struct cmd_ctx *ctx, |
const struct options_table_entry *oe, struct options *oo, const char *value) |
const struct options_table_entry *oe, struct options *oo, const char *value) |
{ |
{ |
struct keylist *keylist; |
int key; |
char *copy, *ptr, *s; |
|
int key; |
|
|
|
keylist = xmalloc(sizeof *keylist); |
if ((key = key_string_lookup_string(value)) == KEYC_NONE) { |
ARRAY_INIT(keylist); |
ctx->error(ctx, "bad key: %s", value); |
|
return (NULL); |
ptr = copy = xstrdup(value); |
|
while ((s = strsep(&ptr, ",")) != NULL) { |
|
if ((key = key_string_lookup_string(s)) == KEYC_NONE) { |
|
ctx->error(ctx, "unknown key: %s", s); |
|
xfree(copy); |
|
xfree(keylist); |
|
return (NULL); |
|
} |
|
ARRAY_ADD(keylist, key); |
|
} |
} |
xfree(copy); |
|
|
|
return (options_set_data(oo, oe->name, keylist, xfree)); |
return (options_set_number(oo, oe->name, key)); |
} |
} |
|
|
/* Set a colour option. */ |
/* Set a colour option. */ |