accept: Factor out rejection flags printing

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-10-29 11:11:30 +02:00
parent d35303d426
commit 2fcc325dd5

View file

@ -27,13 +27,15 @@
* acce.c: Report rejection status of telegrams/annos/loans * acce.c: Report rejection status of telegrams/annos/loans
* *
* Known contributors to this file: * Known contributors to this file:
* * Markus Armbruster, 2006-2016
*/ */
#include <config.h> #include <config.h>
#include "commands.h" #include "commands.h"
static void pr_accept(struct natstr *, natid);
/* /*
* report rejection status * report rejection status
* Optional argument reports staus from the * Optional argument reports staus from the
@ -42,17 +44,6 @@
int int
acce(void) acce(void)
{ {
static char *rejects[] = {
/* must follow reject flags defined in nat.h */
" YES YES YES",
" NO YES YES",
" YES NO YES",
" NO NO YES",
" YES YES NO ",
" NO YES NO ",
" YES NO NO ",
" NO NO NO ",
};
struct natstr *natp; struct natstr *natp;
struct natstr *np; struct natstr *np;
natid cn; natid cn;
@ -78,9 +69,27 @@ acce(void)
if (np->nat_stat == STAT_UNUSED) if (np->nat_stat == STAT_UNUSED)
continue; continue;
pr("%3d) %-14.14s ", cn, cname(cn)); pr("%3d) %-14.14s ", cn, cname(cn));
pr("%s %s\n", pr_accept(natp, cn);
rejects[getrejects(cn, natp)], pr_accept(np, as);
rejects[getrejects(as, np)]); pr("\n");
} }
return RET_OK; return RET_OK;
} }
static void
pr_accept(struct natstr *to, natid from)
{
static char *rejects[] = {
/* must follow reject flags defined in nat.h */
" YES YES YES",
" NO YES YES",
" YES NO YES",
" NO NO YES",
" YES YES NO ",
" NO YES NO ",
" YES NO NO ",
" NO NO NO ",
};
pr(" %s", rejects[getrejects(from, to)]);
}