2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-30 22:05:23 +00:00

Add emit_quotes qualifier to pretty_print_option, so that we don't get extra quotes when emitting strings into configuration scripts

This commit is contained in:
Ted Lemon
1997-06-02 22:32:05 +00:00
parent b52a650cbc
commit a9a9b7f151

View File

@@ -42,7 +42,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#define DHCP_OPTION_DATA #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. */ /* Format the specified option so that a human can easily read it. */
char *pretty_print_option (code, data, len, emit_commas) char *pretty_print_option (code, data, len, emit_commas, emit_quotes)
unsigned char code; unsigned int code;
unsigned char *data; unsigned char *data;
int len; int len;
int emit_commas; int emit_commas;
int emit_quotes;
{ {
static char optbuf [32768]; /* XXX */ static char optbuf [32768]; /* XXX */
int hunksize = 0; int hunksize = 0;
@@ -415,6 +416,10 @@ char *pretty_print_option (code, data, len, emit_commas)
struct in_addr foo; struct in_addr foo;
char comma; char comma;
/* Code should be between 0 and 255. */
if (code > 255)
error ("pretty_print_option: bad code %d\n", code);
if (emit_commas) if (emit_commas)
comma = ','; comma = ',';
else else
@@ -503,9 +508,11 @@ char *pretty_print_option (code, data, len, emit_commas)
for (j = 0; j < numelem; j++) { for (j = 0; j < numelem; j++) {
switch (fmtbuf [j]) { switch (fmtbuf [j]) {
case 't': case 't':
if (emit_quotes)
*op++ = '"'; *op++ = '"';
strcpy (op, dp); strcpy (op, dp);
op += strlen (dp); op += strlen (dp);
if (emit_quotes)
*op++ = '"'; *op++ = '"';
*op = 0; *op = 0;
break; break;