implements a short list of quickcommands

This commit is contained in:
2024-07-10 18:15:11 +01:00
parent ff69837f19
commit 2f2e503ae3
3 changed files with 49 additions and 1 deletions

View File

@@ -81,4 +81,26 @@ char *version_as_string(char *s, long v, int n)
bool is_comment(char *s)
{
return s[0] == '#';
}
}
/**
* @brief Searches the quickcommands array for a quickcommand
* corresponding to the command_key.
*
* @param command_key The key used to search for the quickcommand
* @param quickcommands Pointer to an array of quickcommands
* @param n The number of quickcommands
* @return struct quickcommand* Pointer to the found quickcommand
* May return NULL if quickcommand not found.
*/
struct quickcommand *command_in_quickcommands(const char *command_key, struct quickcommand *quickcommands, int n)
{
for (int i = 0; i < n; i++)
{
if (strncmp(command_key, quickcommands[i].name, strlen(command_key)) == 0)
{
return &quickcommands[i];
}
}
return NULL;
}