Пример #1
0
enum cmd_retval
cmd_show_options_all(struct cmd *self, struct cmd_q *cmdq,
    const struct options_table_entry *table, struct options *oo)
{
	const struct options_table_entry	*oe;
	struct options_entry			*o;
	const char				*optval;

	o = options_first(oo);
	while (o != NULL) {
		if (*o->name == '@') {
			if (args_has(self->args, 'v'))
				cmdq_print(cmdq, "%s", o->str);
			else
				cmdq_print(cmdq, "%s \"%s\"", o->name, o->str);
		}
		o = options_next(o);
	}

	for (oe = table; oe->name != NULL; oe++) {
		if (oe->style != NULL)
			continue;
		if ((o = options_find1(oo, oe->name)) == NULL)
			continue;
		optval = options_table_print_entry(oe, o,
		    args_has(self->args, 'v'));
		if (args_has(self->args, 'v'))
			cmdq_print(cmdq, "%s", optval);
		else
			cmdq_print(cmdq, "%s %s", oe->name, optval);
	}

	return (CMD_RETURN_NORMAL);
}
Пример #2
0
static enum cmd_retval
cmd_show_options_all(struct cmd *self, struct cmdq_item *item,
    struct options *oo)
{
	struct options_entry			*o;
	struct options_array_item		*a;
	u_int					 idx;
	const struct options_table_entry	*oe;

	o = options_first(oo);
	while (o != NULL) {
		oe = options_table_entry(o);
		if ((self->entry != &cmd_show_hooks_entry &&
		    !args_has(self->args, 'H') &&
		    oe != NULL &&
		    (oe->flags & OPTIONS_TABLE_IS_HOOK)) ||
		    (self->entry == &cmd_show_hooks_entry &&
		    (oe == NULL ||
		    (~oe->flags & OPTIONS_TABLE_IS_HOOK)))) {
			o = options_next(o);
			continue;
		}
		if (!options_isarray(o))
			cmd_show_options_print(self, item, o, -1);
		else if ((a = options_array_first(o)) == NULL) {
			if (!args_has(self->args, 'v'))
				cmdq_print(item, "%s", options_name(o));
		} else {
			while (a != NULL) {
				idx = options_array_item_index(a);
				cmd_show_options_print(self, item, o, idx);
				a = options_array_next(a);
			}
		}
		o = options_next(o);
	}
	return (CMD_RETURN_NORMAL);
}