-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
22 lines (18 loc) · 1.13 KB
/
common.h
File metadata and controls
22 lines (18 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#define ASSERT(cond, status, ...) \
if (!(cond)) { \
fprintf(stderr, __VA_ARGS__); \
exit((status)); \
}
struct FnTable {
const char *name;
int (*fn)(int, char **);
};
int do_cmd(size_t cmds_len, const struct FnTable cmds[static cmds_len], int argc, char **argv);
[[gnu::cold]] void print_cmds(size_t cmds_len, const struct FnTable cmds[static cmds_len], const char name[static 1]);
int do_cmd_full(size_t cmds_len, const struct FnTable cmds[static cmds_len], int argc, char **argv, const char name[static 1]);