NeoMutt  2022-04-29-249-gaae397
Teaching an old dog new tricks
icommands.h File Reference

Information commands. More...

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

Go to the source code of this file.

Data Structures

struct  ICommand
 An Informational Command. More...


enum CommandResult mutt_parse_icommand (const char *line, struct Buffer *err)
 Parse an informational command. More...

Detailed Description

Information commands.

  • Christopher John Czettel
  • 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

Definition in file icommands.h.

Function Documentation

◆ mutt_parse_icommand()

enum CommandResult mutt_parse_icommand ( const char *  line,
struct Buffer err 

Parse an informational command.

lineCommand to execute
errBuffer for error messages
Return values
MUTT_CMD_WARNINGWarning with message: command failed
  • Error (no message): command not found
  • Error with message: command failed

Definition at line 91 of file icommands.c.

93 if (!line || (*line == '\0') || !err)
94 return MUTT_CMD_ERROR;
98 struct Buffer *token = mutt_buffer_pool_get();
99 struct Buffer expn = mutt_buffer_make(0);
100 mutt_buffer_addstr(&expn, line);
101 mutt_buffer_seek(&expn, 0);
105 SKIPWS(expn.dptr);
107 for (size_t i = 0; ICommandList[i].name; i++)
108 {
109 if (!mutt_str_equal(token->data, ICommandList[i].name))
110 continue;
112 rc = ICommandList[i].parse(token, &expn, ICommandList[i].data, err);
113 if (rc != MUTT_CMD_SUCCESS)
114 goto finish;
116 break; /* Continue with next command */
117 }
121 mutt_buffer_dealloc(&expn);
122 return rc;
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:67
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:309
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:233
void mutt_buffer_seek(struct Buffer *buf, size_t offset)
Set current read/write position to offset from beginning.
Definition: buffer.c:483
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:85
Error codes for command_t parse functions.
Definition: command.h:34
Success: Command worked.
Definition: command.h:37
Error: Can't help the user.
Definition: command.h:35
static const struct ICommand ICommandList[]
All available informational commands.
Definition: icommands.c:68
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:273
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
No flags are set.
Definition: mutt.h:67
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define SKIPWS(ch)
Definition: string2.h:46
String manipulation buffer.
Definition: buffer.h:34
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
enum CommandResult(* parse)(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Function to parse information commands.
Definition: icommands.h:47
char * name
Name of the command.
Definition: icommands.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function: