From fcd79f550b23182705d86ca3520db5ea60e37453 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 1 Feb 2016 11:56:47 +0100 Subject: add padding to output --- dyndhcpd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/dyndhcpd.c b/dyndhcpd.c index 353fd7a..5cbfb79 100644 --- a/dyndhcpd.c +++ b/dyndhcpd.c @@ -190,17 +190,23 @@ int main(int argc, char ** argv) { inet_ntop(AF_INET, &bootp.minhost.i, bootp.minhost.c, INET_ADDRSTRLEN) != NULL && inet_ntop(AF_INET, &bootp.maxhost.i, bootp.maxhost.c, INET_ADDRSTRLEN) != NULL) { /* print information */ - if (verbose) - printf("Interface: %s\n" + if (verbose) { + int pad = strlen(dhcp.minhost.c) > strlen(bootp.minhost.c) ? + strlen(dhcp.minhost.c) : strlen(bootp.minhost.c); + printf( "Interface: %s\n" "Domain: %s\n" "Host Address: %s\n" "Network: %s\n" "Broadcast: %s\n" "Netmask: %s\n" - "Hosts DHCP: %s - %s\n" - "Hosts BOOTP: %s - %s\n", - interface, domainname, network.address.c, network.netaddress.c, network.broadcast.c, network.netmask.c, - dhcp.minhost.c, dhcp.maxhost.c, bootp.minhost.c, bootp.maxhost.c); + "Hosts DHCP: %-*s - %s\n" + "Hosts BOOTP: %-*s - %s\n", + interface, domainname, + network.address.c, network.netaddress.c, + network.broadcast.c, network.netmask.c, + pad, dhcp.minhost.c, dhcp.maxhost.c, + pad, bootp.minhost.c, bootp.maxhost.c); + } /* open the template for reading */ if (templatefilename == NULL) -- cgit v1.2.3-54-g00ecf