diff options
author | Phil Sutter <phil@nwl.cc> | 2022-11-25 03:13:14 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2022-11-29 13:25:26 +0100 |
commit | 023dd2c515be63ddb2f0b6a6f3bccab4cdf7a71c (patch) | |
tree | 4209d3e8123555385bbc731fe8da9ac2c90bf07b /include | |
parent | 208290ff0bfecb49044c3df87149aa6fa683de09 (diff) |
libxtables: xt_xlate_add() to take care of spacing
Try to eliminate most of the whitespace issues by separating strings
from separate xt_xlate_add() calls by whitespace if needed.
Cover the common case of consecutive range, list or MAC/IP address
printing by inserting whitespace only if the string to be appended
starts with an alphanumeric character or a brace. The latter helps to
make spacing in anonymous sets consistent.
Provide *_nospc() variants which disable the auto-spacing for the
mandatory exception to the rule.
Make things round by dropping any trailing whitespace before returning
the buffer via xt_xlate_get().
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'include')
-rw-r--r-- | include/xtables.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/xtables.h b/include/xtables.h index 9eba4f61..dad1949e 100644 --- a/include/xtables.h +++ b/include/xtables.h @@ -621,8 +621,11 @@ extern const char *xtables_lmap_id2name(const struct xtables_lmap *, int); struct xt_xlate *xt_xlate_alloc(int size); void xt_xlate_free(struct xt_xlate *xl); void xt_xlate_add(struct xt_xlate *xl, const char *fmt, ...) __attribute__((format(printf,2,3))); +void xt_xlate_add_nospc(struct xt_xlate *xl, const char *fmt, ...) __attribute__((format(printf,2,3))); #define xt_xlate_rule_add xt_xlate_add +#define xt_xlate_rule_add_nospc xt_xlate_add_nospc void xt_xlate_set_add(struct xt_xlate *xl, const char *fmt, ...) __attribute__((format(printf,2,3))); +void xt_xlate_set_add_nospc(struct xt_xlate *xl, const char *fmt, ...) __attribute__((format(printf,2,3))); void xt_xlate_add_comment(struct xt_xlate *xl, const char *comment); const char *xt_xlate_get_comment(struct xt_xlate *xl); void xl_xlate_set_family(struct xt_xlate *xl, uint8_t family); |