projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into next
[paraslash.git]
/
filter_common.c
diff --git
a/filter_common.c
b/filter_common.c
index d83629bd4bf9d2b3f609ba71d36b5c7afcfc04a8..7c71ff39243a7a63f7026c11726418377790c87e 100644
(file)
--- a/
filter_common.c
+++ b/
filter_common.c
@@
-6,6
+6,7
@@
/** \file filter_common.c Common helper functions for filter input/output. */
/** \file filter_common.c Common helper functions for filter input/output. */
+#include <regex.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
@@
-23,17
+24,14
@@
struct filter filters[NUM_SUPPORTED_FILTERS] = {FILTER_ARRAY};
/**
* Call the init function of each supported filter.
/**
* Call the init function of each supported filter.
- *
- * \param all_filters the array of all supported filters.
- *
* \sa filter::init
*/
* \sa filter::init
*/
-void filter_init(
struct filter *all_filters
)
+void filter_init(
void
)
{
int i;
FOR_EACH_SUPPORTED_FILTER(i)
{
int i;
FOR_EACH_SUPPORTED_FILTER(i)
-
all_filters[i].init(all_
filters + i);
+
filters[i].init(
filters + i);
}
/**
}
/**
@@
-46,7
+44,7
@@
void filter_init(struct filter *all_filters)
*/
static void close_filter_callback(struct filter_callback *fcb)
{
*/
static void close_filter_callback(struct filter_callback *fcb)
{
- PARA_NOTICE_LOG("closing filter_callback %p
, data: %p\n", fcb, fcb->data
);
+ PARA_NOTICE_LOG("closing filter_callback %p
\n", fcb
);
list_del(&fcb->node);
fcb->close(fcb);
}
list_del(&fcb->node);
fcb->close(fcb);
}
@@
-102,13
+100,13
@@
static void call_callbacks(struct filter_node *fn, char *inbuf, size_t inlen,
* there is input available for the filter node in question. If the convert
* function consumed some or all of its input data, all registered input
* callbacks are called. Similarly, if a convert function produced output, all
* there is input available for the filter node in question. If the convert
* function consumed some or all of its input data, all registered input
* callbacks are called. Similarly, if a convert function produced output, all
- * registerd output callbacks get called.
+ * register
e
d output callbacks get called.
*
* On errors a (negative) error code is stored in t->error.
*
* \sa filter_node, filter#convert, filter_callback.
*/
*
* On errors a (negative) error code is stored in t->error.
*
* \sa filter_node, filter#convert, filter_callback.
*/
-void filter_p
re
_select(__a_unused struct sched *s, struct task *t)
+void filter_p
ost
_select(__a_unused struct sched *s, struct task *t)
{
struct filter_chain *fc = container_of(t, struct filter_chain, task);
struct filter_node *fn;
{
struct filter_chain *fc = container_of(t, struct filter_chain, task);
struct filter_node *fn;
@@
-121,15
+119,13
@@
void filter_pre_select(__a_unused struct sched *s, struct task *t)
return;
}
again:
return;
}
again:
- ib =
fc->inbuf
;
+ ib =
*fc->inbufp
;
loaded = fc->in_loaded;
conv = 0;
FOR_EACH_FILTER_NODE(fn, fc, i) {
struct filter *f = filters + fn->filter_num;
if (fn->loaded < fn->bufsize) {
size_t size, old_fn_loaded = fn->loaded;
loaded = fc->in_loaded;
conv = 0;
FOR_EACH_FILTER_NODE(fn, fc, i) {
struct filter *f = filters + fn->filter_num;
if (fn->loaded < fn->bufsize) {
size_t size, old_fn_loaded = fn->loaded;
-// PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
-// fc, *loaded, fn->filter->name);
t->error = f->convert(ib, *loaded, fn);
if (t->error < 0)
return;
t->error = f->convert(ib, *loaded, fn);
if (t->error < 0)
return;
@@
-137,22
+133,14
@@
again:
call_callbacks(fn, ib, size, fn->buf + old_fn_loaded,
fn->loaded - old_fn_loaded);
*loaded -= size;
call_callbacks(fn, ib, size, fn->buf + old_fn_loaded,
fn->loaded - old_fn_loaded);
*loaded -= size;
- conv += size;
- if (*loaded && size) {
-// PARA_DEBUG_LOG("moving %zd bytes in input "
-// "buffer for %s filter\n",
-// *loaded, fn->filter->name);
+ conv += size + fn->loaded - old_fn_loaded;
+ if (*loaded && size)
memmove(ib, ib + size, *loaded);
memmove(ib, ib + size, *loaded);
- }
}
ib = fn->buf;
loaded = &fn->loaded;
}
conv_total += conv;
}
ib = fn->buf;
loaded = &fn->loaded;
}
conv_total += conv;
-// PARA_DEBUG_LOG("eof (in/out/fc): %d/%d/%d out_loaded: %zd, "
-// "conv: %d, conv_total: %d\n", *fc->input_eof,
-// fc->output_eof? *fc->output_eof : -42,
-// fc->eof, *fc->out_loaded, conv, conv_total);
if (conv)
goto again;
if (*fc->input_error >= 0)
if (conv)
goto again;
if (*fc->input_error >= 0)
@@
-208,15
+196,18
@@
static int parse_filter_args(int filter_num, char *options, void **conf)
if (!f->parse_config)
return strlen(options)? -E_BAD_FILTER_OPTIONS : filter_num;
// PARA_DEBUG_LOG("options: %s\n", options);
if (!f->parse_config)
return strlen(options)? -E_BAD_FILTER_OPTIONS : filter_num;
// PARA_DEBUG_LOG("options: %s\n", options);
- argc = split_args(options, &argv, " \t");
-// PARA_DEBUG_LOG("argc = %d, argv[0]: %s\n", argc, argv[0]);
+ argc = create_argv(options, " \t", &argv);
+ if (argc < 0)
+ return -E_BAD_FILTER_OPTIONS;
+ PARA_DEBUG_LOG("argc = %d, argv[0]: %s\n", argc, argv[0]);
for (i = argc - 1; i >= 0; i--)
argv[i + 1] = argv[i];
argv[0] = para_strdup(f->name);
for (i = argc - 1; i >= 0; i--)
argv[i + 1] = argv[i];
argv[0] = para_strdup(f->name);
- argc
+= 1
;
+ argc
++
;
ret = f->parse_config(argc, argv, conf);
ret = f->parse_config(argc, argv, conf);
- free(argv[0]);
- free(argv);
+ free(argv[argc - 1]);
+ argv[argc - 1] = NULL;
+ free_argv(argv);
return ret < 0? ret : filter_num;
}
return ret < 0? ret : filter_num;
}