|
Packit Service |
5956c7 |
/*
|
|
Packit Service |
5956c7 |
* Soft: Keepalived is a failover program for the LVS project
|
|
Packit Service |
5956c7 |
* <www.linuxvirtualserver.org>. It monitor & manipulate
|
|
Packit Service |
5956c7 |
* a loadbalanced server pool using multi-layer checks.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Part: cfreader.c include file.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Author: Alexandre Cassen, <acassen@linux-vs.org>
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
5956c7 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
5956c7 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit Service |
5956c7 |
* See the GNU General Public License for more details.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
5956c7 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
5956c7 |
* as published by the Free Software Foundation; either version
|
|
Packit Service |
5956c7 |
* 2 of the License, or (at your option) any later version.
|
|
Packit Service |
5956c7 |
*
|
|
Packit Service |
5956c7 |
* Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>
|
|
Packit Service |
5956c7 |
*/
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#ifndef _PARSER_H
|
|
Packit Service |
5956c7 |
#define _PARSER_H
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* system includes */
|
|
Packit Service |
5956c7 |
#include <sys/types.h>
|
|
Packit Service |
5956c7 |
#include <stdbool.h>
|
|
Packit Service |
5956c7 |
#include <stdint.h>
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* local includes */
|
|
Packit Service |
5956c7 |
#include "vector.h"
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Global definitions */
|
|
Packit Service |
5956c7 |
#define KEEPALIVED_CONFIG_FILE DEFAULT_CONFIG_FILE
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Maximum config line length */
|
|
Packit Service |
5956c7 |
#define MAXBUF 1024
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Maximum time read_timer can return */
|
|
Packit Service |
5956c7 |
#define TIMER_MAX (ULONG_MAX / TIMER_HZ)
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Configuration test errors. These should be in decreasing order of severity */
|
|
Packit Service |
5956c7 |
typedef enum {
|
|
Packit Service |
5956c7 |
CONFIG_OK,
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* The following mean keepalived cannot run the config */
|
|
Packit Service |
5956c7 |
CONFIG_FILE_NOT_FOUND,
|
|
Packit Service |
5956c7 |
CONFIG_BAD_IF,
|
|
Packit Service |
5956c7 |
CONFIG_FATAL,
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* The following are configuration errors, but keepalived will still run */
|
|
Packit Service |
5956c7 |
CONFIG_MULTIPLE_FILES,
|
|
Packit Service |
5956c7 |
CONFIG_UNKNOWN_KEYWORD,
|
|
Packit Service |
5956c7 |
CONFIG_UNEXPECTED_BOB, /* '{' */
|
|
Packit Service |
5956c7 |
CONFIG_MISSING_BOB, /* '{' */
|
|
Packit Service |
5956c7 |
CONFIG_UNEXPECTED_EOB, /* '}' */
|
|
Packit Service |
5956c7 |
CONFIG_MISSING_EOB, /* '}' */
|
|
Packit Service |
5956c7 |
CONFIG_UNMATCHED_QUOTE,
|
|
Packit Service |
5956c7 |
CONFIG_MISSING_PARAMETER,
|
|
Packit Service |
5956c7 |
CONFIG_INVALID_NUMBER,
|
|
Packit Service |
5956c7 |
CONFIG_GENERAL_ERROR,
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* The following is for script security not enabled when needed */
|
|
Packit Service |
5956c7 |
CONFIG_SECURITY_ERROR,
|
|
Packit Service |
5956c7 |
} config_err_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* keyword definition */
|
|
Packit Service |
5956c7 |
typedef struct _keyword {
|
|
Packit Service |
5956c7 |
const char *string;
|
|
Packit Service |
5956c7 |
void (*handler) (vector_t *);
|
|
Packit Service |
5956c7 |
vector_t *sub;
|
|
Packit Service |
5956c7 |
void (*sub_close_handler) (void);
|
|
Packit Service |
5956c7 |
bool active;
|
|
Packit Service |
5956c7 |
} keyword_t;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* global vars exported */
|
|
Packit Service |
5956c7 |
extern vector_t *keywords;
|
|
Packit Service |
5956c7 |
extern char *config_id;
|
|
Packit Service |
5956c7 |
extern const char *WHITE_SPACE;
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#ifdef _MEM_CHECK_
|
|
Packit Service |
5956c7 |
#define alloc_strvec(str) (memcheck_log("alloc_strvec", str, (__FILE__), (char *)(__FUNCTION__), (__LINE__)), \
|
|
Packit Service |
5956c7 |
alloc_strvec_r(str))
|
|
Packit Service |
5956c7 |
#else
|
|
Packit Service |
5956c7 |
#define alloc_strvec(str) (alloc_strvec_r(str))
|
|
Packit Service |
5956c7 |
#endif
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
/* Prototypes */
|
|
Packit Service |
5956c7 |
extern void report_config_error(config_err_t, const char *format, ...)
|
|
Packit Service |
5956c7 |
__attribute__((format (printf, 2, 3)));
|
|
Packit Service |
5956c7 |
extern config_err_t get_config_status(void);
|
|
Packit Service |
5956c7 |
extern bool read_int(const char *, int *, int, int, bool);
|
|
Packit Service |
5956c7 |
extern bool read_unsigned(const char *, unsigned *, unsigned, unsigned, bool);
|
|
Packit Service |
5956c7 |
extern bool read_unsigned64(const char *, uint64_t *, uint64_t, uint64_t, bool);
|
|
Packit Service |
5956c7 |
extern bool read_double(const char *, double *, double, double, bool);
|
|
Packit Service |
5956c7 |
extern bool read_int_strvec(const vector_t *, size_t, int *, int, int, bool);
|
|
Packit Service |
5956c7 |
extern bool read_unsigned_strvec(const vector_t *, size_t, unsigned *, unsigned, unsigned, bool);
|
|
Packit Service |
5956c7 |
extern bool read_unsigned64_strvec(const vector_t *, size_t, uint64_t *, uint64_t, uint64_t, bool);
|
|
Packit Service |
5956c7 |
extern bool read_unsigned_base_strvec(const vector_t *, size_t, int, unsigned *, unsigned, unsigned, bool);
|
|
Packit Service |
5956c7 |
extern bool read_double_strvec(const vector_t *, size_t, double *, double, double, bool);
|
|
Packit Service |
5956c7 |
extern void install_keyword_root(const char *, void (*handler) (vector_t *), bool);
|
|
Packit Service |
5956c7 |
extern void install_root_end_handler(void (*handler) (void));
|
|
Packit Service |
5956c7 |
extern void install_sublevel(void);
|
|
Packit Service |
5956c7 |
extern void install_sublevel_end(void);
|
|
Packit Service |
5956c7 |
extern void install_sublevel_end_handler(void (*handler) (void));
|
|
Packit Service |
5956c7 |
extern void install_keyword(const char *, void (*handler) (vector_t *));
|
|
Packit Service |
5956c7 |
extern vector_t *alloc_strvec_quoted_escaped(char *);
|
|
Packit Service |
5956c7 |
extern vector_t *alloc_strvec_r(char *);
|
|
Packit Service |
5956c7 |
extern bool check_conf_file(const char*);
|
|
Packit Service |
5956c7 |
extern vector_t *read_value_block(vector_t *);
|
|
Packit Service |
5956c7 |
extern void alloc_value_block(void (*alloc_func) (vector_t *), const char *);
|
|
Packit Service |
5956c7 |
extern void *set_value(vector_t *);
|
|
Packit Service |
5956c7 |
extern bool read_timer(vector_t *, size_t, unsigned long *, unsigned long, unsigned long, bool);
|
|
Packit Service |
5956c7 |
extern int check_true_false(char *);
|
|
Packit Service |
5956c7 |
extern void skip_block(bool);
|
|
Packit Service |
5956c7 |
extern void init_data(const char *, vector_t * (*init_keywords) (void));
|
|
Packit Service |
5956c7 |
|
|
Packit Service |
5956c7 |
#endif
|