Addition of the module utilities functions
This commit is contained in:
@ -93,6 +93,8 @@ typedef struct gwbuf {
|
||||
/*< Consume a number of bytes in the buffer */
|
||||
#define GWBUF_CONSUME(b, bytes) (b)->start += bytes
|
||||
|
||||
#define GWBUF_RTRIM(b, bytes) (b)->end -= bytes
|
||||
|
||||
#define GWBUF_TYPE(b) (b)->gwbuf_type
|
||||
/*<
|
||||
* Function prototypes for the API to maniplate the buffers
|
||||
|
||||
@ -37,6 +37,15 @@
|
||||
* is to make it a void * externally.
|
||||
*/
|
||||
typedef void *FILTER;
|
||||
|
||||
/**
|
||||
* The structure used to pass name, value pairs to the filter instances
|
||||
*/
|
||||
typedef struct {
|
||||
char *name; /**< Name of the parameter */
|
||||
char *value; /**< Value of the parameter */
|
||||
} FILTER_PARAMETER;
|
||||
|
||||
/**
|
||||
* @verbatim
|
||||
* The "module object" structure for a query router module
|
||||
@ -60,7 +69,7 @@ typedef void *FILTER;
|
||||
* @see load_module
|
||||
*/
|
||||
typedef struct filter_object {
|
||||
FILTER *(*createInstance)(char **options);
|
||||
FILTER *(*createInstance)(char **options, FILTER_PARAMETER **);
|
||||
void *(*newSession)(FILTER *instance, SESSION *session);
|
||||
void (*closeSession)(FILTER *instance, void *fsession);
|
||||
void (*freeSession)(FILTER *instance, void *fsession);
|
||||
@ -75,7 +84,6 @@ typedef struct filter_object {
|
||||
* file modinfo.h.
|
||||
*/
|
||||
#define FILTER_VERSION {1, 0, 0}
|
||||
|
||||
/**
|
||||
* The definition of a filter form the configuration file.
|
||||
* This is basically the link between a plugin to load and the
|
||||
@ -85,6 +93,8 @@ typedef struct filter_def {
|
||||
char *name; /*< The Filter name */
|
||||
char *module; /*< The module to load */
|
||||
char **options; /*< The options set for this filter */
|
||||
FILTER_PARAMETER
|
||||
**parameters; /*< The filter parameters */
|
||||
FILTER filter;
|
||||
FILTER_OBJECT *obj;
|
||||
SPINLOCK spin;
|
||||
@ -96,6 +106,7 @@ FILTER_DEF *filter_alloc(char *, char *);
|
||||
void filter_free(FILTER_DEF *);
|
||||
FILTER_DEF *filter_find(char *);
|
||||
void filterAddOption(FILTER_DEF *, char *);
|
||||
void filterAddParameter(FILTER_DEF *, char *, char *);
|
||||
DOWNSTREAM *filterApply(FILTER_DEF *, SESSION *, DOWNSTREAM *);
|
||||
void dprintAllFilters(DCB *);
|
||||
void dprintFilter(DCB *, FILTER_DEF *);
|
||||
|
||||
36
server/include/modutil.h
Normal file
36
server/include/modutil.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef _MODUTIL_H
|
||||
#define _MODUTIL_H
|
||||
/*
|
||||
* This file is distributed as part of MaxScale from SkySQL. It is free
|
||||
* software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation,
|
||||
* version 2.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright SkySQL Ab 2014
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file modutil.h A set of useful routines for module writers
|
||||
*
|
||||
* @verbatim
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* 04/06/14 Mark Riddoch Initial implementation
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
#include <buffer.h>
|
||||
|
||||
extern int modutil_is_SQL(GWBUF *);
|
||||
extern int modutil_extract_SQL(GWBUF *, char **, int *);
|
||||
#endif
|
||||
@ -74,6 +74,17 @@ typedef struct {
|
||||
void *router_session, GWBUF *queue);
|
||||
} DOWNSTREAM;
|
||||
|
||||
/**
|
||||
* The upstream element in the filter chain. This may refer to
|
||||
* another filter or to the protocol implementation.
|
||||
*/
|
||||
typedef struct {
|
||||
void *instance;
|
||||
void *session;
|
||||
int (*write)(void *, void *, GWBUF *);
|
||||
int (*error)(void *);
|
||||
} UPSTREAM;
|
||||
|
||||
/**
|
||||
* Structure used to track the filter instances and sessions of the filters
|
||||
* that are in use within a session.
|
||||
|
||||
Reference in New Issue
Block a user