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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#ifndef NAK_FFI_H
#define NAK_FFI_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ========================================================================
* Tier 1: Game Detection
* ======================================================================== */
/** A detected game installation */
typedef struct {
char *name;
char *app_id;
char *install_path;
char *prefix_path; /* NULL if no prefix */
char *launcher; /* display name string */
char *my_games_folder; /* NULL if not applicable */
char *appdata_local_folder; /* NULL if not applicable */
char *appdata_roaming_folder; /* NULL if not applicable */
char *registry_path; /* NULL if not applicable */
char *registry_value; /* NULL if not applicable */
} NakGame;
/** List of detected games */
typedef struct {
NakGame *games;
size_t count;
size_t steam_count;
size_t heroic_count;
size_t bottles_count;
} NakGameList;
/** Detect all installed games across all launchers */
NakGameList nak_detect_all_games(void);
/** Free a NakGameList returned by nak_detect_all_games */
void nak_game_list_free(NakGameList list);
/** A known game definition (static data, do NOT free) */
typedef struct {
const char *name;
const char *steam_app_id;
const char *gog_app_id; /* NULL if none */
const char *epic_app_id; /* NULL if none */
const char *my_games_folder; /* NULL if not applicable */
const char *appdata_local_folder; /* NULL if not applicable */
const char *appdata_roaming_folder; /* NULL if not applicable */
const char *registry_path;
const char *registry_value;
const char *steam_folder;
} NakKnownGame;
/** Get the list of all known games (static data, do NOT free).
* Returns pointer to array; writes count to *out_count. */
const NakKnownGame *nak_get_known_games(size_t *out_count);
/* ========================================================================
* Tier 2: Proton Detection
* ======================================================================== */
/** An installed Proton version */
typedef struct {
char *name;
char *config_name;
char *path;
int is_steam_proton;
int is_experimental;
} NakSteamProton;
/** List of detected Proton installations */
typedef struct {
NakSteamProton *protons;
size_t count;
} NakProtonList;
/** Find all installed Proton versions */
NakProtonList nak_find_steam_protons(void);
/** Free a NakProtonList */
void nak_proton_list_free(NakProtonList list);
/* ========================================================================
* Tier 3: Steam Paths
* ======================================================================== */
/** Find the Steam installation path.
* Returns newly allocated string (free with nak_string_free), or NULL. */
char *nak_find_steam_path(void);
/* ========================================================================
* Tier 4: Dependency Installation (callback-based)
* ======================================================================== */
/** Callback for status/log messages */
typedef void (*NakStatusCallback)(const char *message);
typedef void (*NakLogCallback)(const char *message);
/** Callback for progress updates (0.0 to 1.0) */
typedef void (*NakProgressCallback)(float progress);
/** Install all Wine prefix dependencies (blocking call).
* cancel_flag: pointer to int, set non-zero to cancel.
* Returns NULL on success, or error message (free with nak_string_free). */
char *nak_install_all_dependencies(
const char *prefix_path,
const char *proton_name,
const char *proton_path,
NakStatusCallback status_cb,
NakLogCallback log_cb,
NakProgressCallback progress_cb,
const int *cancel_flag,
uint32_t app_id
);
/** Apply Wine registry settings to a prefix.
* Returns NULL on success, or error message (free with nak_string_free). */
char *nak_apply_wine_registry_settings(
const char *prefix_path,
const char *proton_name,
const char *proton_path,
NakLogCallback log_cb,
uint32_t app_id
);
/** Apply a game's registry entry with a custom install path.
* Looks up game_name in KNOWN_GAMES and writes registry pointing to install_path.
* Returns NULL on success, or an error message (free with nak_string_free). */
char *nak_apply_registry_for_game_path(
const char *prefix_path,
const char *proton_name,
const char *proton_path,
const char *game_name,
const char *install_path,
NakLogCallback log_cb
);
/* ========================================================================
* Tier 5: Prefix Symlinks
* ======================================================================== */
/** Ensure AppData/Local/Temp exists in the Wine prefix.
* Call during prefix creation. */
void nak_ensure_temp_directory(const char *prefix_path);
/** Detect games and create symlinks from the prefix to game prefixes.
* Call during prefix creation. */
void nak_create_game_symlinks_auto(const char *prefix_path);
/* ========================================================================
* Tier 6: Logging
* ======================================================================== */
/** Callback for NaK log messages: (level, message).
* Levels: "info", "warning", "error", "install", "action", "download" */
typedef void (*NakLogLevelCallback)(const char *level, const char *message);
/** Initialize NaK logging with a callback.
* Call once at startup before any other nak_* functions. */
void nak_init_logging(NakLogLevelCallback cb);
/* ========================================================================
* Tier 7: DXVK Configuration
* ======================================================================== */
/** Ensure the DXVK config file exists, downloading if necessary.
* Returns NULL on success, or error message (free with nak_string_free). */
char *nak_ensure_dxvk_conf(void);
/** Get the path to the DXVK config file.
* Returns newly allocated string (free with nak_string_free). */
char *nak_get_dxvk_conf_path(void);
/* ========================================================================
* Tier 8: Steam Linux Runtime (SLR)
* ======================================================================== */
/** Returns 1 if SteamLinuxRuntime_sniper is installed and the run script exists, 0 otherwise. */
int nak_slr_is_installed(void);
/** Get the path to the SLR run script.
* Returns NULL if SLR is not installed.
* Caller must free with nak_string_free(). */
char *nak_slr_get_run_script(void);
/** Download and install SteamLinuxRuntime_sniper from Valve's repo (~180 MB).
* Skips if already at the latest version (checked via BUILD_ID).
* progress_cb: 0.0..1.0 during download (may be NULL).
* status_cb: human-readable status strings (may be NULL).
* cancel_flag: pointer to int, set non-zero to cancel (may be NULL).
* Returns NULL on success, or error message (free with nak_string_free). */
char *nak_download_slr(
NakProgressCallback progress_cb,
NakStatusCallback status_cb,
const int *cancel_flag
);
/* ========================================================================
* Tier 9: PE Icon Extraction
* ======================================================================== */
/** Result of icon extraction */
typedef struct {
uint8_t *data; /**< Raw ICO file bytes (NULL if extraction failed) */
size_t len; /**< Length in bytes (0 if extraction failed) */
} NakIconData;
/** Extract the best icon from a Windows PE executable (.exe/.dll).
* Returns raw ICO bytes. Free with nak_icon_data_free(). */
NakIconData nak_extract_exe_icon(const char *exe_path);
/** Free icon data returned by nak_extract_exe_icon */
void nak_icon_data_free(NakIconData icon);
/* ========================================================================
* General
* ======================================================================== */
/** Free a string returned by any nak_* function */
void nak_string_free(char *s);
#ifdef __cplusplus
}
#endif
#endif /* NAK_FFI_H */
|