version 1.9, 2014/01/09 13:58:06 |
version 1.10, 2014/01/28 23:07:09 |
|
|
o = xmalloc(sizeof *o); |
o = xmalloc(sizeof *o); |
o->name = xstrdup(name); |
o->name = xstrdup(name); |
RB_INSERT(options_tree, &oo->tree, o); |
RB_INSERT(options_tree, &oo->tree, o); |
|
memcpy(&o->style, &grid_default_cell, sizeof o->style); |
} else if (o->type == OPTIONS_STRING) |
} else if (o->type == OPTIONS_STRING) |
free(o->str); |
free(o->str); |
|
|
|
|
o = xmalloc(sizeof *o); |
o = xmalloc(sizeof *o); |
o->name = xstrdup(name); |
o->name = xstrdup(name); |
RB_INSERT(options_tree, &oo->tree, o); |
RB_INSERT(options_tree, &oo->tree, o); |
|
memcpy(&o->style, &grid_default_cell, sizeof o->style); |
} else if (o->type == OPTIONS_STRING) |
} else if (o->type == OPTIONS_STRING) |
free(o->str); |
free(o->str); |
|
|
|
|
if (o->type != OPTIONS_NUMBER) |
if (o->type != OPTIONS_NUMBER) |
fatalx("option not a number"); |
fatalx("option not a number"); |
return (o->num); |
return (o->num); |
|
} |
|
|
|
struct options_entry * |
|
options_set_style(struct options *oo, const char *name, const char *value, |
|
int append) |
|
{ |
|
struct options_entry *o; |
|
|
|
if ((o = options_find1(oo, name)) == NULL) { |
|
o = xmalloc(sizeof *o); |
|
o->name = xstrdup(name); |
|
RB_INSERT(options_tree, &oo->tree, o); |
|
} else if (o->type == OPTIONS_STRING) |
|
free(o->str); |
|
|
|
if (!append) |
|
memcpy(&o->style, &grid_default_cell, sizeof o->style); |
|
|
|
o->type = OPTIONS_STYLE; |
|
if (style_parse(&grid_default_cell, &o->style, value) == -1) |
|
return (NULL); |
|
return (o); |
|
} |
|
|
|
struct grid_cell * |
|
options_get_style(struct options *oo, const char *name) |
|
{ |
|
struct options_entry *o; |
|
|
|
if ((o = options_find(oo, name)) == NULL) |
|
fatalx("missing option"); |
|
if (o->type != OPTIONS_STYLE) |
|
fatalx("option not a style"); |
|
return (&o->style); |
} |
} |