NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
command.c File Reference

NeoMutt Commands. More...

#include "config.h"
#include "mutt/lib.h"
#include "command.h"
+ Include dependency graph for command.c:

Go to the source code of this file.

Functions

 ARRAY_HEAD (CommandArray, struct Command)
 
static int commands_sort (const void *a, const void *b, void *sdata)
 Compare two commands by name - Implements sort_t -.
 
void commands_register (const struct Command *cmds, const size_t num_cmds)
 Add commands to Commands array.
 
void commands_cleanup (void)
 Free Commands array.
 
size_t commands_array (struct Command **first)
 Get Commands array.
 
struct Commandcommand_get (const char *s)
 Get a Command by its name.
 

Variables

static struct CommandArray Commands = ARRAY_HEAD_INITIALIZER
 All the registered commands, e.g. alias, sidebar_pin.
 

Detailed Description

NeoMutt Commands.

Authors
  • 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 command.c.

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( CommandArray  ,
struct Command   
)

◆ commands_register()

void commands_register ( const struct Command cmds,
const size_t  num_cmds 
)

Add commands to Commands array.

Parameters
cmdsArray of Commands
num_cmdsNumber of Commands in the Array

Definition at line 53 of file command.c.

54{
55 for (int i = 0; i < num_cmds; i++)
56 {
57 ARRAY_ADD(&Commands, cmds[i]);
58 }
60}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition: array.h:279
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:156
static struct CommandArray Commands
All the registered commands, e.g. alias, sidebar_pin.
Definition: command.c:35
static int commands_sort(const void *a, const void *b, void *sdata)
Compare two commands by name - Implements sort_t -.
Definition: command.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commands_cleanup()

void commands_cleanup ( void  )

Free Commands array.

Definition at line 65 of file command.c.

66{
68}
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
+ Here is the caller graph for this function:

◆ commands_array()

size_t commands_array ( struct Command **  first)

Get Commands array.

Parameters
firstSet to first element of Commands array
Return values
numSize of Commands array

Definition at line 75 of file command.c.

76{
77 *first = ARRAY_FIRST(&Commands);
78 return ARRAY_SIZE(&Commands);
79}
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition: array.h:135
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
+ Here is the caller graph for this function:

◆ command_get()

struct Command * command_get ( const char *  s)

Get a Command by its name.

Parameters
sCommand string to lookup
Return values
ptrSuccess, Command
NULLError, no such command

Definition at line 87 of file command.c.

88{
89 struct Command *cmd = NULL;
91 {
92 if (mutt_str_equal(s, cmd->name))
93 return cmd;
94 }
95 return NULL;
96}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
const char * name
Name of the command.
Definition: command.h:52
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Commands

struct CommandArray Commands = ARRAY_HEAD_INITIALIZER
static

All the registered commands, e.g. alias, sidebar_pin.

Definition at line 35 of file command.c.