NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
tags.h File Reference

Driver based email tags. More...

#include <stdbool.h>
#include "mutt/lib.h"
+ Include dependency graph for tags.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Tag
 LinkedList Tag Element. More...
 

Functions

 STAILQ_HEAD (TagList, Tag)
 
void driver_tags_free (struct TagList *list)
 Free tags from a header. More...
 
char * driver_tags_get (struct TagList *list)
 Get tags. More...
 
char * driver_tags_get_transformed (struct TagList *list)
 Get transformed tags. More...
 
char * driver_tags_get_transformed_for (struct TagList *list, const char *name)
 Get transformed tag for a tag name from a header. More...
 
char * driver_tags_get_with_hidden (struct TagList *list)
 Get tags with hiddens. More...
 
bool driver_tags_replace (struct TagList *list, char *tags)
 Replace all tags. More...
 

Variables

struct SlistC_HiddenTags
 Config: Tags that shouldn't be displayed on screen. More...
 
struct HashTableTagTransforms
 Lookup table of alternative tag names. More...
 

Detailed Description

Driver based email tags.

Authors
  • Mehdi Abaakouk

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file tags.h.

Function Documentation

◆ STAILQ_HEAD()

STAILQ_HEAD ( TagList  ,
Tag   
)

◆ driver_tags_free()

void driver_tags_free ( struct TagList *  list)

Free tags from a header.

Parameters
[in]listList of tags

Free the whole tags structure

Definition at line 104 of file tags.c.

105 {
106  if (!list)
107  return;
108 
109  struct Tag *np = STAILQ_FIRST(list);
110  struct Tag *next = NULL;
111  while (np)
112  {
113  next = STAILQ_NEXT(np, entries);
114  FREE(&np->name);
115  FREE(&np->transformed);
116  FREE(&np);
117  np = next;
118  }
119  STAILQ_INIT(list);
120 }
LinkedList Tag Element.
Definition: tags.h:40
char * name
Tag name.
Definition: tags.h:42
#define STAILQ_INIT(head)
Definition: queue.h:369
#define STAILQ_NEXT(elm, field)
Definition: queue.h:397
#define FREE(x)
Definition: memory.h:40
char * transformed
Transformed name.
Definition: tags.h:43
#define STAILQ_FIRST(head)
Definition: queue.h:347
+ Here is the caller graph for this function:

◆ driver_tags_get()

char* driver_tags_get ( struct TagList *  list)

Get tags.

Parameters
[in]listList of tags
Return values
ptrString list of tags

Return a new allocated string containing all tags separated by space

Definition at line 142 of file tags.c.

143 {
144  return driver_tags_getter(list, false, false, NULL);
145 }
static char * driver_tags_getter(struct TagList *head, bool show_hidden, bool show_transformed, const char *filter)
Get transformed tags.
Definition: tags.c:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ driver_tags_get_transformed()

char* driver_tags_get_transformed ( struct TagList *  list)

Get transformed tags.

Parameters
[in]listList of tags
Return values
ptrString list of tags

Return a new allocated string containing all tags separated by space with transformation

Definition at line 130 of file tags.c.

131 {
132  return driver_tags_getter(list, false, true, NULL);
133 }
static char * driver_tags_getter(struct TagList *head, bool show_hidden, bool show_transformed, const char *filter)
Get transformed tags.
Definition: tags.c:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ driver_tags_get_transformed_for()

char* driver_tags_get_transformed_for ( struct TagList *  head,
const char *  name 
)

Get transformed tag for a tag name from a header.

Parameters
[in]headList of tags
[in]nameTag to transform
Return values
ptrString tag

Return a new allocated string containing all tags separated by space even the hiddens.

Definition at line 169 of file tags.c.

170 {
171  return driver_tags_getter(head, true, true, name);
172 }
char * name
Tag name.
Definition: tags.h:42
static char * driver_tags_getter(struct TagList *head, bool show_hidden, bool show_transformed, const char *filter)
Get transformed tags.
Definition: tags.c:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ driver_tags_get_with_hidden()

char* driver_tags_get_with_hidden ( struct TagList *  list)

Get tags with hiddens.

Parameters
[in]listList of tags
Return values
ptrString list of tags

Return a new allocated string containing all tags separated by space even the hiddens.

Definition at line 155 of file tags.c.

156 {
157  return driver_tags_getter(list, true, false, NULL);
158 }
static char * driver_tags_getter(struct TagList *head, bool show_hidden, bool show_transformed, const char *filter)
Get transformed tags.
Definition: tags.c:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ driver_tags_replace()

bool driver_tags_replace ( struct TagList *  head,
char *  tags 
)

Replace all tags.

Parameters
[in]headList of tags
[in]tagsstring of all tags separated by space
Return values
falseNo changes are made
trueTags are updated

Free current tags structures and replace it by new tags

Definition at line 183 of file tags.c.

184 {
185  if (!head)
186  return false;
187 
188  driver_tags_free(head);
189 
190  if (tags)
191  {
192  struct ListHead hsplit = STAILQ_HEAD_INITIALIZER(hsplit);
193  mutt_list_str_split(&hsplit, tags, ' ');
194  struct ListNode *np = NULL;
195  STAILQ_FOREACH(np, &hsplit, entries)
196  {
197  driver_tags_add(head, np->data);
198  }
199  mutt_list_free(&hsplit);
200  }
201  return true;
202 }
void driver_tags_free(struct TagList *list)
Free tags from a header.
Definition: tags.c:104
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
size_t mutt_list_str_split(struct ListHead *head, const char *src, char sep)
Split a string into a list using a separator char.
Definition: list.c:247
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * data
String.
Definition: list.h:36
static void driver_tags_add(struct TagList *list, char *new_tag)
Add a tag to header.
Definition: tags.c:80
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
A List node for strings.
Definition: list.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_HiddenTags

struct Slist* C_HiddenTags

Config: Tags that shouldn't be displayed on screen.

Definition at line 36 of file tags.c.

◆ TagTransforms

struct HashTable* TagTransforms

Lookup table of alternative tag names.

Definition at line 38 of file tags.c.