libscomp/exec.h

28 lines
611 B
C

#pragma once
#include "input.h"
enum libscomp_cmd_r {
LIBSCOMP_NOT_FOUND = -1,
LIBSCOMP_CMD_OK = 0
};
struct libscomp_cmd {
const char *name;
int (*exec)(struct libscomp_line *, void *);
};
struct libscomp_cmd_store {
struct libscomp_cmd *arr;
size_t len;
};
#if defined(__STDC_VERSION__)
#define libscomp_mkcmds(...) {(struct libscomp_cmd []){__VA_ARGS__}, \
sizeof((struct libscomp_cmd []){__VA_ARGS__}) / \
sizeof((struct libscomp_cmd []){__VA_ARGS__}[0])}
#endif
int libscomp_exec(const struct libscomp_cmd_store *cmds,
struct libscomp_line *ln,
void *ptr
);