Re: [nft RFC PATCH 2/6] rule: allow to print sets in plain format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 18, 2014 at 12:18:17AM +0100, Arturo Borrero Gonzalez wrote:
> Allow to print sets with or without format.
> 
> This is useful in situations where we want to print exactly the same the user
> typed (IOW, in one single line, and with family/table info).

I like that, I wanted to make the indentation level variable anyway to
avoid deep indentation for set only output. Also I was considering a
pretty print function that neatly aligned all members.

Small note: we never know for sure we're generating what the user typed.
He might have used line continuations, bitwise operators etc.


> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -90,21 +90,30 @@ struct set *set_lookup(const struct table *table, const char *name)
>  	return NULL;
>  }
>  
> -void set_print(const struct set *set)
> +static void do_set_print(const struct set *set, const char *tab,
> +			 const char *nl, const char *family, const char *table)

Maybe encapsulate the tab/nl arguments into a struct. That will reduce
the needed changes when the indentation level is added.

Regarding newlines - it serves to purposes that probably need to be
handled differently.

- set family table name {\n

In this case its just for better readability.

- type bla\n

In this case its for making the output parsable. The parser expects
a stmt_seperator, which can be either \n or ;.

So I guess we need both a nl and a seperator argument.

Furthermore, I think a char (instead of a char *) should do fine.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux