From a9a9b7f1519eca20974f3a07d6ffc5d7b258eadf Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Mon, 2 Jun 1997 22:32:05 +0000 Subject: [PATCH] Add emit_quotes qualifier to pretty_print_option, so that we don't get extra quotes when emitting strings into configuration scripts --- common/options.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/common/options.c b/common/options.c index 449137e4..068cf060 100644 --- a/common/options.c +++ b/common/options.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.24 1997/05/09 08:07:09 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.25 1997/06/02 22:32:05 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -398,11 +398,12 @@ 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, emit_commas) - unsigned char code; +char *pretty_print_option (code, data, len, emit_commas, emit_quotes) + unsigned int code; unsigned char *data; int len; int emit_commas; + int emit_quotes; { static char optbuf [32768]; /* XXX */ int hunksize = 0; @@ -415,6 +416,10 @@ char *pretty_print_option (code, data, len, emit_commas) struct in_addr foo; char comma; + /* Code should be between 0 and 255. */ + if (code > 255) + error ("pretty_print_option: bad code %d\n", code); + if (emit_commas) comma = ','; else @@ -503,10 +508,12 @@ char *pretty_print_option (code, data, len, emit_commas) for (j = 0; j < numelem; j++) { switch (fmtbuf [j]) { case 't': - *op++ = '"'; + if (emit_quotes) + *op++ = '"'; strcpy (op, dp); op += strlen (dp); - *op++ = '"'; + if (emit_quotes) + *op++ = '"'; *op = 0; break; case 'I':