NeoMutt  2025-09-05-2-g4bf191
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
tag.h File Reference

Notmuch tag functions. More...

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

Go to the source code of this file.

Data Structures

struct  NmTags
 Array of Notmuch tags. More...
 

Functions

 ARRAY_HEAD (TagArray, char *)
 
void nm_tag_array_free (struct NmTags *tags)
 Free all memory of a NmTags.
 
struct NmTags nm_tag_str_to_tags (const char *tag_string)
 Converts a comma and/or space-delimited string of tags into an array.
 

Detailed Description

Notmuch tag functions.

Authors
  • Austin Ray
  • Richard Russon

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 tag.h.

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( TagArray  ,
char *   
)

◆ nm_tag_array_free()

void nm_tag_array_free ( struct NmTags tags)

Free all memory of a NmTags.

Parameters
tagsNmTags being cleaned up

Definition at line 39 of file tag.c.

40{
41 ARRAY_FREE(&tags->tags);
42 FREE(&tags->tag_str);
43}
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define FREE(x)
Definition: memory.h:62
struct TagArray tags
Tags.
Definition: tag.h:39
char * tag_str
Source string.
Definition: tag.h:40
+ Here is the caller graph for this function:

◆ nm_tag_str_to_tags()

struct NmTags nm_tag_str_to_tags ( const char *  tag_str)

Converts a comma and/or space-delimited string of tags into an array.

Parameters
tag_strString containing a list of tags, comma- and/or space-delimited
Return values
objArray containing tags represented as strings

Definition at line 50 of file tag.c.

51{
52 char *buf = mutt_str_dup(tag_str);
53
54 struct NmTags tags = { ARRAY_HEAD_INITIALIZER, buf };
55
56 char *end = NULL;
57 char *tag = NULL;
58
59 for (char *p = buf; p && (p[0] != '\0'); p++)
60 {
61 if (!tag && mutt_isspace(*p))
62 continue;
63 if (!tag)
64 tag = p; /* begin of the tag */
65 if ((p[0] == ',') || (p[0] == ' '))
66 end = p; /* terminate the tag */
67 else if (p[1] == '\0')
68 end = p + 1; /* end of optstr */
69 if (!tag || !end)
70 continue;
71 if (tag >= end)
72 break;
73 *end = '\0';
74
75 ARRAY_ADD(&tags.tags, tag);
76
77 end = NULL;
78 tag = NULL;
79 }
80
81 return tags;
82}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:156
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:58
bool mutt_isspace(int arg)
Wrapper for isspace(3)
Definition: ctype.c:95
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:254
Array of Notmuch tags.
Definition: tag.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function: