| 234 | #define ENABLE_SET 2 |
| 235 | |
| 236 | static int parse_option(const char *arg, int len, unsigned int *colopts, |
| 237 | int *group_set) |
| 238 | { |
| 239 | struct colopt opts[] = { |
| 240 | { "always", COL_ENABLED, COL_ENABLE_MASK }, |
| 241 | { "never", COL_DISABLED, COL_ENABLE_MASK }, |
| 242 | { "auto", COL_AUTO, COL_ENABLE_MASK }, |
| 243 | { "plain", COL_PLAIN, COL_LAYOUT_MASK }, |
| 244 | { "column", COL_COLUMN, COL_LAYOUT_MASK }, |
| 245 | { "row", COL_ROW, COL_LAYOUT_MASK }, |
| 246 | { "dense", COL_DENSE, 0 }, |
| 247 | }; |
| 248 | int i; |
| 249 | |
| 250 | for (i = 0; i < ARRAY_SIZE(opts); i++) { |
| 251 | int set = 1, arg_len = len, name_len; |
| 252 | const char *arg_str = arg; |
| 253 | |
| 254 | if (!opts[i].mask) { |
| 255 | if (arg_len > 2 && !strncmp(arg_str, "no", 2)) { |
| 256 | arg_str += 2; |
| 257 | arg_len -= 2; |
| 258 | set = 0; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | name_len = strlen(opts[i].name); |
| 263 | if (arg_len != name_len || |
| 264 | strncmp(arg_str, opts[i].name, name_len)) |
| 265 | continue; |
| 266 | |
| 267 | switch (opts[i].mask) { |
| 268 | case COL_ENABLE_MASK: |
| 269 | *group_set |= ENABLE_SET; |
| 270 | break; |
| 271 | case COL_LAYOUT_MASK: |
| 272 | *group_set |= LAYOUT_SET; |
| 273 | break; |
| 274 | } |
| 275 | |
| 276 | if (opts[i].mask) |
| 277 | *colopts = (*colopts & ~opts[i].mask) | opts[i].value; |
| 278 | else { |
| 279 | if (set) |
| 280 | *colopts |= opts[i].value; |
| 281 | else |
| 282 | *colopts &= ~opts[i].value; |
| 283 | } |
| 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | return error("unsupported option '%s'", arg); |
| 288 | } |
| 289 | |
| 290 | static int parse_config(unsigned int *colopts, const char *value) |
| 291 | { |