aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoonwoo Park <joonwpark81@gmail.com>2008-07-08 05:37:31 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-08 05:37:31 -0400
commitb9c796783151678d08b1ec1ef410685b2515ba51 (patch)
tree48546b3c11b7111f465d09fe6802bae3e227262f
parent58de7862e61cb71251a25314d1b3d7260af1448a (diff)
textsearch: support for case insensitive searching
The function textsearch_prepare has a new flag to support case insensitive searching. Signed-off-by: Joonwoo Park <joonwpark81@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/textsearch.h10
-rw-r--r--lib/textsearch.c14
2 files changed, 13 insertions, 11 deletions
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 6f371f24160b..6c34cf28b7aa 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -10,10 +10,8 @@
10 10
11struct ts_config; 11struct ts_config;
12 12
13/** 13#define TS_AUTOLOAD 1 /* Automatically load textsearch modules when needed */
14 * TS_AUTOLOAD - Automatically load textsearch modules when needed 14#define TS_IGNORECASE 2 /* Searches string case insensitively */
15 */
16#define TS_AUTOLOAD 1
17 15
18/** 16/**
19 * struct ts_state - search state 17 * struct ts_state - search state
@@ -39,7 +37,7 @@ struct ts_state
39struct ts_ops 37struct ts_ops
40{ 38{
41 const char *name; 39 const char *name;
42 struct ts_config * (*init)(const void *, unsigned int, gfp_t); 40 struct ts_config * (*init)(const void *, unsigned int, gfp_t, int);
43 unsigned int (*find)(struct ts_config *, 41 unsigned int (*find)(struct ts_config *,
44 struct ts_state *); 42 struct ts_state *);
45 void (*destroy)(struct ts_config *); 43 void (*destroy)(struct ts_config *);
@@ -52,12 +50,14 @@ struct ts_ops
52/** 50/**
53 * struct ts_config - search configuration 51 * struct ts_config - search configuration
54 * @ops: operations of chosen algorithm 52 * @ops: operations of chosen algorithm
53 * @flags: flags
55 * @get_next_block: callback to fetch the next block to search in 54 * @get_next_block: callback to fetch the next block to search in
56 * @finish: callback to finalize a search 55 * @finish: callback to finalize a search
57 */ 56 */
58struct ts_config 57struct ts_config
59{ 58{
60 struct ts_ops *ops; 59 struct ts_ops *ops;
60 int flags;
61 61
62 /** 62 /**
63 * get_next_block - fetch next block of data 63 * get_next_block - fetch next block of data
diff --git a/lib/textsearch.c b/lib/textsearch.c
index be8bda3862f5..b451fcc9354c 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -54,10 +54,13 @@
54 * USAGE 54 * USAGE
55 * 55 *
56 * Before a search can be performed, a configuration must be created 56 * Before a search can be performed, a configuration must be created
57 * by calling textsearch_prepare() specyfing the searching algorithm and 57 * by calling textsearch_prepare() specifying the searching algorithm,
58 * the pattern to look for. The returned configuration may then be used 58 * the pattern to look for and flags. As a flag, you can set TS_IGNORECASE
59 * for an arbitary amount of times and even in parallel as long as a 59 * to perform case insensitive matching. But it might slow down
60 * separate struct ts_state variable is provided to every instance. 60 * performance of algorithm, so you should use it at own your risk.
61 * The returned configuration may then be used for an arbitary
62 * amount of times and even in parallel as long as a separate struct
63 * ts_state variable is provided to every instance.
61 * 64 *
62 * The actual search is performed by either calling textsearch_find_- 65 * The actual search is performed by either calling textsearch_find_-
63 * continuous() for linear data or by providing an own get_next_block() 66 * continuous() for linear data or by providing an own get_next_block()
@@ -89,7 +92,6 @@
89 * panic("Oh my god, dancing chickens at %d\n", pos); 92 * panic("Oh my god, dancing chickens at %d\n", pos);
90 * 93 *
91 * textsearch_destroy(conf); 94 * textsearch_destroy(conf);
92 *
93 * ========================================================================== 95 * ==========================================================================
94 */ 96 */
95 97
@@ -279,7 +281,7 @@ struct ts_config *textsearch_prepare(const char *algo, const void *pattern,
279 if (ops == NULL) 281 if (ops == NULL)
280 goto errout; 282 goto errout;
281 283
282 conf = ops->init(pattern, len, gfp_mask); 284 conf = ops->init(pattern, len, gfp_mask, flags);
283 if (IS_ERR(conf)) { 285 if (IS_ERR(conf)) {
284 err = PTR_ERR(conf); 286 err = PTR_ERR(conf);
285 goto errout; 287 goto errout;