Commit b9c79678 authored by Joonwoo Park's avatar Joonwoo Park Committed by David S. Miller

textsearch: support for case insensitive searching

The function textsearch_prepare has a new flag to support case
insensitive searching.
Signed-off-by: default avatarJoonwoo Park <joonwpark81@gmail.com>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 58de7862
...@@ -10,10 +10,8 @@ ...@@ -10,10 +10,8 @@
struct ts_config; struct ts_config;
/** #define TS_AUTOLOAD 1 /* Automatically load textsearch modules when needed */
* TS_AUTOLOAD - Automatically load textsearch modules when needed #define TS_IGNORECASE 2 /* Searches string case insensitively */
*/
#define TS_AUTOLOAD 1
/** /**
* struct ts_state - search state * struct ts_state - search state
...@@ -39,7 +37,7 @@ struct ts_state ...@@ -39,7 +37,7 @@ struct ts_state
struct ts_ops struct ts_ops
{ {
const char *name; const char *name;
struct ts_config * (*init)(const void *, unsigned int, gfp_t); struct ts_config * (*init)(const void *, unsigned int, gfp_t, int);
unsigned int (*find)(struct ts_config *, unsigned int (*find)(struct ts_config *,
struct ts_state *); struct ts_state *);
void (*destroy)(struct ts_config *); void (*destroy)(struct ts_config *);
...@@ -52,12 +50,14 @@ struct ts_ops ...@@ -52,12 +50,14 @@ struct ts_ops
/** /**
* struct ts_config - search configuration * struct ts_config - search configuration
* @ops: operations of chosen algorithm * @ops: operations of chosen algorithm
* @flags: flags
* @get_next_block: callback to fetch the next block to search in * @get_next_block: callback to fetch the next block to search in
* @finish: callback to finalize a search * @finish: callback to finalize a search
*/ */
struct ts_config struct ts_config
{ {
struct ts_ops *ops; struct ts_ops *ops;
int flags;
/** /**
* get_next_block - fetch next block of data * get_next_block - fetch next block of data
......
...@@ -54,10 +54,13 @@ ...@@ -54,10 +54,13 @@
* USAGE * USAGE
* *
* Before a search can be performed, a configuration must be created * Before a search can be performed, a configuration must be created
* by calling textsearch_prepare() specyfing the searching algorithm and * by calling textsearch_prepare() specifying the searching algorithm,
* the pattern to look for. The returned configuration may then be used * the pattern to look for and flags. As a flag, you can set TS_IGNORECASE
* for an arbitary amount of times and even in parallel as long as a * to perform case insensitive matching. But it might slow down
* separate struct ts_state variable is provided to every instance. * performance of algorithm, so you should use it at own your risk.
* The returned configuration may then be used for an arbitary
* amount of times and even in parallel as long as a separate struct
* ts_state variable is provided to every instance.
* *
* The actual search is performed by either calling textsearch_find_- * The actual search is performed by either calling textsearch_find_-
* continuous() for linear data or by providing an own get_next_block() * continuous() for linear data or by providing an own get_next_block()
...@@ -89,7 +92,6 @@ ...@@ -89,7 +92,6 @@
* panic("Oh my god, dancing chickens at %d\n", pos); * panic("Oh my god, dancing chickens at %d\n", pos);
* *
* textsearch_destroy(conf); * textsearch_destroy(conf);
*
* ========================================================================== * ==========================================================================
*/ */
...@@ -279,7 +281,7 @@ struct ts_config *textsearch_prepare(const char *algo, const void *pattern, ...@@ -279,7 +281,7 @@ struct ts_config *textsearch_prepare(const char *algo, const void *pattern,
if (ops == NULL) if (ops == NULL)
goto errout; goto errout;
conf = ops->init(pattern, len, gfp_mask); conf = ops->init(pattern, len, gfp_mask, flags);
if (IS_ERR(conf)) { if (IS_ERR(conf)) {
err = PTR_ERR(conf); err = PTR_ERR(conf);
goto errout; goto errout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment