From: Ted Lemon Date: Sat, 22 Feb 1997 08:32:05 +0000 (+0000) Subject: pretty_print_options now optionally seperates array elements with comma, and now... X-Git-Tag: DHCP_970222~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=171c47a6cc79372a6538e7fdec548da9122a6b90;p=thirdparty%2Fdhcp.git pretty_print_options now optionally seperates array elements with comma, and now encloses text strings in quotes --- diff --git a/common/options.c b/common/options.c index 2f0210ea1..6d18ad5ef 100644 --- a/common/options.c +++ b/common/options.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.21 1997/02/19 10:52:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.22 1997/02/22 08:32:04 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -398,10 +398,11 @@ int store_options (buffer, buflen, options, priority_list, priority_len, /* Format the specified option so that a human can easily read it. */ -char *pretty_print_option (code, data, len) +char *pretty_print_option (code, data, len, emit_commas) unsigned char code; unsigned char *data; int len; + int emit_commas; { static char optbuf [32768]; /* XXX */ int hunksize = 0; @@ -489,7 +490,11 @@ char *pretty_print_option (code, data, len) for (j = 0; j < numelem; j++) { switch (fmtbuf [j]) { case 't': + *op++ = '"'; strcpy (op, dp); + op += strlen (dp); + *op++ = '"'; + *op = 0; break; case 'I': foo.s_addr = htonl (getULong (dp)); @@ -530,7 +535,8 @@ char *pretty_print_option (code, data, len) *op++ = ' '; } if (i + 1 < numhunk) { - *op++ = ','; + if (emit_commas) + *op++ = ','; *op++ = ' '; } diff --git a/common/print.c b/common/print.c index 90b5532a5..e43b58c0b 100644 --- a/common/print.c +++ b/common/print.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: print.c,v 1.11 1996/08/27 09:53:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: print.c,v 1.12 1997/02/22 08:32:05 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -132,7 +132,7 @@ void dump_packet (tp) dhcp_options [i].name, pretty_print_option (i, tp -> options [i].data, - tp -> options [i].len)); + tp -> options [i].len, 1)); } } debug (""); @@ -183,4 +183,3 @@ void hash_dump (table) } } } - diff --git a/options.c b/options.c index 2f0210ea1..6d18ad5ef 100644 --- a/options.c +++ b/options.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.21 1997/02/19 10:52:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.22 1997/02/22 08:32:04 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -398,10 +398,11 @@ int store_options (buffer, buflen, options, priority_list, priority_len, /* Format the specified option so that a human can easily read it. */ -char *pretty_print_option (code, data, len) +char *pretty_print_option (code, data, len, emit_commas) unsigned char code; unsigned char *data; int len; + int emit_commas; { static char optbuf [32768]; /* XXX */ int hunksize = 0; @@ -489,7 +490,11 @@ char *pretty_print_option (code, data, len) for (j = 0; j < numelem; j++) { switch (fmtbuf [j]) { case 't': + *op++ = '"'; strcpy (op, dp); + op += strlen (dp); + *op++ = '"'; + *op = 0; break; case 'I': foo.s_addr = htonl (getULong (dp)); @@ -530,7 +535,8 @@ char *pretty_print_option (code, data, len) *op++ = ' '; } if (i + 1 < numhunk) { - *op++ = ','; + if (emit_commas) + *op++ = ','; *op++ = ' '; } diff --git a/print.c b/print.c index 90b5532a5..e43b58c0b 100644 --- a/print.c +++ b/print.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: print.c,v 1.11 1996/08/27 09:53:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: print.c,v 1.12 1997/02/22 08:32:05 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -132,7 +132,7 @@ void dump_packet (tp) dhcp_options [i].name, pretty_print_option (i, tp -> options [i].data, - tp -> options [i].len)); + tp -> options [i].len, 1)); } } debug (""); @@ -183,4 +183,3 @@ void hash_dump (table) } } } -