aboutsummaryrefslogtreecommitdiff
path: root/src/common.h
blob: f3f617afb50a5db05c44b67294ab8e2f76c2f88b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef COMMON_H
#define COMMON_H

#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/stat.h>

#include "defines.h"

#include <json.h>

extern uint8_t no_net;

typedef int (*func_t)(int, char**);

struct MemoryStruct {
    uint8_t* memory;
    size_t size;
};

struct Command {
    char* name;
    func_t func;
    char* description;
};

enum flag_variants {
	ONE = 1 << 0,
	TWO = 1 << 1,
	BOTH   = ONE + TWO,
};

struct Flag {
    const char* name;
    enum flag_variants variant;
    uint8_t returns;
    int (*func)(int, char**);
    const char* description;
};

int set_no_net(UNUSED int argc, UNUSED char** argv);

void print_help(const struct Command*, size_t, const struct Flag*, size_t);

#endif