diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-23 07:41:21 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-23 07:41:21 +0000 |
commit | c24d849fa41114108b52a0a5e9256a7f0558b0d8 (patch) | |
tree | 93dbcffb22bbddf9181fbc3e89d93d8e36bb6afd /options.c | |
parent | e013970b0b0b44bf871233cffcf5ca77ce700e2e (diff) |
Split options into a table to allow abbreviations.
Diffstat (limited to 'options.c')
-rw-r--r-- | options.c | 63 |
1 files changed, 1 insertions, 62 deletions
@@ -1,4 +1,4 @@ -/* $Id: options.c,v 1.2 2008-06-15 08:01:54 nicm Exp $ */ +/* $Id: options.c,v 1.3 2008-06-23 07:41:21 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,9 +30,6 @@ SPLAY_GENERATE(options_tree, options_entry, entry, options_cmp); -struct options_entry *options_find1(struct options *, const char *); -struct options_entry *options_find(struct options *, const char *); - int options_cmp(struct options_entry *o1, struct options_entry *o2) { @@ -145,61 +142,3 @@ options_get_number(struct options *oo, const char *name) fatalx("option not a number"); return (o->value.number); } - -void -options_set_key(struct options *oo, const char *name, int value) -{ - struct options_entry *o; - - if ((o = options_find1(oo, name)) == NULL) { - o = xmalloc(sizeof *o); - o->name = xstrdup(name); - SPLAY_INSERT(options_tree, &oo->tree, o); - } else if (o->type == OPTIONS_STRING) - xfree(o->value.string); - - o->type = OPTIONS_KEY; - o->value.key = value; - -} - -int -options_get_key(struct options *oo, const char *name) -{ - struct options_entry *o; - - if ((o = options_find(oo, name)) == NULL) - fatalx("missing option"); - if (o->type != OPTIONS_KEY) - fatalx("option not a key"); - return (o->value.key); -} - -void -options_set_colours(struct options *oo, const char *name, u_char value) -{ - struct options_entry *o; - - if ((o = options_find1(oo, name)) == NULL) { - o = xmalloc(sizeof *o); - o->name = xstrdup(name); - SPLAY_INSERT(options_tree, &oo->tree, o); - } else if (o->type == OPTIONS_STRING) - xfree(o->value.string); - - o->type = OPTIONS_COLOURS; - o->value.colours = value; - -} - -u_char -options_get_colours(struct options *oo, const char *name) -{ - struct options_entry *o; - - if ((o = options_find(oo, name)) == NULL) - fatalx("missing option"); - if (o->type != OPTIONS_COLOURS) - fatalx("option not a colours"); - return (o->value.colours); -} |