libscomp/exec.h

28 lines
611 B
C
Raw Normal View History

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;
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__}, \
sizeof((struct libscomm_cmd []){__VA_ARGS__}) / \
sizeof((struct libscomm_cmd []){__VA_ARGS__}[0])}
2021-07-30 23:57:22 -04:00
#endif
int libscomm_exec(const struct libscomm_cmd_store *cmds,
struct libscomm_line *ln,
void *ptr
);