Search implementation.
More...
#include "src/lib/search/search.h"
#include "src/lib/convert.h"
#include "src/lib/datetime.h"
#include "src/lib/log.h"
#include "src/lib/mem.h"
#include "src/lib/sds/sds_extras.h"
#include "src/lib/search/search_fuzzy.h"
#include "src/lib/search/search_pcre.h"
#include "src/lib/utf8_wrapper.h"
#include <ctype.h>
#include <inttypes.h>
#include <string.h>
|
| enum | search_operators {
SEARCH_OP_UNKNOWN = -1
, SEARCH_OP_EQUAL
, SEARCH_OP_STARTS_WITH
, SEARCH_OP_CONTAINS
,
SEARCH_OP_NOT_EQUAL
, SEARCH_OP_REGEX
, SEARCH_OP_NOT_REGEX
, SEARCH_OP_GREATER
,
SEARCH_OP_GREATER_EQUAL
, SEARCH_OP_FUZZY
} |
| enum | search_filters {
SEARCH_FILTER_ANY_TAG = -2
, SEARCH_FILTER_MODIFIED_SINCE = -3
, SEARCH_FILTER_ADDED_SINCE = -4
, SEARCH_FILTER_FILE = -5
,
SEARCH_FILTER_BITRATE = -6
, SEARCH_FILTER_BASE = -7
, SEARCH_FILTER_PRIO = -8
, SEARCH_FILTER_AUDIO_FORMAT = -9
} |
|
| static int | expr_get_tag_song (const char *p, size_t *len) |
| static int | expr_get_tag_webradio (const char *p, size_t *len) |
| static int | expr_get_op (const char *p, int tag, size_t *len) |
| static sds | expr_get_value (const char *p, const char *end, int tag, sds buf, bool *rc) |
| static bool | expr_parse_value (struct t_search_expression *expr) |
| static void * | free_search_expression_struct (struct t_search_expression *expr) |
| static void | free_search_expression_node (struct t_list_node *current) |
| static bool | match_tag (const char *value, size_t value_len, struct t_search_expression *expr) |
| static bool | exit_search_loop (bool rc, struct t_search_expression *expr) |
| struct t_list * | search_expression_parse (const char *expression, enum search_type type) |
| void | search_expression_free (struct t_list *expr_list) |
| bool | search_expression_song (const struct mpd_song *song, const struct t_list *expr_list, const struct t_mympd_mpd_tags *any_tag_types) |
| bool | search_expression_album (const struct t_album *album, const struct t_list *expr_list, const struct t_mympd_mpd_tags *any_tag_types) |
| bool | search_expression_webradio (const struct t_webradio_data *webradio, const struct t_list *expr_list, const struct t_webradio_tags *any_tag_types) |
◆ search_filters
◆ search_operators
Private definitions Search operators like them from MPD
◆ exit_search_loop()
Determines if the search loop can end
- Parameters
-
| rc | Result of match_tag function |
| expr | Search expression |
- Returns
- true if search loop can be prematurely exited, else false
◆ expr_get_op()
| int expr_get_op |
( |
const char * | p, |
|
|
int | tag, |
|
|
size_t * | len ) |
|
static |
Extracts the search operator
- Parameters
-
| p | Pointer to start of operator in the expression |
| tag | Filter type |
| len | Set to count of bytes parsed |
- Returns
- Search operator or -1 on error
◆ expr_get_tag_song()
| int expr_get_tag_song |
( |
const char * | p, |
|
|
size_t * | len ) |
|
static |
Extracts the tag from a song search expression
- Parameters
-
| p | Pointer to start of expression |
| len | Set to count of bytes parsed |
- Returns
- MPD song tag, filter type or -1 on error
◆ expr_get_tag_webradio()
| int expr_get_tag_webradio |
( |
const char * | p, |
|
|
size_t * | len ) |
|
static |
Extracts the tag from a webradio search expression
- Parameters
-
| p | Pointer to start of expression |
| len | Set to count of bytes parsed |
- Returns
- Webradio tag, filter type or -1 on error
◆ expr_get_value()
| sds expr_get_value |
( |
const char * | p, |
|
|
const char * | end, |
|
|
int | tag, |
|
|
sds | buf, |
|
|
bool * | rc ) |
|
static |
Extracts the value to search for
- Parameters
-
| p | Pointer to start of value in the expression |
| end | Pointer to end of the expression |
| tag | Filter type |
| buf | Already allocated sds string to append the value |
| rc | Set to true on success, else false |
- Returns
- Pointer to buf
◆ expr_parse_value()
Parses the search expression value
- Parameters
-
| expr | The parsed search expression |
- Returns
- true on success, else false
◆ free_search_expression_node()
| void free_search_expression_node |
( |
struct t_list_node * | current | ) |
|
|
static |
Callback function for freeing a list node with t_search_expression user_data
- Parameters
-
| current | pointer to list node |
◆ free_search_expression_struct()
◆ match_tag()
Private functions Search expression matching against a tag value
- Parameters
-
| value | Value to match search expression against |
| value_len | Value length |
| expr | Search expression |
- Returns
- true if search expression matches, else false
◆ search_expression_album()
Implements search expressions for albums.
- Parameters
-
| album | pointer to album struct |
| expr_list | expression list returned by parse_search_expression |
| any_tag_types | tags for special "any" tag in expression |
- Returns
- expression result
◆ search_expression_free()
| void search_expression_free |
( |
struct t_list * | expr_list | ) |
|
Frees the search expression list
- Parameters
-
| expr_list | pointer to the list |
◆ search_expression_parse()
| struct t_list * search_expression_parse |
( |
const char * | expression, |
|
|
enum search_type | type ) |
Public functions Parses a mpd search expression string to a list
- Parameters
-
| expression | mpd search expression |
| type | type of struct for the search expression |
- Returns
- list of the expression or NULL on error
◆ search_expression_song()
| bool search_expression_song |
( |
const struct mpd_song * | song, |
|
|
const struct t_list * | expr_list, |
|
|
const struct t_mympd_mpd_tags * | any_tag_types ) |
Implements search expressions for mpd songs.
- Parameters
-
| song | pointer to mpd song struct |
| expr_list | expression list returned by parse_search_expression |
| any_tag_types | tags for special "any" tag in expression |
- Returns
- expression result
◆ search_expression_webradio()
Implements search expressions for webradios.
- Parameters
-
| webradio | pointer to webradio struct |
| expr_list | expression list returned by parse_search_expression |
| any_tag_types | tags for special "any" tag in expression |
- Returns
- expression result