-
Notifications
You must be signed in to change notification settings - Fork 7
/
cosmogfx.c
68 lines (59 loc) · 1.24 KB
/
cosmogfx.c
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
#include "cosmogfx.h"
#include "elf_loader.h"
#include "glcv/src/cv.c"
intptr_t osEvent_xlib(ev *e);
intptr_t osEvent_win(ev *e);
extern int cvrun_xlib(int, char **);
extern int cvrun_win(int, char **);
#define cvrun cvrun_xlib
#define osEvent osEvent_xlib
#include "glcv/src/xlib.c"
#undef osEvent
#undef cvrun
#include <libc/isystem/windows.h>
#undef cvrun
#define cvrun cvrun_win
#define osEvent osEvent_win
#include "glcv/src/win.c"
#undef osEvent
#undef cvrun
intptr_t
osEvent(ev *e)
{
if (IsWindows())
return osEvent_win(e);
else
return osEvent_xlib(e);
}
static int
cont(void **p, int argc, char **argv)
{
z_dlopen = p[0];
z_dlsym = p[1];
z_dlclose = p[2];
z_dlerror = p[3];
cvrun_xlib(argc, argv);
}
int
cosmogfx_init(int argc, char **argv, char **envp)
{
dtrampoline_init();
if (IsWindows())
cvrun_win(argc, argv);
else {
argv[argc] = (char *)cont;
char interp[256];
elf_interp(interp, sizeof(interp), "/usr/bin/env");
const char *helper;
if (IsOpenbsd())
helper = "/zip/helper/obsd";
else if (IsFreebsd())
helper = "/zip/helper/fbsd";
else if (IsNetbsd())
helper = "/zip/helper/nbsd";
else
helper = "/zip/helper/linux";
elf_exec(helper, interp, argc, argv, envp);
}
}
STATIC_YOINK("zip_uri_support");