about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedutil.c
blob: 91503f78d91e8a078cd75e81702b569d0d9eb906 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <dlfcn.h>

#include "wrappedlibs.h"

#include "box64stack.h"
#include "x64emu.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "callback.h"
#include "librarian.h"
#include "librarian/library_private.h"
#include "emu/x64emu_private.h"
#include "box64context.h"

const char* utilName = "libutil.so.1";
#define LIBNAME util

EXPORT pid_t my_forkpty(x64emu_t* emu, void* amaster, void* name, void* termp, void* winp)
{
    static forkpty_t forkinfo;
    forkinfo.amaster = amaster;
    forkinfo.name = name;
    forkinfo.termp = termp;
    forkinfo.winp = winp;
    library_t* lib = GetLibInternal(utilName);
    forkinfo.f = dlsym(lib->w.lib, "forkpty");
    
    emu->quit = 1;
    emu->fork = 2;
    emu->forkpty_info = &forkinfo;
        
    return 0;
}

#ifdef STATICBUILD
#include <pty.h>
#include <utmp.h>
#endif

#ifdef STATICBUILD
#else
#define PRE_INIT\
    if(1)                                                      \
        lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);    \
    else
#endif

#include "wrappedlib_init.h"