NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
stailq.c
Go to the documentation of this file.
1
30
36
37
#include "config.h"
38
#include "
mutt/lib.h
"
39
#include "
core/lib.h
"
40
#include "
stailq.h
"
41
#include "
parse/lib.h
"
42
52
enum
CommandResult
parse_stailq
(
const
struct
Command
*cmd,
struct
Buffer
*line,
53
struct
ListHead *list,
54
const
struct
ParseContext
*pc,
struct
ParseError
*pe)
55
{
56
struct
Buffer
*err = pe->
message
;
57
58
if
(!
MoreArgs
(line))
59
{
60
buf_printf
(err,
_
(
"%s: too few arguments"
), cmd->
name
);
61
return
MUTT_CMD_WARNING
;
62
}
63
64
struct
Buffer
*token =
buf_pool_get
();
65
66
do
67
{
68
parse_extract_token
(token, line,
TOKEN_NONE
);
69
add_to_stailq
(list,
buf_string
(token));
70
}
while
(
MoreArgs
(line));
71
72
buf_pool_release
(&token);
73
return
MUTT_CMD_SUCCESS
;
74
}
75
85
enum
CommandResult
parse_unstailq
(
const
struct
Command
*cmd,
86
struct
Buffer
*line,
struct
ListHead *list,
87
const
struct
ParseContext
*pc,
struct
ParseError
*pe)
88
{
89
struct
Buffer
*err = pe->
message
;
90
91
if
(!
MoreArgs
(line))
92
{
93
buf_printf
(err,
_
(
"%s: too few arguments"
), cmd->
name
);
94
return
MUTT_CMD_WARNING
;
95
}
96
97
struct
Buffer
*token =
buf_pool_get
();
98
99
do
100
{
101
parse_extract_token
(token, line,
TOKEN_NONE
);
102
/* Check for deletion of entire list */
103
if
(
mutt_str_equal
(
buf_string
(token),
"*"
))
104
{
105
mutt_list_free
(list);
106
break
;
107
}
108
remove_from_stailq
(list,
buf_string
(token));
109
}
while
(
MoreArgs
(line));
110
111
buf_pool_release
(&token);
112
return
MUTT_CMD_SUCCESS
;
113
}
buf_printf
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition
buffer.c:168
buf_string
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition
buffer.h:96
CommandResult
CommandResult
Error codes for command_t parse functions.
Definition
command.h:37
MUTT_CMD_SUCCESS
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition
command.h:40
MUTT_CMD_WARNING
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition
command.h:39
lib.h
Convenience wrapper for the core headers.
parse_extract_token
int parse_extract_token(struct Buffer *dest, struct Buffer *line, TokenFlags flags)
Extract one token from a string.
Definition
extract.c:49
MoreArgs
#define MoreArgs(buf)
Definition
extract.h:32
TOKEN_NONE
@ TOKEN_NONE
No flags are set.
Definition
extract.h:50
parse_stailq
enum CommandResult parse_stailq(const struct Command *cmd, struct Buffer *line, struct ListHead *list, const struct ParseContext *pc, struct ParseError *pe)
Parse a list command - Implements Command::parse() -.
Definition
stailq.c:52
parse_unstailq
enum CommandResult parse_unstailq(const struct Command *cmd, struct Buffer *line, struct ListHead *list, const struct ParseContext *pc, struct ParseError *pe)
Parse an unlist command - Implements Command::parse() -.
Definition
stailq.c:85
remove_from_stailq
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition
list.c:344
add_to_stailq
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition
list.c:319
mutt_list_free
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition
list.c:123
lib.h
Convenience wrapper for the library headers.
_
#define _(a)
Definition
message.h:28
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition
string.c:666
lib.h
Text parsing functions.
buf_pool_get
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition
pool.c:91
buf_pool_release
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition
pool.c:111
stailq.h
Parse Stailq Commands.
Buffer
String manipulation buffer.
Definition
buffer.h:36
Command
Definition
command.h:161
Command::name
const char * name
Name of the Command.
Definition
command.h:162
ParseContext
Context for config parsing (history/backtrace).
Definition
pcontext.h:34
ParseError
Detailed error information from config parsing.
Definition
perror.h:34
ParseError::message
struct Buffer * message
Error message.
Definition
perror.h:35