summaryrefslogtreecommitdiffstats
path: root/extensions/libxt_sctp.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2010-12-18 02:04:59 +0100
committerJan Engelhardt <jengelh@medozas.de>2011-01-31 03:05:34 +0100
commit73866357e4a7a0fdc1b293bf8863fee2bd56da9e (patch)
tree1890725e5f327ba14ccf452ff9e5916954d7908f /extensions/libxt_sctp.c
parentbb8be30857edd501e701c2f22db6c59bd6839c87 (diff)
iptables: do not print trailing whitespaces
Due to the use of printf("foobar "), iptables emits spaces at the end-of-line, which looks odd to some users because it causes the terminal to wrap even if there is seemingly nothing to print. It may also have other points of annoyance, such as mailers interpreting a trailing space as an indicator that the paragraph continues when format=flowed is also on. And git highlights trailing spaces in red, so let's avoid :) Preexisting inconsistencies in outputting spaces in the right spot are also addressed right away. References: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=429579 Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'extensions/libxt_sctp.c')
-rw-r--r--extensions/libxt_sctp.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c
index 016a9f9e..718d4c42 100644
--- a/extensions/libxt_sctp.c
+++ b/extensions/libxt_sctp.c
@@ -329,7 +329,7 @@ print_ports(const char *name, uint16_t min, uint16_t max,
const char *inv = invert ? "!" : "";
if (min != 0 || max != 0xFFFF || invert) {
- printf("%s", name);
+ printf(" %s", name);
if (min == max) {
printf(":%s", inv);
print_port(min, numeric);
@@ -339,7 +339,6 @@ print_ports(const char *name, uint16_t min, uint16_t max,
printf(":");
print_port(max, numeric);
}
- printf(" ");
}
}
@@ -391,19 +390,19 @@ print_chunks(const struct xt_sctp_info *einfo, int numeric)
int flag;
switch (chunk_match_type) {
- case SCTP_CHUNK_MATCH_ANY: printf("any "); break;
- case SCTP_CHUNK_MATCH_ALL: printf("all "); break;
- case SCTP_CHUNK_MATCH_ONLY: printf("only "); break;
+ case SCTP_CHUNK_MATCH_ANY: printf(" any"); break;
+ case SCTP_CHUNK_MATCH_ALL: printf(" all"); break;
+ case SCTP_CHUNK_MATCH_ONLY: printf(" only"); break;
default: printf("Never reach here\n"); break;
}
if (SCTP_CHUNKMAP_IS_CLEAR(einfo->chunkmap)) {
- printf("NONE ");
+ printf(" NONE");
goto out;
}
if (SCTP_CHUNKMAP_IS_ALL_SET(einfo->chunkmap)) {
- printf("ALL ");
+ printf(" ALL");
goto out;
}
@@ -412,6 +411,8 @@ print_chunks(const struct xt_sctp_info *einfo, int numeric)
if (SCTP_CHUNKMAP_IS_SET(einfo->chunkmap, i)) {
if (flag)
printf(",");
+ else
+ putchar(' ');
flag = 1;
print_chunk(i, numeric);
for (j = 0; j < flag_count; j++) {
@@ -422,9 +423,6 @@ print_chunks(const struct xt_sctp_info *einfo, int numeric)
}
}
}
-
- if (flag)
- printf(" ");
out:
return;
}
@@ -435,7 +433,7 @@ sctp_print(const void *ip, const struct xt_entry_match *match, int numeric)
const struct xt_sctp_info *einfo =
(const struct xt_sctp_info *)match->data;
- printf("sctp ");
+ printf(" sctp");
if (einfo->flags & XT_SCTP_SRC_PORTS) {
print_ports("spt", einfo->spts[0], einfo->spts[1],
@@ -453,7 +451,7 @@ sctp_print(const void *ip, const struct xt_entry_match *match, int numeric)
/* FIXME: print_chunks() is used in save() where the printing of '!'
s taken care of, so we need to do that here as well */
if (einfo->invflags & XT_SCTP_CHUNK_TYPES) {
- printf("! ");
+ printf(" !");
}
print_chunks(einfo, numeric);
}
@@ -466,28 +464,28 @@ static void sctp_save(const void *ip, const struct xt_entry_match *match)
if (einfo->flags & XT_SCTP_SRC_PORTS) {
if (einfo->invflags & XT_SCTP_SRC_PORTS)
- printf("! ");
+ printf(" !");
if (einfo->spts[0] != einfo->spts[1])
- printf("--sport %u:%u ",
+ printf(" --sport %u:%u",
einfo->spts[0], einfo->spts[1]);
else
- printf("--sport %u ", einfo->spts[0]);
+ printf(" --sport %u", einfo->spts[0]);
}
if (einfo->flags & XT_SCTP_DEST_PORTS) {
if (einfo->invflags & XT_SCTP_DEST_PORTS)
- printf("! ");
+ printf(" !");
if (einfo->dpts[0] != einfo->dpts[1])
- printf("--dport %u:%u ",
+ printf(" --dport %u:%u",
einfo->dpts[0], einfo->dpts[1]);
else
- printf("--dport %u ", einfo->dpts[0]);
+ printf(" --dport %u", einfo->dpts[0]);
}
if (einfo->flags & XT_SCTP_CHUNK_TYPES) {
if (einfo->invflags & XT_SCTP_CHUNK_TYPES)
- printf("! ");
- printf("--chunk-types ");
+ printf(" !");
+ printf(" --chunk-types");
print_chunks(einfo, 0);
}