summaryrefslogtreecommitdiff
path: root/src/libc.c
blob: e739976ad6f7e0300a969a1c7a5b83c1a7b3349b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "libc.h"
#include "common.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

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;
}