libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
class="ui-resizable-handle">
Loading...
Searching...
No Matches
lws-fts.h
Go to the documentation of this file.
1
/*
2
* libwebsockets - small server side websockets and web server implementation
3
*
4
* Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*/
24
33
34
struct
lws_fts;
35
struct
lws_fts_file;
36
37
/*
38
* Queries produce their results in an lwsac, using these public API types.
39
* The first thing in the lwsac is always a struct lws_fts_result (see below)
40
* containing heads for linked-lists of the other result types.
41
*/
42
43
/* one filepath's results */
44
45
struct
lws_fts_result_filepath
{
46
struct
lws_fts_result_filepath
*
next
;
47
int
matches
;
/* logical number of matches */
48
int
matches_length
;
/* bytes in length table (may be zero) */
49
int
lines_in_file
;
50
int
filepath_length
;
51
52
/* - uint32_t line table follows (first for alignment) */
53
/* - filepath (of filepath_length) follows */
54
};
55
56
/* autocomplete result */
57
58
struct
lws_fts_result_autocomplete
{
59
struct
lws_fts_result_autocomplete
*
next
;
60
int
instances
;
61
int
agg_instances
;
62
int
ac_length
;
63
char
elided
;
/* children skipped in interest of antecedent children */
64
char
has_children
;
65
66
/* - autocomplete suggestion (of length ac_length) follows */
67
};
68
69
/*
70
* The results lwsac always starts with this. If no results and / or no
71
* autocomplete the members may be NULL. This implies the symbol nor any
72
* suffix on it exists in the trie file.
73
*/
74
struct
lws_fts_result
{
75
struct
lws_fts_result_filepath
*
filepath_head
;
76
struct
lws_fts_result_autocomplete
*
autocomplete_head
;
77
int
duration_ms
;
78
int
effective_flags
;
/* the search flags that were used */
79
};
80
81
/*
82
* index creation functions
83
*/
84
92
LWS_VISIBLE
LWS_EXTERN
struct
lws_fts *
93
lws_fts_create
(
int
fd);
94
103
LWS_VISIBLE
LWS_EXTERN
void
104
lws_fts_destroy
(
struct
lws_fts **trie);
105
116
LWS_VISIBLE
LWS_EXTERN
int
117
lws_fts_file_index
(
struct
lws_fts *t,
const
char
*filepath,
int
filepath_len,
118
int
priority);
119
130
LWS_VISIBLE
LWS_EXTERN
int
131
lws_fts_fill
(
struct
lws_fts *t,
uint32_t
file_index,
const
char
*buf,
132
size_t
len);
133
143
LWS_VISIBLE
LWS_EXTERN
int
144
lws_fts_serialize
(
struct
lws_fts *t);
145
146
/*
147
* index search functions
148
*/
149
158
LWS_VISIBLE
LWS_EXTERN
struct
lws_fts_file *
159
lws_fts_open
(
const
char
*filepath);
160
161
#define LWSFTS_F_QUERY_AUTOCOMPLETE (1 << 0)
162
#define LWSFTS_F_QUERY_FILES (1 << 1)
163
#define LWSFTS_F_QUERY_FILE_LINES (1 << 2)
164
#define LWSFTS_F_QUERY_QUOTE_LINE (1 << 3)
165
166
struct
lws_fts_search_params
{
167
/* the actual search term */
168
const
char
*
needle
;
169
/* if non-NULL, FILE results for this filepath only */
170
const
char
*
only_filepath
;
171
/* will be set to the results lwsac */
172
struct
lwsac *
results_head
;
173
/* combination of LWSFTS_F_QUERY_* flags */
174
int
flags
;
175
/* maximum number of autocomplete suggestions to return */
176
int
max_autocomplete
;
177
/* maximum number of filepaths to return */
178
int
max_files
;
179
/* maximum number of line number results to return per filepath */
180
int
max_lines
;
181
};
182
202
LWS_VISIBLE
LWS_EXTERN
struct
lws_fts_result
*
203
lws_fts_search
(
struct
lws_fts_file *jtf,
struct
lws_fts_search_params
*ftsp);
204
212
LWS_VISIBLE
LWS_EXTERN
void
213
lws_fts_close
(
struct
lws_fts_file *jtf);
214
lws_fts_result_filepath::next
struct lws_fts_result_filepath * next
Definition
lws-fts.h:46
lws_fts_search_params::max_files
int max_files
Definition
lws-fts.h:178
lws_fts_result_autocomplete::ac_length
int ac_length
Definition
lws-fts.h:62
lws_fts_search_params::results_head
struct lwsac * results_head
Definition
lws-fts.h:172
lws_fts_result_autocomplete::agg_instances
int agg_instances
Definition
lws-fts.h:61
lws_fts_search_params::max_autocomplete
int max_autocomplete
Definition
lws-fts.h:176
lws_fts_search_params::only_filepath
const char * only_filepath
Definition
lws-fts.h:170
lws_fts_result_autocomplete::next
struct lws_fts_result_autocomplete * next
Definition
lws-fts.h:59
lws_fts_search_params::needle
const char * needle
Definition
lws-fts.h:168
lws_fts_result_filepath::matches
int matches
Definition
lws-fts.h:47
lws_fts_search_params::flags
int flags
Definition
lws-fts.h:174
lws_fts_result_filepath::filepath_length
int filepath_length
Definition
lws-fts.h:50
lws_fts_result_filepath::lines_in_file
int lines_in_file
Definition
lws-fts.h:49
lws_fts_result_autocomplete::instances
int instances
Definition
lws-fts.h:60
lws_fts_result::effective_flags
int effective_flags
Definition
lws-fts.h:78
lws_fts_result::filepath_head
struct lws_fts_result_filepath * filepath_head
Definition
lws-fts.h:75
lws_fts_result_autocomplete::elided
char elided
Definition
lws-fts.h:63
lws_fts_search_params::max_lines
int max_lines
Definition
lws-fts.h:180
lws_fts_result_filepath::matches_length
int matches_length
Definition
lws-fts.h:48
lws_fts_result_autocomplete::has_children
char has_children
Definition
lws-fts.h:64
lws_fts_result::autocomplete_head
struct lws_fts_result_autocomplete * autocomplete_head
Definition
lws-fts.h:76
lws_fts_result::duration_ms
int duration_ms
Definition
lws-fts.h:77
lws_fts_open
LWS_VISIBLE LWS_EXTERN struct lws_fts_file * lws_fts_open(const char *filepath)
lws_fts_serialize
LWS_VISIBLE LWS_EXTERN int lws_fts_serialize(struct lws_fts *t)
lws_fts_destroy
LWS_VISIBLE LWS_EXTERN void lws_fts_destroy(struct lws_fts **trie)
lws_fts_file_index
LWS_VISIBLE LWS_EXTERN int lws_fts_file_index(struct lws_fts *t, const char *filepath, int filepath_len, int priority)
lws_fts_search
LWS_VISIBLE LWS_EXTERN struct lws_fts_result * lws_fts_search(struct lws_fts_file *jtf, struct lws_fts_search_params *ftsp)
lws_fts_create
LWS_VISIBLE LWS_EXTERN struct lws_fts * lws_fts_create(int fd)
lws_fts_fill
LWS_VISIBLE LWS_EXTERN int lws_fts_fill(struct lws_fts *t, uint32_t file_index, const char *buf, size_t len)
lws_fts_close
LWS_VISIBLE LWS_EXTERN void lws_fts_close(struct lws_fts_file *jtf)
lws_fts_result
Definition
lws-fts.h:74
lws_fts_result_autocomplete
Definition
lws-fts.h:58
lws_fts_result_filepath
Definition
lws-fts.h:45
lws_fts_search_params
Definition
lws-fts.h:166
uint32_t
unsigned int uint32_t
Definition
libwebsockets.h:695
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:296
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:291
include
libwebsockets
lws-fts.h
Generated on
for libwebsockets by
1.18.0