aboutsummaryrefslogtreecommitdiff
path: root/src/lutris.h
blob: 074cebd526b62e5284ea723222a3d8c4e5f5d492 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef LUTRIS_H
#define LUTRIS_H

#include <stddef.h>
#include <json.h>

#define VARIABLESIGN '$'

#include "lutris/enum.h"
enum keyword_t {
    #include "lutris/keyword.h"

    KEYWORDMAX,
    unknown_keyword
};

enum task_t {
    #include "lutris/task.h"

    TASKKEYWORDMAX,
    no_task,
    unknown_task
};

enum runner_t {
    #include "lutris/runner.h"

    RUNNERMAX
};

#include "lutris/array.h"
static const char keywordstr[KEYWORDMAX][0xF] = {
    #include "lutris/keyword.h"
};


static const char taskKeywordstr[TASKKEYWORDMAX][0xF] = 
{
    #include "lutris/task.h"
};

static const char runnerStr[RUNNERMAX][0xF] = 
{
    #include "lutris/runner.h"
};


enum errors {
    NONE,
    NO_JSON,
    NO_SLUG,
    NO_SCRIPT,
    NO_INSTALLER,
};

struct directive_t {
    enum keyword_t command;
    enum task_t task;
    char** arguments;
    size_t size;
};

struct file_t {
    char* name;
    char* url;
};

enum value_type_t {
    value_string,
    value_function
};

struct list_t {
    char* key;
    enum value_type_t type;
    union
    {
        char* str;
        char* (*func)();
    } value;
};

// my best attempt at representing a Lutris installer as a struct
struct script_t {
    char* name;
    char* version;
    enum runner_t runner;
    char* description;
    char* notes;
    char* wine;

    struct directive_t** directives;
    size_t directivecount;

    struct file_t** files;
    size_t filecount;

    struct list_t** variables;
    size_t variablecount;

    enum errors error;
};

#include "command.h"

COMMAND_GROUP(lutris);
COMMAND(lutris, search);
COMMAND(lutris, list);
COMMAND(lutris, install);
COMMAND(lutris, info);
COMMAND(lutris, help);

void lutris_escapeString(char*, size_t);
struct script_t lutris_getInstaller(char*);
void lutris_freeInstaller(struct script_t*);

size_t parseVar(char**, struct list_t**, size_t);

#endif