Blame source/uds/indexLayoutParser.h

Packit b55c50
/*
Packit b55c50
 * Copyright (c) 2020 Red Hat, Inc.
Packit b55c50
 *
Packit b55c50
 * This program is free software; you can redistribute it and/or
Packit b55c50
 * modify it under the terms of the GNU General Public License
Packit b55c50
 * as published by the Free Software Foundation; either version 2
Packit b55c50
 * of the License, or (at your option) any later version.
Packit b55c50
 * 
Packit b55c50
 * This program is distributed in the hope that it will be useful,
Packit b55c50
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b55c50
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b55c50
 * GNU General Public License for more details.
Packit b55c50
 * 
Packit b55c50
 * You should have received a copy of the GNU General Public License
Packit b55c50
 * along with this program; if not, write to the Free Software
Packit b55c50
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit b55c50
 * 02110-1301, USA. 
Packit b55c50
 *
Packit b55c50
 * $Id: //eng/uds-releases/jasper/src/uds/indexLayoutParser.h#1 $
Packit b55c50
 */
Packit b55c50
Packit b55c50
#ifndef INDEX_LAYOUT_PARSER_H
Packit b55c50
#define INDEX_LAYOUT_PARSER_H
Packit b55c50
Packit b55c50
#include "typeDefs.h"
Packit b55c50
Packit b55c50
typedef enum {
Packit b55c50
  LP_STRING    = 0x001,
Packit b55c50
  LP_UINT64    = 0x002,
Packit b55c50
  LP_TYPE_MASK = 0x0FF,
Packit b55c50
  LP_DEFAULT   = 0x100,
Packit b55c50
} LPType;
Packit b55c50
Packit b55c50
typedef struct layoutParameter {
Packit b55c50
  const char *name;
Packit b55c50
  LPType      type;
Packit b55c50
  union {
Packit b55c50
    char     **str;
Packit b55c50
    uint64_t  *num;
Packit b55c50
  } value;
Packit b55c50
  bool        seen;
Packit b55c50
} LayoutParameter;
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Function to parse an index layout specification.
Packit b55c50
 *
Packit b55c50
 * This parser treats the specification as a set of name=value parameters
Packit b55c50
 * or, in the absence of an '=' character, a single value for a default
Packit b55c50
 * parameter. The list of acceptable parameters is specified as an array
Packit b55c50
 * of LayoutParameter entries. Each such parameter contains the address
Packit b55c50
 * of the variable in which the value is to be stored.
Packit b55c50
 *
Packit b55c50
 * @param info          A copy of the index layout specification that
Packit b55c50
 *                        will be altered by the parser to insert null
Packit b55c50
 *                        characters after each value. Note that string
Packit b55c50
 *                        parameter values will point into the memory of
Packit b55c50
 *                        this string, so this specification cannot be
Packit b55c50
 *                        deallocated until all uses of the parameter
Packit b55c50
 *                        values are over.
Packit b55c50
 * @param params        The table of parameters the caller expects to
Packit b55c50
 *                        find in the ``info'' string. Currently this
Packit b55c50
 *                        parser can handle string and uint64_t values.
Packit b55c50
 * @param count         The size of the parameter table.
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS or an error code, particularly
Packit b55c50
 *      UDS_INDEX_NAME_REQUIRED for all parsing errors.
Packit b55c50
 **/
Packit b55c50
int parseLayoutString(char *info, LayoutParameter *params, size_t count)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
#endif // INDEX_LAYOUT_PARSER_H