dhcp_symbol.c (7c478bd9) dhcp_symbol.c (d04ccbb3)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
23 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident "%Z%%M% %I% %E% SMI"
28
29#include <stdlib.h>
30#include <ctype.h>
31#include <strings.h>

--- 11 unchanged lines hidden (view full) ---

43 char *dc_string; /* string value for the category */
44 int dc_minlen; /* min. chars of dc_string to match */
45 dsym_category_t dc_id; /* numerical value for the category */
46 boolean_t dc_dhcptab; /* valid for dhcptab use? */
47 ushort_t dc_min; /* minimum valid code */
48 ushort_t dc_max; /* maximum valid code */
49} dsym_cat_t;
50
23 * Use is subject to license terms.
24 */
25
26#pragma ident "%Z%%M% %I% %E% SMI"
27
28#include <stdlib.h>
29#include <ctype.h>
30#include <strings.h>

--- 11 unchanged lines hidden (view full) ---

42 char *dc_string; /* string value for the category */
43 int dc_minlen; /* min. chars of dc_string to match */
44 dsym_category_t dc_id; /* numerical value for the category */
45 boolean_t dc_dhcptab; /* valid for dhcptab use? */
46 ushort_t dc_min; /* minimum valid code */
47 ushort_t dc_max; /* maximum valid code */
48} dsym_cat_t;
49
51static dsym_cat_t cats[DSYM_CATEGORY_NUM] = {
50static dsym_cat_t cats[] = {
52 { "Extend", 6, DSYM_EXTEND, B_TRUE, DHCP_LAST_STD + 1,
53 DHCP_SITE_OPT - 1 },
54 { "Vendor=", 6, DSYM_VENDOR, B_TRUE, DHCP_FIRST_OPT,
55 DHCP_LAST_OPT },
56 { "Site", 4, DSYM_SITE, B_TRUE, DHCP_SITE_OPT, DHCP_LAST_OPT },
57 { "Standard", 8, DSYM_STANDARD, B_FALSE, DHCP_FIRST_OPT,
58 DHCP_LAST_STD },
59 { "Field", 5, DSYM_FIELD, B_FALSE, CD_PACKET_START,

--- 7 unchanged lines hidden (view full) ---

67 * of a DHCP symbol type.
68 */
69typedef struct dsym_type {
70 char *dt_string; /* string value for the type */
71 dsym_cdtype_t dt_id; /* numerical value for the type */
72 boolean_t dt_dhcptab; /* valid for dhcptab use? */
73} dsym_type_t;
74
51 { "Extend", 6, DSYM_EXTEND, B_TRUE, DHCP_LAST_STD + 1,
52 DHCP_SITE_OPT - 1 },
53 { "Vendor=", 6, DSYM_VENDOR, B_TRUE, DHCP_FIRST_OPT,
54 DHCP_LAST_OPT },
55 { "Site", 4, DSYM_SITE, B_TRUE, DHCP_SITE_OPT, DHCP_LAST_OPT },
56 { "Standard", 8, DSYM_STANDARD, B_FALSE, DHCP_FIRST_OPT,
57 DHCP_LAST_STD },
58 { "Field", 5, DSYM_FIELD, B_FALSE, CD_PACKET_START,

--- 7 unchanged lines hidden (view full) ---

66 * of a DHCP symbol type.
67 */
68typedef struct dsym_type {
69 char *dt_string; /* string value for the type */
70 dsym_cdtype_t dt_id; /* numerical value for the type */
71 boolean_t dt_dhcptab; /* valid for dhcptab use? */
72} dsym_type_t;
73
75static dsym_type_t types[DSYM_CDTYPE_NUM] = {
74static dsym_type_t types[] = {
76 { "ASCII", DSYM_ASCII, B_TRUE },
77 { "OCTET", DSYM_OCTET, B_TRUE },
78 { "IP", DSYM_IP, B_TRUE },
79 { "NUMBER", DSYM_NUMBER, B_TRUE },
80 { "BOOL", DSYM_BOOL, B_TRUE },
81 { "INCLUDE", DSYM_INCLUDE, B_FALSE },
82 { "UNUMBER8", DSYM_UNUMBER8, B_TRUE },
83 { "UNUMBER16", DSYM_UNUMBER16, B_TRUE },
75 { "ASCII", DSYM_ASCII, B_TRUE },
76 { "OCTET", DSYM_OCTET, B_TRUE },
77 { "IP", DSYM_IP, B_TRUE },
78 { "NUMBER", DSYM_NUMBER, B_TRUE },
79 { "BOOL", DSYM_BOOL, B_TRUE },
80 { "INCLUDE", DSYM_INCLUDE, B_FALSE },
81 { "UNUMBER8", DSYM_UNUMBER8, B_TRUE },
82 { "UNUMBER16", DSYM_UNUMBER16, B_TRUE },
83 { "UNUMBER24", DSYM_UNUMBER24, B_TRUE },
84 { "UNUMBER32", DSYM_UNUMBER32, B_TRUE },
85 { "UNUMBER64", DSYM_UNUMBER64, B_TRUE },
86 { "SNUMBER8", DSYM_SNUMBER8, B_TRUE },
87 { "SNUMBER16", DSYM_SNUMBER16, B_TRUE },
88 { "SNUMBER32", DSYM_SNUMBER32, B_TRUE },
84 { "UNUMBER32", DSYM_UNUMBER32, B_TRUE },
85 { "UNUMBER64", DSYM_UNUMBER64, B_TRUE },
86 { "SNUMBER8", DSYM_SNUMBER8, B_TRUE },
87 { "SNUMBER16", DSYM_SNUMBER16, B_TRUE },
88 { "SNUMBER32", DSYM_SNUMBER32, B_TRUE },
89 { "SNUMBER64", DSYM_SNUMBER64, B_TRUE }
89 { "SNUMBER64", DSYM_SNUMBER64, B_TRUE },
90 { "IPV6", DSYM_IPV6, B_TRUE },
91 { "DUID", DSYM_DUID, B_TRUE },
92 { "DOMAIN", DSYM_DOMAIN, B_TRUE }
90};
91
92/*
93 * symbol delimiters and constants
94 */
95#define DSYM_CLASS_DEL " \t\n"
96#define DSYM_FIELD_DEL ","
97#define DSYM_VENDOR_DEL '='
98#define DSYM_QUOTE '"'
99
100/*
101 * dsym_trim(): trims all whitespace from either side of a string
102 *
103 * input: char **: a pointer to a string to trim of whitespace.
104 * output: none
105 */
93};
94
95/*
96 * symbol delimiters and constants
97 */
98#define DSYM_CLASS_DEL " \t\n"
99#define DSYM_FIELD_DEL ","
100#define DSYM_VENDOR_DEL '='
101#define DSYM_QUOTE '"'
102
103/*
104 * dsym_trim(): trims all whitespace from either side of a string
105 *
106 * input: char **: a pointer to a string to trim of whitespace.
107 * output: none
108 */
109
106static void
107dsym_trim(char **str)
108{
109
110 char *tmpstr = *str;
111
112 /*
113 * Trim all whitespace from the front of the string.

--- 34 unchanged lines hidden (view full) ---

148 * note: original string is modified
149 *
150 * input: char *: string in which to search for tokens
151 * char *: list of possible token delimiter characters
152 * char **: location for next call to routine
153 * boolean_t: should delimiters be ignored if within quoted string?
154 * output: char *: token, or NULL if no more tokens
155 */
110static void
111dsym_trim(char **str)
112{
113
114 char *tmpstr = *str;
115
116 /*
117 * Trim all whitespace from the front of the string.

--- 34 unchanged lines hidden (view full) ---

152 * note: original string is modified
153 *
154 * input: char *: string in which to search for tokens
155 * char *: list of possible token delimiter characters
156 * char **: location for next call to routine
157 * boolean_t: should delimiters be ignored if within quoted string?
158 * output: char *: token, or NULL if no more tokens
159 */
160
156static char *
157dsym_get_token(char *str, char *dels, char **lasts, boolean_t quote_support)
158{
159
160 char *ptr = str;
161 char *del;
162 boolean_t found = B_FALSE;
163 boolean_t in_quote = B_FALSE;

--- 45 unchanged lines hidden (view full) ---

209
210/*
211 * dsym_get_long(): given a numeric string, returns its long value
212 *
213 * input: const char *: the numeric string
214 * long *: the return location for the long value
215 * output: DSYM_SUCCESS, DSYM_VALUE_OUT_OF_RANGE or DSYM_SYNTAX_ERROR
216 */
161static char *
162dsym_get_token(char *str, char *dels, char **lasts, boolean_t quote_support)
163{
164
165 char *ptr = str;
166 char *del;
167 boolean_t found = B_FALSE;
168 boolean_t in_quote = B_FALSE;

--- 45 unchanged lines hidden (view full) ---

214
215/*
216 * dsym_get_long(): given a numeric string, returns its long value
217 *
218 * input: const char *: the numeric string
219 * long *: the return location for the long value
220 * output: DSYM_SUCCESS, DSYM_VALUE_OUT_OF_RANGE or DSYM_SYNTAX_ERROR
221 */
222
217static dsym_errcode_t
218dsym_get_long(const char *str, long *val)
219{
220
221 int ret = DSYM_SUCCESS;
222 int i;
223
224 for (i = 0; str[i] != '\0'; i++) {

--- 12 unchanged lines hidden (view full) ---

237}
238
239/*
240 * dsym_free_classes(): frees the classes allocated by dsym_parse_classes()
241 *
242 * input: dhcp_classes_t *: pointer to structure containing classes to free
243 * output: none
244 */
223static dsym_errcode_t
224dsym_get_long(const char *str, long *val)
225{
226
227 int ret = DSYM_SUCCESS;
228 int i;
229
230 for (i = 0; str[i] != '\0'; i++) {

--- 12 unchanged lines hidden (view full) ---

243}
244
245/*
246 * dsym_free_classes(): frees the classes allocated by dsym_parse_classes()
247 *
248 * input: dhcp_classes_t *: pointer to structure containing classes to free
249 * output: none
250 */
251
245void
246dsym_free_classes(dhcp_classes_t *classes)
247{
248
249 int i;
250
251 if (classes->dc_names == NULL) {
252 return;

--- 12 unchanged lines hidden (view full) ---

265 * dsym_parse_classes(): given a "Vendor" class string, builds and returns
266 * the list of vendor classes
267 *
268 * input: char *: the "Vendor" class string
269 * dhcp_classes_t *: pointer to the classes structure
270 * output: DSYM_SUCCESS, DSYM_INVALID_CAT, DSYM_EXCEEDS_MAX_CLASS_SIZE,
271 * DSYM_EXCEEDS_CLASS_SIZE, DSYM_SYNTAX_ERROR, or DSYM_NO_MEMORY
272 */
252void
253dsym_free_classes(dhcp_classes_t *classes)
254{
255
256 int i;
257
258 if (classes->dc_names == NULL) {
259 return;

--- 12 unchanged lines hidden (view full) ---

272 * dsym_parse_classes(): given a "Vendor" class string, builds and returns
273 * the list of vendor classes
274 *
275 * input: char *: the "Vendor" class string
276 * dhcp_classes_t *: pointer to the classes structure
277 * output: DSYM_SUCCESS, DSYM_INVALID_CAT, DSYM_EXCEEDS_MAX_CLASS_SIZE,
278 * DSYM_EXCEEDS_CLASS_SIZE, DSYM_SYNTAX_ERROR, or DSYM_NO_MEMORY
279 */
280
273static dsym_errcode_t
274dsym_parse_classes(char *ptr, dhcp_classes_t *classes_ret)
275{
276
277 char **classes = NULL;
278 char *cp;
279 int len;
280 int ret = DSYM_SUCCESS;

--- 66 unchanged lines hidden (view full) ---

347 * dsym_get_cat_by_name(): given a category field, returns the pointer to its
348 * entry in the internal category table.
349 *
350 * input: const char *: the category name
351 * dsym_cat_t *: the return location for the pointer to the table entry
352 * boolean_t: case-sensitive name compare
353 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
354 */
281static dsym_errcode_t
282dsym_parse_classes(char *ptr, dhcp_classes_t *classes_ret)
283{
284
285 char **classes = NULL;
286 char *cp;
287 int len;
288 int ret = DSYM_SUCCESS;

--- 66 unchanged lines hidden (view full) ---

355 * dsym_get_cat_by_name(): given a category field, returns the pointer to its
356 * entry in the internal category table.
357 *
358 * input: const char *: the category name
359 * dsym_cat_t *: the return location for the pointer to the table entry
360 * boolean_t: case-sensitive name compare
361 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
362 */
363
355static dsym_errcode_t
356dsym_get_cat_by_name(const char *cat, dsym_cat_t **entry, boolean_t cs)
357{
358
359 dsym_cat_t *entryp = NULL;
360 int ret = DSYM_SUCCESS;
361 int cnt = sizeof (cats) / sizeof (dsym_cat_t);
362 int result;

--- 48 unchanged lines hidden (view full) ---

411/*
412 * dsym_parse_cat(): given a category field, returns the category value
413 * Note: The category must be a valid dhcptab category.
414 *
415 * input: const char *: a category field
416 * dsym_category_t *: the return location for the category value
417 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
418 */
364static dsym_errcode_t
365dsym_get_cat_by_name(const char *cat, dsym_cat_t **entry, boolean_t cs)
366{
367
368 dsym_cat_t *entryp = NULL;
369 int ret = DSYM_SUCCESS;
370 int cnt = sizeof (cats) / sizeof (dsym_cat_t);
371 int result;

--- 48 unchanged lines hidden (view full) ---

420/*
421 * dsym_parse_cat(): given a category field, returns the category value
422 * Note: The category must be a valid dhcptab category.
423 *
424 * input: const char *: a category field
425 * dsym_category_t *: the return location for the category value
426 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
427 */
428
419static dsym_errcode_t
420dsym_parse_cat(const char *field, dsym_category_t *cat)
421{
422
423 dsym_cat_t *entry;
424 int ret;
425
426 ret = dsym_get_cat_by_name(field, &entry, B_TRUE);

--- 17 unchanged lines hidden (view full) ---

444 * dsym_parse_intrange(): given a DHCP integer field, returns the value
445 *
446 * input: const char *: a DHCP code field
447 * int *: the return location for the value
448 * int: the minimum valid value
449 * int: the maximum valid value
450 * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, or DSYM_VALUE_OUT_OF_RANGE
451 */
429static dsym_errcode_t
430dsym_parse_cat(const char *field, dsym_category_t *cat)
431{
432
433 dsym_cat_t *entry;
434 int ret;
435
436 ret = dsym_get_cat_by_name(field, &entry, B_TRUE);

--- 17 unchanged lines hidden (view full) ---

454 * dsym_parse_intrange(): given a DHCP integer field, returns the value
455 *
456 * input: const char *: a DHCP code field
457 * int *: the return location for the value
458 * int: the minimum valid value
459 * int: the maximum valid value
460 * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, or DSYM_VALUE_OUT_OF_RANGE
461 */
462
452static dsym_errcode_t
453dsym_parse_intrange(const char *field, int *intval, int min, int max)
454{
455
456 int ret;
457 long longval;
458
459 ret = dsym_get_long(field, &longval);

--- 10 unchanged lines hidden (view full) ---

470/*
471 * dsym_validate_code(): given a symbol category and code, validates
472 * that the code is valid for the category
473 *
474 * input: dsym_category_t: the symbol category
475 * uint16_t: the symbol code
476 * output: DSYM_SUCCESS, DSYM_INVALID_CAT or DSYM_CODE_OUT_OF_RANGE
477 */
463static dsym_errcode_t
464dsym_parse_intrange(const char *field, int *intval, int min, int max)
465{
466
467 int ret;
468 long longval;
469
470 ret = dsym_get_long(field, &longval);

--- 10 unchanged lines hidden (view full) ---

481/*
482 * dsym_validate_code(): given a symbol category and code, validates
483 * that the code is valid for the category
484 *
485 * input: dsym_category_t: the symbol category
486 * uint16_t: the symbol code
487 * output: DSYM_SUCCESS, DSYM_INVALID_CAT or DSYM_CODE_OUT_OF_RANGE
488 */
489
478static dsym_errcode_t
479dsym_validate_code(dsym_category_t cat, ushort_t code)
480{
481
482 int cnt = sizeof (cats) / sizeof (dsym_cat_t);
483 int i;
484
485 /*

--- 16 unchanged lines hidden (view full) ---

502/*
503 * dsym_validate_granularity(): given a symbol type, validates
504 * that the granularity is valid for the type
505 *
506 * input: dsym_cdtype_t: the symbol type
507 * uchar_t: the symbol granularity
508 * output: DSYM_SUCCESS or DSYM_VALUE_OUT_OF_RANGE
509 */
490static dsym_errcode_t
491dsym_validate_code(dsym_category_t cat, ushort_t code)
492{
493
494 int cnt = sizeof (cats) / sizeof (dsym_cat_t);
495 int i;
496
497 /*

--- 16 unchanged lines hidden (view full) ---

514/*
515 * dsym_validate_granularity(): given a symbol type, validates
516 * that the granularity is valid for the type
517 *
518 * input: dsym_cdtype_t: the symbol type
519 * uchar_t: the symbol granularity
520 * output: DSYM_SUCCESS or DSYM_VALUE_OUT_OF_RANGE
521 */
522
510static dsym_errcode_t
511dsym_validate_granularity(dsym_cdtype_t type, uchar_t gran)
512{
513 /*
514 * We only need to check for a 0 with non-boolean types, as
515 * anything else is already validated by the ranges passed to
516 * dsym_parse_intrange() in dsym_parse_field().
517 */

--- 7 unchanged lines hidden (view full) ---

525 * dsym_get_type_by_name(): given a type field, returns the pointer to its
526 * entry in the internal type table.
527 *
528 * input: const char *: the type name
529 * dsym_type_t *: the return location for the pointer to the table entry
530 * boolean_t: case-sensitive name compare
531 * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE
532 */
523static dsym_errcode_t
524dsym_validate_granularity(dsym_cdtype_t type, uchar_t gran)
525{
526 /*
527 * We only need to check for a 0 with non-boolean types, as
528 * anything else is already validated by the ranges passed to
529 * dsym_parse_intrange() in dsym_parse_field().
530 */

--- 7 unchanged lines hidden (view full) ---

538 * dsym_get_type_by_name(): given a type field, returns the pointer to its
539 * entry in the internal type table.
540 *
541 * input: const char *: the type name
542 * dsym_type_t *: the return location for the pointer to the table entry
543 * boolean_t: case-sensitive name compare
544 * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE
545 */
546
533static dsym_errcode_t
534dsym_get_type_by_name(const char *type, dsym_type_t **entry, boolean_t cs)
535{
536 int cnt = sizeof (types) / sizeof (dsym_type_t);
537 int result;
538 int i;
539
540 for (i = 0; i < cnt; i++) {

--- 15 unchanged lines hidden (view full) ---

556
557/*
558 * dsym_parse_type(): given a DHCP type string, returns the type id
559 *
560 * input: char *: a DHCP type string
561 * dsym_cdtype_t *: the return location for the type id
562 * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE
563 */
547static dsym_errcode_t
548dsym_get_type_by_name(const char *type, dsym_type_t **entry, boolean_t cs)
549{
550 int cnt = sizeof (types) / sizeof (dsym_type_t);
551 int result;
552 int i;
553
554 for (i = 0; i < cnt; i++) {

--- 15 unchanged lines hidden (view full) ---

570
571/*
572 * dsym_parse_type(): given a DHCP type string, returns the type id
573 *
574 * input: char *: a DHCP type string
575 * dsym_cdtype_t *: the return location for the type id
576 * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE
577 */
578
564static dsym_errcode_t
565dsym_parse_type(char *field, dsym_cdtype_t *type)
566{
567
568 dsym_type_t *entry;
569 int ret;
570
571 ret = dsym_get_type_by_name(field, &entry, B_TRUE);

--- 15 unchanged lines hidden (view full) ---

587
588/*
589 * dsym_free_fields(): frees an array of fields allocated by
590 * dsym_init_parser().
591 *
592 * input: char **: array of fields to free
593 * output: none
594 */
579static dsym_errcode_t
580dsym_parse_type(char *field, dsym_cdtype_t *type)
581{
582
583 dsym_type_t *entry;
584 int ret;
585
586 ret = dsym_get_type_by_name(field, &entry, B_TRUE);

--- 15 unchanged lines hidden (view full) ---

602
603/*
604 * dsym_free_fields(): frees an array of fields allocated by
605 * dsym_init_parser().
606 *
607 * input: char **: array of fields to free
608 * output: none
609 */
610
595void
596dsym_free_fields(char **fields)
597{
598 int i;
599 if (fields != NULL) {
600 for (i = 0; i < DSYM_NUM_FIELDS; i++) {
601 free(fields[i]);
602 }
603 free(fields);
604 }
605}
606
607/*
608 * dsym_close_parser(): free up all resources associated with the parser
609 *
610 * input: char **: the fields allocated by dsym_init_parser()
611 * dhcp_symbol_t *: the structure populated by dsym_init_parser()
612 * output: none
613 */
611void
612dsym_free_fields(char **fields)
613{
614 int i;
615 if (fields != NULL) {
616 for (i = 0; i < DSYM_NUM_FIELDS; i++) {
617 free(fields[i]);
618 }
619 free(fields);
620 }
621}
622
623/*
624 * dsym_close_parser(): free up all resources associated with the parser
625 *
626 * input: char **: the fields allocated by dsym_init_parser()
627 * dhcp_symbol_t *: the structure populated by dsym_init_parser()
628 * output: none
629 */
630
614void
615dsym_close_parser(char **fields, dhcp_symbol_t *sym)
616{
617 dsym_free_fields(fields);
618 dsym_free_classes(&sym->ds_classes);
619}
620
621/*
622 * dsym_init_parser(): initializes the structures used to parse a symbol
623 * value.
624 *
625 * input: const char *: the symbol name
626 * const char *: the symbol value in dhcptab format
627 * char ***: the return location for the symbol fields
628 * dhcp_symbol_t *: the structure which eventually will
629 * be the repository for the parsed symbol data
630 * output: int: DSYM_SUCCESS, DYSM_NO_MEMORY, DSYM_NULL_FIELD or
631 * DSYM_TOO_MANY_FIELDS
632 */
631void
632dsym_close_parser(char **fields, dhcp_symbol_t *sym)
633{
634 dsym_free_fields(fields);
635 dsym_free_classes(&sym->ds_classes);
636}
637
638/*
639 * dsym_init_parser(): initializes the structures used to parse a symbol
640 * value.
641 *
642 * input: const char *: the symbol name
643 * const char *: the symbol value in dhcptab format
644 * char ***: the return location for the symbol fields
645 * dhcp_symbol_t *: the structure which eventually will
646 * be the repository for the parsed symbol data
647 * output: int: DSYM_SUCCESS, DYSM_NO_MEMORY, DSYM_NULL_FIELD or
648 * DSYM_TOO_MANY_FIELDS
649 */
650
633dsym_errcode_t
634dsym_init_parser(const char *name, const char *value, char ***fields_ret,
635 dhcp_symbol_t *sym)
636{
637
638 int ret = DSYM_SUCCESS;
639 char *cp;
640 char *next;

--- 64 unchanged lines hidden (view full) ---

705 * char **: symbol fields initialized by dsym_init_parser()
706 * dhcp_symbol_t *: the structure which will be the repository
707 * for the parsed field
708 * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, DSYM_CODE_OUT_OF_RANGE,
709 * DSYM_INVALID_CAT, DSYM_INVALID_TYPE, DSYM_EXCEEDS_CLASS_SIZE,
710 * DSYM_EXCEEDS_MAX_CLASS_SIZE, DSYM_NO_MEMORY,
711 * DSYM_INVALID_FIELD_NUM, DSYM_VALUE_OUT_OF_RANGE
712 */
651dsym_errcode_t
652dsym_init_parser(const char *name, const char *value, char ***fields_ret,
653 dhcp_symbol_t *sym)
654{
655
656 int ret = DSYM_SUCCESS;
657 char *cp;
658 char *next;

--- 64 unchanged lines hidden (view full) ---

723 * char **: symbol fields initialized by dsym_init_parser()
724 * dhcp_symbol_t *: the structure which will be the repository
725 * for the parsed field
726 * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, DSYM_CODE_OUT_OF_RANGE,
727 * DSYM_INVALID_CAT, DSYM_INVALID_TYPE, DSYM_EXCEEDS_CLASS_SIZE,
728 * DSYM_EXCEEDS_MAX_CLASS_SIZE, DSYM_NO_MEMORY,
729 * DSYM_INVALID_FIELD_NUM, DSYM_VALUE_OUT_OF_RANGE
730 */
731
713dsym_errcode_t
714dsym_parse_field(int field_num, char **fields, dhcp_symbol_t *sym)
715{
716
717 int ret = DSYM_SUCCESS;
718 int intval;
719
720 switch (field_num) {

--- 52 unchanged lines hidden (view full) ---

773 * for the parsed field
774 * int *: last field processed
775 * boolean_t: parse all fields even though errors occur?
776 * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, DSYM_CODE_OUT_OF_RANGE,
777 * DSYM_INVALID_CAT, DSYM_INVALID_TYPE, DSYM_EXCEEDS_CLASS_SIZE,
778 * DSYM_EXCEEDS_MAX_CLASS_SIZE, DSYM_NO_MEMORY
779 * DSYM_INVALID_FIELD_NUM, DSYM_VALUE_OUT_OF_RANGE
780 */
732dsym_errcode_t
733dsym_parse_field(int field_num, char **fields, dhcp_symbol_t *sym)
734{
735
736 int ret = DSYM_SUCCESS;
737 int intval;
738
739 switch (field_num) {

--- 52 unchanged lines hidden (view full) ---

792 * for the parsed field
793 * int *: last field processed
794 * boolean_t: parse all fields even though errors occur?
795 * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, DSYM_CODE_OUT_OF_RANGE,
796 * DSYM_INVALID_CAT, DSYM_INVALID_TYPE, DSYM_EXCEEDS_CLASS_SIZE,
797 * DSYM_EXCEEDS_MAX_CLASS_SIZE, DSYM_NO_MEMORY
798 * DSYM_INVALID_FIELD_NUM, DSYM_VALUE_OUT_OF_RANGE
799 */
800
781dsym_errcode_t
782dsym_parser(char **fields, dhcp_symbol_t *sym, int *lastField,
783 boolean_t bestEffort)
784{
785
786 int ret = DSYM_SUCCESS;
787 int tret = DSYM_SUCCESS;
788 int i;

--- 24 unchanged lines hidden (view full) ---

813/*
814 * dsym_get_cat_id(): given a category string, return the associated id.
815 *
816 * input: const char *: the category name
817 * dsym_category_t *: the return location for the id
818 * boolean_t: case-sensitive name compare
819 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
820 */
801dsym_errcode_t
802dsym_parser(char **fields, dhcp_symbol_t *sym, int *lastField,
803 boolean_t bestEffort)
804{
805
806 int ret = DSYM_SUCCESS;
807 int tret = DSYM_SUCCESS;
808 int i;

--- 24 unchanged lines hidden (view full) ---

833/*
834 * dsym_get_cat_id(): given a category string, return the associated id.
835 *
836 * input: const char *: the category name
837 * dsym_category_t *: the return location for the id
838 * boolean_t: case-sensitive name compare
839 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
840 */
841
821dsym_errcode_t
822dsym_get_cat_id(const char *cat, dsym_category_t *id, boolean_t cs)
823{
824
825 dsym_cat_t *entry;
826 int ret;
827
828 ret = dsym_get_cat_by_name(cat, &entry, cs);

--- 9 unchanged lines hidden (view full) ---

838 * ranges.
839 *
840 * input: const char *: the category name
841 * ushort *: return location for the minimum code value.
842 * ushort *: return location for the maximum code value.
843 * boolean_t: case-sensitive name compare
844 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
845 */
842dsym_errcode_t
843dsym_get_cat_id(const char *cat, dsym_category_t *id, boolean_t cs)
844{
845
846 dsym_cat_t *entry;
847 int ret;
848
849 ret = dsym_get_cat_by_name(cat, &entry, cs);

--- 9 unchanged lines hidden (view full) ---

859 * ranges.
860 *
861 * input: const char *: the category name
862 * ushort *: return location for the minimum code value.
863 * ushort *: return location for the maximum code value.
864 * boolean_t: case-sensitive name compare
865 * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT
866 */
867
846dsym_errcode_t
847dsym_get_code_ranges(const char *cat, ushort_t *min, ushort_t *max,
848 boolean_t cs)
849{
850
851 dsym_cat_t *entry;
852 int ret;
853

--- 9 unchanged lines hidden (view full) ---

863/*
864 * dsym_get_type_id(): given a type string, return the associated type id.
865 *
866 * input: const char *: the type name
867 * dsym_cdtype_t *: the return location for the id
868 * boolean_t: case-sensitive name compare
869 * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE
870 */
868dsym_errcode_t
869dsym_get_code_ranges(const char *cat, ushort_t *min, ushort_t *max,
870 boolean_t cs)
871{
872
873 dsym_cat_t *entry;
874 int ret;
875

--- 9 unchanged lines hidden (view full) ---

885/*
886 * dsym_get_type_id(): given a type string, return the associated type id.
887 *
888 * input: const char *: the type name
889 * dsym_cdtype_t *: the return location for the id
890 * boolean_t: case-sensitive name compare
891 * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE
892 */
893
871dsym_errcode_t
872dsym_get_type_id(const char *type, dsym_cdtype_t *id, boolean_t cs)
873{
874
875 dsym_type_t *entry;
876 int ret;
877
878 ret = dsym_get_type_by_name(type, &entry, cs);
879 if (ret == DSYM_SUCCESS) {
880 *id = entry->dt_id;
881 }
882
883 return (ret);
884}
894dsym_errcode_t
895dsym_get_type_id(const char *type, dsym_cdtype_t *id, boolean_t cs)
896{
897
898 dsym_type_t *entry;
899 int ret;
900
901 ret = dsym_get_type_by_name(type, &entry, cs);
902 if (ret == DSYM_SUCCESS) {
903 *id = entry->dt_id;
904 }
905
906 return (ret);
907}