libwebsockets
Lightweight C library for HTML5 websockets
Search

Data Structures

struct  lws_fts_result_filepath
 
struct  lws_fts_result_autocomplete
 
struct  lws_fts_result
 
struct  lws_fts_search_params
 

Macros

#define LWSFTS_F_QUERY_AUTOCOMPLETE   (1 << 0)
 
#define LWSFTS_F_QUERY_FILES   (1 << 1)
 
#define LWSFTS_F_QUERY_FILE_LINES   (1 << 2)
 
#define LWSFTS_F_QUERY_QUOTE_LINE   (1 << 3)
 

Functions

LWS_VISIBLE LWS_EXTERN struct lws_fts * lws_fts_create (int fd)
 
LWS_VISIBLE LWS_EXTERN void lws_fts_destroy (struct lws_fts **trie)
 
LWS_VISIBLE LWS_EXTERN int lws_fts_file_index (struct lws_fts *t, const char *filepath, int filepath_len, int priority)
 
LWS_VISIBLE LWS_EXTERN int lws_fts_fill (struct lws_fts *t, uint32_t file_index, const char *buf, size_t len)
 
LWS_VISIBLE LWS_EXTERN int lws_fts_serialize (struct lws_fts *t)
 
LWS_VISIBLE LWS_EXTERN struct lws_fts_file * lws_fts_open (const char *filepath)
 
LWS_VISIBLE LWS_EXTERN struct lws_fts_resultlws_fts_search (struct lws_fts_file *jtf, struct lws_fts_search_params *ftsp)
 
LWS_VISIBLE LWS_EXTERN void lws_fts_close (struct lws_fts_file *jtf)
 

Detailed Description

Full-text search

Lws provides superfast indexing and fulltext searching from index files on storage.

Function Documentation

◆ lws_fts_close()

LWS_VISIBLE LWS_EXTERN void lws_fts_close ( struct lws_fts_file *  jtf)

#include <include/libwebsockets/lws-fts.h>

lws_fts_close() - Close a previously-opened index file

Parameters
jtfThe pointer returned from the open

Closes the file handle on the index and frees any allocations

◆ lws_fts_create()

LWS_VISIBLE LWS_EXTERN struct lws_fts* lws_fts_create ( int  fd)

#include <include/libwebsockets/lws-fts.h>

lws_fts_create() - Create a new index file

Parameters
fdThe fd opened for write

Inits a new index file, returning a struct lws_fts to represent it

◆ lws_fts_destroy()

LWS_VISIBLE LWS_EXTERN void lws_fts_destroy ( struct lws_fts **  trie)

#include <include/libwebsockets/lws-fts.h>

lws_fts_destroy() - Finalize a new index file / destroy the trie lwsac

Parameters
trieThe previously opened index being finalized

Finalizes an index file that was being created, and frees the memory involved *trie is set to NULL afterwards.

◆ 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 
)

#include <include/libwebsockets/lws-fts.h>

lws_fts_file_index() - Create a new entry in the trie file for an input path

Parameters
tThe previously opened index being written
filepathThe filepath (which may be virtual) associated with this file
filepath_lenThe number of chars in the filepath
prioritynot used yet

Returns an ordinal that represents this new filepath in the index file.

◆ 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 
)

#include <include/libwebsockets/lws-fts.h>

lws_fts_fill() - Process all or a bufferload of input file

Parameters
tThe previously opened index being written
file_indexThe ordinal representing this input filepath
bufA bufferload of data from the input file
lenThe number of bytes in buf

Indexes a buffer of data from the input file.

◆ lws_fts_open()

LWS_VISIBLE LWS_EXTERN struct lws_fts_file* lws_fts_open ( const char *  filepath)

#include <include/libwebsockets/lws-fts.h>

lws_fts_open() - Open an existing index file to search it

Parameters
filepathThe filepath to the index file to open

Opening the index file returns an opaque struct lws_fts_file * that is used to perform other operations on it, or NULL if it can't be opened.

◆ 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 
)

#include <include/libwebsockets/lws-fts.h>

lws_fts_search() - Perform a search operation on an index

Parameters
jtfThe index file struct returned by lws_fts_open
ftspThe struct lws_fts_search_params filled in by the caller

The caller should memset the ftsp struct to 0 to ensure members that may be introduced in later versions contain known values, then set the related members to describe the kind of search action required.

ftsp->results_head is the results lwsac, or NULL. It should be freed with lwsac_free() when the results are finished with.

Returns a pointer into the results lwsac that is a struct lws_fts_result containing the head pointers into linked-lists of results for autocomplete and filepath data, along with some sundry information. This does not need to be freed since freeing the lwsac will also remove this and everything it points to.

◆ lws_fts_serialize()

LWS_VISIBLE LWS_EXTERN int lws_fts_serialize ( struct lws_fts *  t)

#include <include/libwebsockets/lws-fts.h>

lws_fts_serialize() - Store the in-memory trie into the index file

Parameters
tThe previously opened index being written

The trie is held in memory where it can be added to... after all the input filepaths and data have been processed, this is called to serialize / write the trie data into the index file.