2021-07-30 22:14:16 -04:00
|
|
|
#pragma once
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
enum libscomm_cmd_r {
|
|
|
|
LIBSCOMM_NOT_FOUND = -1,
|
|
|
|
LIBSCOMM_CMD_OK = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
struct libscomm_cmd {
|
|
|
|
const char *name;
|
2021-07-31 20:36:22 -04:00
|
|
|
int (*exec)(struct libscomm_line *, void *);
|
2021-07-30 22:14:16 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct libscomm_cmd_store {
|
|
|
|
struct libscomm_cmd *arr;
|
|
|
|
size_t len;
|
|
|
|
};
|
|
|
|
|
2021-07-30 23:57:22 -04:00
|
|
|
#if defined(__STDC_VERSION__)
|
|
|
|
#define libscomm_mkcmds(...) {(struct libscomm_cmd []){__VA_ARGS__}, \
|
2021-07-31 20:36:22 -04:00
|
|
|
sizeof((struct libscomm_cmd []){__VA_ARGS__}) / \
|
|
|
|
sizeof((struct libscomm_cmd []){__VA_ARGS__}[0])}
|
2021-07-30 23:57:22 -04:00
|
|
|
#endif
|
2021-07-31 20:36:22 -04:00
|
|
|
int libscomm_exec(const struct libscomm_cmd_store *cmds,
|
|
|
|
struct libscomm_line *ln,
|
|
|
|
void *ptr
|
|
|
|
);
|