Reindented server/core/filter.c
This commit is contained in:
@ -56,7 +56,9 @@ filter_alloc(char *name, char *module)
|
||||
FILTER_DEF *filter;
|
||||
|
||||
if ((filter = (FILTER_DEF *)malloc(sizeof(FILTER_DEF))) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
filter->name = strdup(name);
|
||||
filter->module = strdup(module);
|
||||
filter->filter = NULL;
|
||||
@ -102,8 +104,10 @@ FILTER_DEF *ptr;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if (ptr)
|
||||
{
|
||||
ptr->next = filter->next;
|
||||
}
|
||||
}
|
||||
spinlock_release(&filter_spin);
|
||||
|
||||
/* Clean up session and free the memory */
|
||||
@ -130,7 +134,9 @@ FILTER_DEF *filter;
|
||||
while (filter)
|
||||
{
|
||||
if (strcmp(filter->name, name) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
filter = filter->next;
|
||||
}
|
||||
spinlock_release(&filter_spin);
|
||||
@ -146,7 +152,9 @@ int
|
||||
filter_standard_parameter(char *name)
|
||||
{
|
||||
if (strcmp(name, "type") == 0 || strcmp(name, "module") == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -172,13 +180,19 @@ int i;
|
||||
{
|
||||
dcb_printf(dcb, "\tOptions: ");
|
||||
for (i = 0; ptr->options && ptr->options[i]; i++)
|
||||
{
|
||||
dcb_printf(dcb, "%s ", ptr->options[i]);
|
||||
}
|
||||
dcb_printf(dcb, "\n");
|
||||
}
|
||||
if (ptr->obj && ptr->filter)
|
||||
{
|
||||
ptr->obj->diagnostics(ptr->filter, NULL, dcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb_printf(dcb, "\tModule not loaded.\n");
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
spinlock_release(&filter_spin);
|
||||
@ -201,12 +215,16 @@ int i;
|
||||
{
|
||||
dcb_printf(dcb, "\tOptions: ");
|
||||
for (i = 0; filter->options && filter->options[i]; i++)
|
||||
{
|
||||
dcb_printf(dcb, "%s ", filter->options[i]);
|
||||
}
|
||||
dcb_printf(dcb, "\n");
|
||||
}
|
||||
if (filter->obj && filter->filter)
|
||||
{
|
||||
filter->obj->diagnostics(filter->filter, NULL, dcb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List all filters in a tabular form to a DCB
|
||||
@ -233,12 +251,17 @@ int i;
|
||||
dcb_printf(dcb, "%-19s | %-15s | ",
|
||||
ptr->name, ptr->module);
|
||||
for (i = 0; ptr->options && ptr->options[i]; i++)
|
||||
{
|
||||
dcb_printf(dcb, "%s ", ptr->options[i]);
|
||||
}
|
||||
dcb_printf(dcb, "\n");
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if (allFilters)
|
||||
dcb_printf(dcb, "--------------------+-----------------+----------------------------------------\n\n");
|
||||
{
|
||||
dcb_printf(dcb,
|
||||
"--------------------+-----------------+----------------------------------------\n\n");
|
||||
}
|
||||
spinlock_release(&filter_spin);
|
||||
}
|
||||
|
||||
@ -263,9 +286,10 @@ int i;
|
||||
else
|
||||
{
|
||||
for (i = 0; filter->options[i]; i++)
|
||||
{
|
||||
;
|
||||
filter->options = (char **)realloc(filter->options,
|
||||
(i + 2) * sizeof(char *));
|
||||
}
|
||||
filter->options = (char **)realloc(filter->options, (i + 2) * sizeof(char *));
|
||||
filter->options[i] = strdup(option);
|
||||
filter->options[i+1] = NULL;
|
||||
}
|
||||
@ -293,7 +317,9 @@ int i;
|
||||
else
|
||||
{
|
||||
for (i = 0; filter->parameters[i]; i++)
|
||||
{
|
||||
;
|
||||
}
|
||||
filter->parameters = (FILTER_PARAMETER **)realloc(filter->parameters,
|
||||
(i + 2) * sizeof(FILTER_PARAMETER *));
|
||||
}
|
||||
@ -401,7 +427,9 @@ UPSTREAM *me = NULL;
|
||||
* not require to see results and can be left out of the chain.
|
||||
*/
|
||||
if (filter->obj->setUpstream == NULL)
|
||||
{
|
||||
return upstream;
|
||||
}
|
||||
|
||||
if (filter->obj->clientReply != NULL)
|
||||
{
|
||||
|
||||
@ -41,7 +41,8 @@ typedef void *FILTER;
|
||||
/**
|
||||
* The structure used to pass name, value pairs to the filter instances
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
char *name; /**< Name of the parameter */
|
||||
char *value; /**< Value of the parameter */
|
||||
} FILTER_PARAMETER;
|
||||
@ -69,7 +70,8 @@ typedef struct {
|
||||
*
|
||||
* @see load_module
|
||||
*/
|
||||
typedef struct filter_object {
|
||||
typedef struct filter_object
|
||||
{
|
||||
FILTER *(*createInstance)(char **options, FILTER_PARAMETER **);
|
||||
void *(*newSession)(FILTER *instance, SESSION *session);
|
||||
void (*closeSession)(FILTER *instance, void *fsession);
|
||||
@ -92,17 +94,16 @@ typedef struct filter_object {
|
||||
* This is basically the link between a plugin to load and the
|
||||
* optons to pass to that plugin.
|
||||
*/
|
||||
typedef struct filter_def {
|
||||
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_PARAMETER **parameters; /**< The filter parameters */
|
||||
FILTER filter; /**< The runtime filter */
|
||||
FILTER_OBJECT *obj; /**< The "MODULE_OBJECT" for the filter */
|
||||
SPINLOCK spin; /**< Spinlock to protect the filter definition */
|
||||
struct filter_def
|
||||
*next; /**< Next filter in the chain of all filters */
|
||||
struct filter_def *next; /**< Next filter in the chain of all filters */
|
||||
} FILTER_DEF;
|
||||
|
||||
FILTER_DEF *filter_alloc(char *, char *);
|
||||
@ -117,4 +118,5 @@ int filter_standard_parameter(char *);
|
||||
void dprintAllFilters(DCB *);
|
||||
void dprintFilter(DCB *, FILTER_DEF *);
|
||||
void dListFilters(DCB *);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user