aboutsummaryrefslogtreecommitdiff
path: root/src/common.h
blob: fdd5ac291e3d0c749b71c120035d0a7801db2b0d (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
54
55
#ifndef COMMON_H
#define COMMON_H

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

#define ARRAY_LEN(arr) sizeof(arr) / sizeof(arr[0])

#define WINE_API "https://lutris.net/api/runners/wine"
#define DXVK_API "https://api.github.com/repos/lutris/dxvk/releases"
#define INSTALLER_API "https://lutris.net/api/installers/"

#ifndef NAME
#warning "no name specified, setting it to \"polecat\""
#define NAME "polecat"
#endif

#ifndef VERSION
#warning "no version specified, setting it to \"0.0.0\""
#define VERSION "0.0.0"
#endif

#define USER_AGENT NAME "/" VERSION

#define USAGE_STR "Usage: " NAME

#ifdef DEBUG
#define unreachable printf("unreachable code reached\n" __FILE__ ":L%i\n", __LINE__); exit(0);
#else
#define unreachable
#endif

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

struct Command {
    char* name;
    int (*func)(int, char**);
    char* description;
};

void print_help(const struct Command*, size_t);

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

void makeDir(const char* path);

#endif