Blame source/uds/indexLayoutParser.h

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