From 27ae570d688aedd40c3e175b746ee900d08b81d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Fri, 21 Jun 2024 21:48:02 +0900 Subject: =?UTF-8?q?libc=E3=81=AE=E6=83=85=E5=A0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libc.c | 24 ++++++++++++++++++++++++ src/libc.h | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 src/libc.c create mode 100644 src/libc.h (limited to 'src') diff --git a/src/libc.c b/src/libc.c new file mode 100644 index 0000000..9b3a129 --- /dev/null +++ b/src/libc.c @@ -0,0 +1,24 @@ +#include "libc.h" +#include "common.h" + +#include +#include +#include + +const char *display_libc() { +#if defined(__linux__) + const char *musl = run_command_s("ldd $(which ls) | grep libc | grep musl)"; + if (musl != NULL && strlen(musl) != 0) { + free((void *)musl); + return "musl"; + } + + const char *glibc = run_command_s("ldd $(which ls) | grep libc | grep gnu"); + if (glibc != NULL && strlen(glibc) != 0) { + free((void *)glibc); + return "glibc"; + } +#endif + + return NULL; +} diff --git a/src/libc.h b/src/libc.h new file mode 100644 index 0000000..0558a77 --- /dev/null +++ b/src/libc.h @@ -0,0 +1,6 @@ +#ifndef LIBC_H +#define LIBC_H + +const char *display_libc(); + +#endif -- cgit v1.2.3