mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-30 22:05:23 +00:00
Add support (not debugged) for printing enumerations.
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: options.c,v 1.73 2000/12/28 23:16:19 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: options.c,v 1.74 2000/12/29 06:45:00 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#define DHCP_OPTION_DATA
|
#define DHCP_OPTION_DATA
|
||||||
@@ -913,6 +913,7 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
|
|||||||
int numhunk = -1;
|
int numhunk = -1;
|
||||||
int numelem = 0;
|
int numelem = 0;
|
||||||
char fmtbuf [32];
|
char fmtbuf [32];
|
||||||
|
struct enumeration *enumbuf [32];
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
char *op = optbuf;
|
char *op = optbuf;
|
||||||
const unsigned char *dp = data;
|
const unsigned char *dp = data;
|
||||||
@@ -924,6 +925,8 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
|
|||||||
else
|
else
|
||||||
comma = ' ';
|
comma = ' ';
|
||||||
|
|
||||||
|
memset (enumbuf, 0, sizeof enumbuf);
|
||||||
|
|
||||||
/* Figure out the size of the data. */
|
/* Figure out the size of the data. */
|
||||||
for (l = i = 0; option -> format [i]; i++, l++) {
|
for (l = i = 0; option -> format [i]; i++, l++) {
|
||||||
if (!numhunk) {
|
if (!numhunk) {
|
||||||
@@ -975,6 +978,15 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
|
|||||||
fmtbuf [l + 1] = 0;
|
fmtbuf [l + 1] = 0;
|
||||||
numhunk = -2;
|
numhunk = -2;
|
||||||
break;
|
break;
|
||||||
|
case 'N':
|
||||||
|
k = i;
|
||||||
|
while (option -> format [i] &&
|
||||||
|
option -> format [i] != '.')
|
||||||
|
i++;
|
||||||
|
enumbuf [l] = find_enumeration (&option -> format [k],
|
||||||
|
i - k);
|
||||||
|
hunksize += 1;
|
||||||
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'L':
|
case 'L':
|
||||||
@@ -1056,6 +1068,21 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
|
|||||||
*op++ = '"';
|
*op++ = '"';
|
||||||
*op = 0;
|
*op = 0;
|
||||||
break;
|
break;
|
||||||
|
/* pretty-printing an array of enums is
|
||||||
|
going to get ugly. */
|
||||||
|
case 'N':
|
||||||
|
if (!enumbuf [j])
|
||||||
|
goto enum_as_num;
|
||||||
|
for (i = 0; ;i++) {
|
||||||
|
if (!enumbuf [j] -> values [i].name)
|
||||||
|
goto enum_as_num;
|
||||||
|
if (enumbuf [j] -> values [i].value ==
|
||||||
|
*dp)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
strcpy (op, enumbuf [j] -> values [i].name);
|
||||||
|
op += strlen (op);
|
||||||
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
foo.s_addr = htonl (getULong (dp));
|
foo.s_addr = htonl (getULong (dp));
|
||||||
strcpy (op, inet_ntoa (foo));
|
strcpy (op, inet_ntoa (foo));
|
||||||
@@ -1082,6 +1109,7 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
|
|||||||
sprintf (op, "%d", *(const char *)dp++);
|
sprintf (op, "%d", *(const char *)dp++);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
|
enum_as_num:
|
||||||
sprintf (op, "%d", *dp++);
|
sprintf (op, "%d", *dp++);
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
|
Reference in New Issue
Block a user