24 lines
552 B
C
24 lines
552 B
C
#pragma once
|
|
#include "input.h"
|
|
|
|
enum libscomm_cmd_r {
|
|
LIBSCOMM_NOT_FOUND = -1,
|
|
LIBSCOMM_CMD_OK = 0
|
|
};
|
|
|
|
struct libscomm_cmd {
|
|
const char *name;
|
|
int (*exec)(struct libscomm_line *);
|
|
};
|
|
|
|
struct libscomm_cmd_store {
|
|
struct libscomm_cmd *arr;
|
|
size_t len;
|
|
};
|
|
|
|
#if defined(__STDC_VERSION__)
|
|
#define libscomm_mkcmds(...) {(struct libscomm_cmd []){__VA_ARGS__}, \
|
|
sizeof((struct libscomm_cmd []){__VA_ARGS__}) / sizeof((struct libscomm_cmd []){__VA_ARGS__}[0])}
|
|
#endif
|
|
int libscomm_exec(const struct libscomm_cmd_store *cmds, struct libscomm_line *ln);
|