Cleanup
[carla.git] / source / interposer / interposer-safe.cpp
blob6c14fc7a2c4a4d426b1a4a80c2049367dc350bb3
1 /*
2 * Carla Interposer for unsafe backend functions
3 * Copyright (C) 2014-2022 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "CarlaUtils.hpp"
20 #include <cerrno>
21 #include <dlfcn.h>
22 #include <sched.h>
23 #include <spawn.h>
25 #define PREVENTED_FUNC_MSG carla_stderr2("Carla prevented a plugin from calling '%s', bad plugin!", __FUNCTION__)
27 // -----------------------------------------------------------------------
28 // Gtk stuff
30 CARLA_PLUGIN_EXPORT void gtk_init(int*, char***);
31 CARLA_PLUGIN_EXPORT int gtk_init_check(int*, char***);
32 CARLA_PLUGIN_EXPORT int gtk_init_with_args(int*, char***, const char*, void*, const char*, void**);
34 // -----------------------------------------------------------------------
35 // Our custom functions
37 CARLA_PLUGIN_EXPORT
38 pid_t fork()
40 PREVENTED_FUNC_MSG;
41 errno = ENOSYS;
42 return -1;
45 CARLA_PLUGIN_EXPORT
46 int clone(int (*)(void*), void*, int, void*, ...)
48 PREVENTED_FUNC_MSG;
49 errno = ENOSYS;
50 return -1;
53 CARLA_PLUGIN_EXPORT
54 int posix_spawn(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const[], char* const[])
56 PREVENTED_FUNC_MSG;
57 return ENOSYS;
60 CARLA_PLUGIN_EXPORT
61 int posix_spawnp(pid_t*, const char*, const posix_spawn_file_actions_t*, const posix_spawnattr_t*, char* const[], char* const[])
63 PREVENTED_FUNC_MSG;
64 return ENOSYS;
67 // -----------------------------------------------------------------------
69 CARLA_PLUGIN_EXPORT
70 void exit(int status)
72 carla_stderr2("Carla prevented a plugin from calling 'exit', redirecting to '_exit' instead, bad plugin!");
73 _exit(status);
76 // -----------------------------------------------------------------------
78 CARLA_PLUGIN_EXPORT
79 void gtk_init(int*, char***)
81 PREVENTED_FUNC_MSG;
84 CARLA_PLUGIN_EXPORT
85 int gtk_init_check(int*, char***)
87 PREVENTED_FUNC_MSG;
88 return 0;
91 CARLA_PLUGIN_EXPORT
92 int gtk_init_with_args(int*, char***, const char*, void*, const char*, void**)
94 PREVENTED_FUNC_MSG;
95 return 0;
98 // -----------------------------------------------------------------------