NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
search()

Search a menu for a item matching a regex. More...

+ Collaboration diagram for search():

Functions

static int query_search (struct Menu *menu, regex_t *rx, int line)
 Search a Address menu item - Implements Menu::search() -Try to match various Address fields. More...
 
static int select_file_search (struct Menu *menu, regex_t *rx, int line)
 Menu search callback for matching files - Implements Menu::search() -. More...
 
static int generic_search (struct Menu *menu, regex_t *rx, int line)
 Search a menu for a item matching a regex - Implements Menu::search() -. More...
 

Detailed Description

Search a menu for a item matching a regex.

Parameters
menuMenu to search
rxRegex to match
lineMenu entry to match
Return values
0Success
>0Error, e.g. REG_NOMATCH

Function Documentation

◆ query_search()

static int query_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Search a Address menu item - Implements Menu::search() -Try to match various Address fields.

Definition at line 145 of file dlgquery.c.

146 {
147  const struct AliasViewArray *ava = &((struct AliasMenuData *) menu->mdata)->ava;
148  struct AliasView *av = ARRAY_GET(ava, line);
149  struct Alias *alias = av->alias;
150 
151  if (alias->name && (regexec(rx, alias->name, 0, NULL, 0) == 0))
152  return 0;
153  if (alias->comment && (regexec(rx, alias->comment, 0, NULL, 0) == 0))
154  return 0;
155  if (!TAILQ_EMPTY(&alias->addr))
156  {
157  struct Address *addr = TAILQ_FIRST(&alias->addr);
158  if (addr->personal && (regexec(rx, addr->personal, 0, NULL, 0) == 0))
159  {
160  return 0;
161  }
162  if (addr->mailbox && (regexec(rx, addr->mailbox, 0, NULL, 0) == 0))
163  {
164  return 0;
165  }
166  }
167 
168  return REG_NOMATCH;
169 }
A shortcut for an email address or addresses.
Definition: alias.h:33
char * name
Short name.
Definition: alias.h:35
#define TAILQ_FIRST(head)
Definition: queue.h:723
AliasView array wrapper with Pattern information -.
Definition: gui.h:52
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
An email address.
Definition: address.h:35
char * mailbox
Mailbox and host address.
Definition: address.h:38
GUI data wrapping an Alias.
Definition: gui.h:35
struct Alias * alias
Alias.
Definition: gui.h:44
void * mdata
Private data.
Definition: lib.h:155
char * comment
Free-form comment string.
Definition: alias.h:37
char * personal
Real name of address.
Definition: address.h:37
#define TAILQ_EMPTY(head)
Definition: queue.h:721
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:36
+ Here is the caller graph for this function:

◆ select_file_search()

static int select_file_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Menu search callback for matching files - Implements Menu::search() -.

Definition at line 970 of file browser.c.

971 {
972  struct BrowserStateEntry *entry = menu->mdata;
973 #ifdef USE_NNTP
974  if (OptNews)
975  return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
976 #endif
977  struct FolderFile *ff = ARRAY_GET(entry, line);
978  char *search_on = ff->desc ? ff->desc : ff->name;
979 
980  return regexec(rx, search_on, 0, NULL, 0);
981 }
char * desc
Definition: browser.h:63
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
char * name
Definition: browser.h:62
Browser entry representing a folder/dir.
Definition: browser.h:53
void * mdata
Private data.
Definition: lib.h:155
WHERE bool OptNews
(pseudo) used to change reader mode
Definition: options.h:44
+ Here is the caller graph for this function:

◆ generic_search()

static int generic_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Search a menu for a item matching a regex - Implements Menu::search() -.

Definition at line 97 of file menu.c.

98 {
99  char buf[1024];
100 
101  menu_make_entry(menu, buf, sizeof(buf), line);
102  return regexec(rx, buf, 0, NULL, 0);
103 }
void menu_make_entry(struct Menu *menu, char *buf, size_t buflen, int i)
Create string to display in a Menu (the index)
Definition: draw.c:299
+ Here is the call graph for this function:
+ Here is the caller graph for this function: