Move DEBUG macro to own header to be a standalone helper

This commit is contained in:
Pablo Marcos Oltra 2018-01-06 19:09:53 +01:00
parent 2f04ad81c6
commit 2796ea1f5f
4 changed files with 17 additions and 9 deletions

View file

@ -18,6 +18,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "debug.h"
#include <stdio.h>
#include <stdlib.h>
@ -47,7 +48,6 @@
char *optional = NULL;
char *optional_ld_preload = NULL;
int debug_flag = 0;
void checkrt(char *usr_in_appdir)
{
@ -63,8 +63,6 @@ void checkrt(char *usr_in_appdir)
char *gcc_bundle_lib = "./" GCCDIR "/libgcc_s.so.1";
const char *format = "tr '\\0' '\\n' < '%s' | grep -e '%s' | tail -n1";
debug_flag = getenv("APPIMAGE_CHECKRT_DEBUG") ? 1 : 0;
if (access(stdcxx_bundle_lib, F_OK) == 0) {
f = popen("ldconfig -p | grep 'libstdc++.so.6 (" LIBC6_ARCH ")' | awk 'NR==1{print $NF}'", "r");
ret = fscanf(f, "%s", stdcxx_sys_lib); (void)ret;

View file

@ -1,9 +1,8 @@
#ifndef CHEKRT_H
#define CHECKRT_H
extern char *optional;
extern char *optional_ld_preload;
extern void checkrt(char *usr_in_appdir);
extern int debug_flag;
#define DEBUG(...) do { \
if (debug_flag) \
printf(__VA_ARGS__); \
} while (0)
#endif

11
debug.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef DEBUG_H
#define DEBUG_H
#include <stdlib.h>
#define DEBUG(...) do { \
if (getenv("APPIMAGE_CHECKRT_DEBUG")) \
printf(__VA_ARGS__); \
} while (0)
#endif // DEBUG_H

2
exec.c
View file

@ -42,7 +42,7 @@ variable (e.g. "PATH"):
#define _GNU_SOURCE
#include "checkrt.h"
#include "debug.h"
#include <unistd.h>
#include <dlfcn.h>