Blame common/expr.h

Packit 6bd9ab
/*
Packit 6bd9ab
   expr.h - limited shell-like expression parsing functions
Packit 6bd9ab
   This file is part of the nss-pam-ldapd library.
Packit 6bd9ab
Packit 6bd9ab
   Copyright (C) 2009, 2012 Arthur de Jong
Packit 6bd9ab
Packit 6bd9ab
   This library is free software; you can redistribute it and/or
Packit 6bd9ab
   modify it under the terms of the GNU Lesser General Public
Packit 6bd9ab
   License as published by the Free Software Foundation; either
Packit 6bd9ab
   version 2.1 of the License, or (at your option) any later version.
Packit 6bd9ab
Packit 6bd9ab
   This library is distributed in the hope that it will be useful,
Packit 6bd9ab
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6bd9ab
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6bd9ab
   Lesser General Public License for more details.
Packit 6bd9ab
Packit 6bd9ab
   You should have received a copy of the GNU Lesser General Public
Packit 6bd9ab
   License along with this library; if not, write to the Free Software
Packit 6bd9ab
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 6bd9ab
   02110-1301 USA
Packit 6bd9ab
*/
Packit 6bd9ab
Packit 6bd9ab
#ifndef COMMON__EXPR_H
Packit 6bd9ab
#define COMMON__EXPR_H 1
Packit 6bd9ab
Packit 6bd9ab
#include "compat/attrs.h"
Packit 6bd9ab
#include "common/set.h"
Packit 6bd9ab
Packit 6bd9ab
typedef const char *(*expr_expander_func) (const char *name, void *expander_arg);
Packit 6bd9ab
Packit 6bd9ab
/* Parse the expression and store the result in buffer, using the
Packit 6bd9ab
   expander function to expand variable names to values. If the expression
Packit 6bd9ab
   is invalid or the result didn't fit in the buffer NULL is returned. */
Packit 6bd9ab
MUST_USE const char *expr_parse(const char *expr, char *buffer, size_t buflen,
Packit 6bd9ab
                                expr_expander_func expander, void *expander_arg);
Packit 6bd9ab
Packit 6bd9ab
/* Return the variable names that are used in expr. If set is NULL a new one
Packit 6bd9ab
   is allocated, otherwise the passed set is added to. */
Packit 6bd9ab
SET *expr_vars(const char *expr, SET *set);
Packit 6bd9ab
Packit 6bd9ab
#endif /* not _COMMON__ */