aboutsummaryrefslogtreecommitdiff
path: root/src/common.h
blob: d4cce1ddddeab4abb7ac6bbeb29fccd5fc722257 (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
47
48
49
50
51
52
53
#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 {
    char* name;
    enum flag_variants variant;
    uint8_t returns;
    int (*func)(int, char**);
    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);

struct stat getStat(const char* path);
int isFile(const char*);
int isDir(const char*);

int makeDir(const char* path);
int removeDir(const char *path);

#endif