2016-07-19 23:14:27 +02:00
|
|
|
#ifndef COMMAND_MATCH_H
|
|
|
|
#define COMMAND_MATCH_H
|
|
|
|
|
|
|
|
#include "command_graph.h"
|
2016-07-21 23:38:03 +02:00
|
|
|
#include "linklist.h"
|
2016-07-19 23:14:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter types. These tell the parser whether to allow
|
|
|
|
* partial matching on tokens.
|
|
|
|
*/
|
|
|
|
enum filter_type
|
|
|
|
{
|
|
|
|
FILTER_RELAXED,
|
|
|
|
FILTER_STRICT
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command matcher result value.
|
|
|
|
*/
|
|
|
|
enum matcher_rv
|
|
|
|
{
|
|
|
|
MATCHER_OK,
|
|
|
|
MATCHER_COMPLETE,
|
|
|
|
MATCHER_INCOMPLETE,
|
|
|
|
MATCHER_NO_MATCH,
|
|
|
|
MATCHER_AMBIGUOUS,
|
|
|
|
MATCHER_EXCEED_ARGC_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Completion match types. */
|
2016-07-21 23:38:03 +02:00
|
|
|
enum match_type
|
2016-07-19 23:14:27 +02:00
|
|
|
{
|
|
|
|
no_match,
|
|
|
|
partly_match,
|
2016-07-21 23:38:03 +02:00
|
|
|
exact_match
|
2016-07-19 23:14:27 +02:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Defines which matcher_rv values constitute
|
|
|
|
* an error. Should be used against matcher_rv
|
|
|
|
* return values to do basic error checking.
|
|
|
|
*/
|
|
|
|
#define MATCHER_ERROR(matcher_rv) \
|
|
|
|
( (matcher_rv) == MATCHER_INCOMPLETE \
|
|
|
|
|| (matcher_rv) == MATCHER_NO_MATCH \
|
|
|
|
|| (matcher_rv) == MATCHER_AMBIGUOUS \
|
|
|
|
|| (matcher_rv) == MATCHER_EXCEED_ARGC_MAX \
|
|
|
|
)
|
|
|
|
|
2016-07-22 21:04:16 +02:00
|
|
|
struct list *
|
2016-07-19 23:14:27 +02:00
|
|
|
match_command (struct graph_node *, enum filter_type, const char *);
|
|
|
|
|
|
|
|
#endif
|