2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * The following structure and table are used to define the attributes 2N/A * of a DHCP symbol category. 2N/A * The following structure and table are used to define the attributes 2N/A * of a DHCP symbol type. 2N/A * symbol delimiters and constants 2N/A * dsym_trim(): trims all whitespace from either side of a string 2N/A * input: char **: a pointer to a string to trim of whitespace. 2N/A * Trim all whitespace from the front of the string. 2N/A * Move the str pointer to first non-whitespace char. 2N/A * Check case where the string is nothing but whitespace. 2N/A * Trim all whitespace from the end of the string. 2N/A * terminate after last non-whitespace char. 2N/A * dsym_get_token(): strtok_r() like routine, except consecutive delimiters 2N/A * result in an empty string 2N/A * note: original string is modified 2N/A * input: char *: string in which to search for tokens 2N/A * char *: list of possible token delimiter characters 2N/A * char **: location for next call to routine 2N/A * boolean_t: should delimiters be ignored if within quoted string? 2N/A * output: char *: token, or NULL if no more tokens 2N/A * If incoming string has no tokens return a NULL 2N/A * pointer to signify no more tokens. 2N/A * Loop until either a token has been identified or until end 2N/A * of string has been reached. 2N/A * If pointer currently lies within a quoted string, 2N/A * then do not check for the delimiter. 2N/A * If the pointer is pointing at a delimiter, then 2N/A * check to see if it points to at a quote and update 2N/A * the state appropriately. 2N/A * dsym_get_long(): given a numeric string, returns its long value 2N/A * input: const char *: the numeric string 2N/A * long *: the return location for the long value 2N/A * output: DSYM_SUCCESS, DSYM_VALUE_OUT_OF_RANGE or DSYM_SYNTAX_ERROR 2N/A for (i = 0;
str[i] !=
'\0'; i++) {
2N/A * dsym_free_classes(): frees the classes allocated by dsym_parse_classes() 2N/A * input: dhcp_classes_t *: pointer to structure containing classes to free 2N/A * dsym_parse_classes(): given a "Vendor" class string, builds and returns 2N/A * the list of vendor classes 2N/A * input: char *: the "Vendor" class string 2N/A * dhcp_classes_t *: pointer to the classes structure 2N/A * output: DSYM_SUCCESS, DSYM_INVALID_CAT, DSYM_EXCEEDS_MAX_CLASS_SIZE, 2N/A * DSYM_EXCEEDS_CLASS_SIZE, DSYM_SYNTAX_ERROR, or DSYM_NO_MEMORY 2N/A /* Strip off the quotes */ 2N/A * dsym_get_cat_by_name(): given a category field, returns the pointer to its 2N/A * entry in the internal category table. 2N/A * input: const char *: the category name 2N/A * dsym_cat_t *: the return location for the pointer to the table entry 2N/A * boolean_t: case-sensitive name compare 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT 2N/A * Special code required for the Vendor category, because we 2N/A * allow whitespace between the keyword and the delimiter. 2N/A * If there is no delimiter, then this is an illegal category. 2N/A * dsym_parse_cat(): given a category field, returns the category value 2N/A * Note: The category must be a valid dhcptab category. 2N/A * input: const char *: a category field 2N/A * dsym_category_t *: the return location for the category value 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT 2N/A * Since this routine is meant to be used to parse dhcptab 2N/A * symbol definitions, only a subset of the DHCP categories 2N/A * are valid in this context. 2N/A * dsym_parse_intrange(): given a DHCP integer field, returns the value 2N/A * input: const char *: a DHCP code field 2N/A * int *: the return location for the value 2N/A * int: the minimum valid value 2N/A * int: the maximum valid value 2N/A * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, or DSYM_VALUE_OUT_OF_RANGE 2N/A * dsym_validate_code(): given a symbol category and code, validates 2N/A * that the code is valid for the category 2N/A * input: dsym_category_t: the symbol category 2N/A * uint16_t: the symbol code 2N/A * output: DSYM_SUCCESS, DSYM_INVALID_CAT or DSYM_CODE_OUT_OF_RANGE 2N/A * Find the category entry from the internal table. 2N/A * dsym_validate_granularity(): given a symbol type, validates 2N/A * that the granularity is valid for the type 2N/A * input: dsym_cdtype_t: the symbol type 2N/A * uchar_t: the symbol granularity 2N/A * output: DSYM_SUCCESS or DSYM_VALUE_OUT_OF_RANGE 2N/A * We only need to check for a 0 with non-boolean types, as 2N/A * anything else is already validated by the ranges passed to 2N/A * dsym_parse_intrange() in dsym_parse_field(). 2N/A * dsym_get_type_by_name(): given a type field, returns the pointer to its 2N/A * entry in the internal type table. 2N/A * input: const char *: the type name 2N/A * dsym_type_t *: the return location for the pointer to the table entry 2N/A * boolean_t: case-sensitive name compare 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE 2N/A * dsym_parse_type(): given a DHCP type string, returns the type id 2N/A * input: char *: a DHCP type string 2N/A * dsym_cdtype_t *: the return location for the type id 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE 2N/A * Since this routine is meant to be used to parse dhcptab 2N/A * symbol definitions, only a subset of the DHCP type 2N/A * are valid in this context. 2N/A * dsym_free_fields(): frees an array of fields allocated by 2N/A * dsym_init_parser(). 2N/A * input: char **: array of fields to free 2N/A * dsym_close_parser(): free up all resources associated with the parser 2N/A * input: char **: the fields allocated by dsym_init_parser() 2N/A * dhcp_symbol_t *: the structure populated by dsym_init_parser() 2N/A * dsym_init_parser(): initializes the structures used to parse a symbol 2N/A * input: const char *: the symbol name 2N/A * const char *: the symbol value in dhcptab format 2N/A * char ***: the return location for the symbol fields 2N/A * dhcp_symbol_t *: the structure which eventually will 2N/A * be the repository for the parsed symbol data 2N/A * output: int: DSYM_SUCCESS, DYSM_NO_MEMORY, DSYM_NULL_FIELD or 2N/A * DSYM_TOO_MANY_FIELDS 2N/A * Initialize the symbol structure. 2N/A * dsym_parse_field(): parses the specified symbol field. 2N/A * input: int: the field number to be parsed. 2N/A * char **: symbol fields initialized by dsym_init_parser() 2N/A * dhcp_symbol_t *: the structure which will be the repository 2N/A * for the parsed field 2N/A * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, DSYM_CODE_OUT_OF_RANGE, 2N/A * DSYM_INVALID_CAT, DSYM_INVALID_TYPE, DSYM_EXCEEDS_CLASS_SIZE, 2N/A * DSYM_EXCEEDS_MAX_CLASS_SIZE, DSYM_NO_MEMORY, 2N/A * DSYM_INVALID_FIELD_NUM, DSYM_VALUE_OUT_OF_RANGE 2N/A * dsym_parser(): parses a DHCP symbol value 2N/A * input: char **: symbol fields initialized by dsym_init_parser() 2N/A * dhcp_symbol_t *: the structure which will be the repository 2N/A * for the parsed field 2N/A * int *: last field processed 2N/A * boolean_t: parse all fields even though errors occur? 2N/A * output: int: DSYM_SUCCESS, DSYM_SYNTAX_ERROR, DSYM_CODE_OUT_OF_RANGE, 2N/A * DSYM_INVALID_CAT, DSYM_INVALID_TYPE, DSYM_EXCEEDS_CLASS_SIZE, 2N/A * DSYM_EXCEEDS_MAX_CLASS_SIZE, DSYM_NO_MEMORY 2N/A * DSYM_INVALID_FIELD_NUM, DSYM_VALUE_OUT_OF_RANGE 2N/A * dsym_get_cat_id(): given a category string, return the associated id. 2N/A * input: const char *: the category name 2N/A * dsym_category_t *: the return location for the id 2N/A * boolean_t: case-sensitive name compare 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT 2N/A * dsym_get_code_ranges(): given a category field, returns its valid code 2N/A * input: const char *: the category name 2N/A * ushort *: return location for the minimum code value. 2N/A * ushort *: return location for the maximum code value. 2N/A * boolean_t: case-sensitive name compare 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_CAT 2N/A * dsym_get_type_id(): given a type string, return the associated type id. 2N/A * input: const char *: the type name 2N/A * dsym_cdtype_t *: the return location for the id 2N/A * boolean_t: case-sensitive name compare 2N/A * output: int: DSYM_SUCCESS or DSYM_INVALID_TYPE