From: Ted Lemon Date: Tue, 6 Jul 1999 16:53:30 +0000 (+0000) Subject: - Pull a change from the 2.0 branch to make 'X' options print as strings X-Git-Tag: V3-BETA-1-PATCH-0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6e7518cc1bf51d75053a3c7a7e6cd1a1e1dff6e;p=thirdparty%2Fdhcp.git - Pull a change from the 2.0 branch to make 'X' options print as strings if possible. --- diff --git a/common/options.c b/common/options.c index 591181c1d..c3311c7d4 100644 --- a/common/options.c +++ b/common/options.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.43 1999/07/02 20:57:25 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.44 1999/07/06 16:53:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -618,7 +618,7 @@ char *pretty_print_option (code, data, len, emit_commas, emit_quotes) int numhunk = -1; int numelem = 0; char fmtbuf [32]; - int i, j; + int i, j, k; char *op = optbuf; unsigned char *dp = data; struct in_addr foo; @@ -637,8 +637,8 @@ char *pretty_print_option (code, data, len, emit_commas, emit_quotes) for (i = 0; dhcp_options [code].format [i]; i++) { if (!numhunk) { log_error ("%s: Extra codes in format string: %s\n", - dhcp_options [code].name, - &(dhcp_options [code].format [i])); + dhcp_options [code].name, + &(dhcp_options [code].format [i])); break; } numelem++; @@ -650,11 +650,21 @@ char *pretty_print_option (code, data, len, emit_commas, emit_quotes) numhunk = 0; break; case 'X': - fmtbuf [i] = 'x'; + for (k = 0; k < len; k++) { + if (!isascii (data [k]) || + !isprint (data [k])) + break; + } + if (k == len) { + fmtbuf [i] = 't'; + numhunk = -2; + } else { + fmtbuf [i] = 'x'; + hunksize++; + comma = ':'; + numhunk = 0; + } fmtbuf [i + 1] = 0; - hunksize++; - numhunk = 0; - comma = ':'; break; case 't': fmtbuf [i] = 't';