Initial commit

This commit is contained in:
2023-01-07 14:48:58 +01:00
commit 5f9eea797d
13 changed files with 1600 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Ignore C stdlibs
libs/
# Ignore output files
output*/
output.json
a.out
# Ignore SuS specs files
sus*/

53
README.md Normal file
View File

@@ -0,0 +1,53 @@
# C Libraries Function Indexer
This project aims to index functions from the multiple implementations of the standard C libraries, and
for any of them show in which implementation or standard they can be found.
Examples of covered standards are : C99, C11, SuSv2, SuSv4
Examples of covered implementations are : glibc, uClibc-ng, FreeBSD libc
The goal would be to index all standard functions, GNU extensions, BSD extensions at least.
This way, when wondering if the function is GNU/BSD or standard, one could just look it up in the
database and even see wether the extension is adopted (i.e. present in other implementations) or not.
This repository contains the tools used to generate a json database of functions.
## Using the database
The database can be accessed via the web hosted implementation [here]().
It was generated on my personal computer, using virtual machines.
## Generating a database
Generation can only be done under linux-glibc, and it assumes that `/bin/sh` is `bash`.
You will need multiple tests systems (either physical computers or virtual machines)
to index the bsds, macos, windows implementations.
The main script should tell you everything you need :
```
chmod +x main.sh index.sh getlib.sh merge.sh # Add execution rights if needed
./main.sh
```
## Internal organization
- main.sh :
The main script. Checks for library/std installations, runs the indexer, and asks the user to run it on different systems.
- index.sh :
The core of the project : index functions from different libcs, check for standards. Can be run in 'local system' mode.
- index-win.bat :
The 'local system' version of the indexer, for Windows.
- getlib.sh :
A script to obtain (download, configure, compile, install) all tested libc (glibc, uClibc-ng, ...) under the ./libs directory.
- merge.sh :
A script to merge outputs (i.e. indexer output and local indexer output on freebsd), used to obtain final outputs.
- merge-bigjson.sh
A script to merge all headers json files into one big json file.
## TODO
- Generate "stdh.sh" automatically, including : Cstd, SuS, GNU exts, BSD exts
- MacOS indexer
- Windows indexer (WIP, need stdh generator to generate powershell arrays....)

19
genf.sh Executable file
View File

@@ -0,0 +1,19 @@
# Generate multiple function arrays from man2 and man3 entries
ls /usr/share/man/man2 | sed 's/\.2.*//' | while read F; do
I=$(man 2 $F | grep '#include' | head -1 | sed 's/>.*$/>/')
if [ -z "$I" ]; then
continue
fi
i_name=$(echo $I | sed 's/.*<//;s/>.*//')
i_name_clean=$(echo $i_name | sed 's/\//_/g' | sed 's/\.h//')
# Add $f to $i_name_clean array
eval "${i_name_clean}+=(\"${F}\")"
echo "${i_name_clean}+=(\"${F}\")"
done
echo "Example output:"
echo "unistd=(${unistd[@]})"
echo "sys_uio=(${sys_uio[@]})"

166
getlib.sh Executable file
View File

@@ -0,0 +1,166 @@
#!/bin/sh
# Create libs folder
local_path=$(realpath .)
lib_path=$local_path/libs
mkdir -p $lib_path
cd $lib_path
# Prepare build environment
mkdir -p build
cd build
# Obtain the GNU C Library (glibc)
glibc_version="2.36"
if [ ! -f "glibc-${glibc_version}.tar.xz" ]; then
wget "https://ftp.gnu.org/gnu/libc/glibc-${glibc_version}.tar.xz"
fi
if [ ! -d "glibc-${glibc_version}" ]; then
tar -xf glibc-${glibc_version}.tar.xz
fi
cd glibc-${glibc_version}
mkdir build
cd build
../configure --prefix=$lib_path/glibc
if [ $? -ne 0 ]; then
echo "Error: glibc configure failed"
return 1 2>/dev/null || exit 1
fi
make -j7
if [ $? -ne 0 ]; then
echo "Error: glibc make failed"
return 1 2>/dev/null || exit 1
fi
make install
if [ $? -ne 0 ]; then
echo "Error: glibc make install failed"
return 1 2>/dev/null || exit 1
fi
cd ../..
# Obtain musl
musl_version="1.2.3"
if [ ! -f "musl-${musl_version}.tar.gz" ]; then
wget "https://musl.libc.org/releases/musl-${musl_version}.tar.gz"
fi
if [ ! -d "musl-${musl_version}" ]; then
tar -xf musl-${musl_version}.tar.gz
fi
cd musl-${musl_version}
mkdir build
cd build
../configure --prefix=$lib_path/musl
if [ $? -ne 0 ]; then
echo "Error: musl configure failed"
return 1 2>/dev/null || exit 1
fi
make -j7
if [ $? -ne 0 ]; then
echo "Error: musl make failed"
return 1 2>/dev/null || exit 1
fi
make install
if [ $? -ne 0 ]; then
echo "Error: musl make install failed"
return 1 2>/dev/null || exit 1
fi
cd ../..
# NOTE : newlib cannot be built for x86_64-linux, as it targets embedded systems
# Only i686-linux is supported, and they do not plan to support x86_64-linux, it seems...
# # Obtain newlib
# newlib_version="4.2.0.20211231"
# if [ ! -f "newlib-${newlib_version}.tar.gz" ]
# then
# wget "ftp://sourceware.org/pub/newlib/newlib-${newlib_version}.tar.gz"
# fi
# if [ ! -d "newlib-${newlib_version}" ]
# then
# tar -xf newlib-${newlib_version}.tar.gz
# fi
# cd newlib-${newlib_version}/newlib
# mkdir build
# cd build
# ../configure --with-newlib --prefix=$lib_path/newlib --disable-multilib
# if [ $? -ne 0 ]; then
# echo "Error: newlib configure failed"
# return 1 2>/dev/null || exit 1
# fi
# make -j7
# if [ $? -ne 0 ]; then
# echo "Error: newlib make failed"
# return 1 2>/dev/null || exit 1
# fi
# make install
# if [ $? -ne 0 ]; then
# echo "Error: newlib make install failed"
# return 1 2>/dev/null || exit 1
# fi
# cd ../../..
# Obtain uClibc-ng
uClibc_ng_version="1.0.42"
if [ ! -f "uClibc-ng-${uClibc_ng_version}.tar.gz" ]; then
wget "https://downloads.uclibc-ng.org/releases/${uClibc_ng_version}/uClibc-ng-${uClibc_ng_version}.tar.gz"
fi
if [ ! -d "uClibc-ng-${uClibc_ng_version}" ]; then
tar -xf uClibc-ng-${uClibc_ng_version}.tar.gz
fi
cd "uClibc-ng-${uClibc_ng_version}"
make defconfig
if [ $? -ne 0 ]; then
echo "Error: uClibc-ng make defconfig failed"
return 1 2>/dev/null || exit 1
fi
#prefix=$lib_path/uClibc-ng
#escaped_prefix=$(printf '%s\n' "$prefix" | sed -e 's/[\/&]/\\&/g')
#sed -i -e "/RUNTIME_PREFIX=/ s/=.*/=\"${escaped_prefix}\"/" .config
sed -i -e "/HAVE_SHARED=/ s/=.*/=n/" .config
# Enable math support
# Replace "# DO_C99_MATH is not set" with "DO_C99_MATH=y"
sed -i 's/# DO_C99_MATH is not set/DO_C99_MATH=y/' .config
# Replace "# DO_XSI_MATH is not set" with "DO_XSI_MATH=y"
sed -i 's/# DO_XSI_MATH is not set/DO_XSI_MATH=y/' .config
# Add the following lines to the end of the file
echo "UCLIBC_HAS_LONG_DOUBLE_MATH=y" >>.config
# Make sure the kernel headers are set to the correct path
sed -i -e '/KERNEL\_HEADERS=/ s/=.*/=\"\/usr\/include\/\"/' .config
make -j7
if [ $? -ne 0 ]; then
echo "Error: uClibc-ng make failed"
echo "Maybe make sure you have the kernel headers installed at /usr/include/, or change the KERNEL_HEADERS variable in .config to the correct path ?"
return 1 2>/dev/null || exit 1
fi
make DESTDIR=$lib_path/uClibc-ng PREFIX=$lib_path/uClibc-ng install
if [ $? -ne 0 ]; then
echo "Error: uClibc-ng make install failed"
return 1 2>/dev/null || exit 1
fi
mv $lib_path/uClibc-ng/usr/x86_64-linux-uclibc/usr/* $lib_path/uClibc-ng/
rm -rf $lib_path/uClibc-ng/usr
cd ..
# Obtain dietlibc
dietlibc_version="0.34"
if [ ! -f "dietlibc-${dietlibc_version}.tar.xz" ]; then
wget "https://www.fefe.de/dietlibc/dietlibc-${dietlibc_version}.tar.xz"
fi
if [ ! -d "dietlibc-${dietlibc_version}" ]; then
tar -xf dietlibc-${dietlibc_version}.tar.xz
fi
cd dietlibc-${dietlibc_version}
make -j7 DESTDIR=$lib_path/dietlibc
if [ $? -ne 0 ]; then
echo "Error: dietlibc make failed"
return 1 2>/dev/null || exit 1
fi
make install DESTDIR=$lib_path/dietlibc
if [ $? -ne 0 ]; then
echo "Error: dietlibc make install failed"
return 1 2>/dev/null || exit 1
fi
mv $lib_path/dietlibc/opt/diet/* $lib_path/dietlibc/
rmdir $lib_path/dietlibc/opt/diet
rmdir $lib_path/dietlibc/opt
mv $lib_path/dietlibc/lib-x86_64 $lib_path/dietlibc/lib
cd ..

20
index-win.bat Normal file
View File

@@ -0,0 +1,20 @@
# Index functions of libc (Windows)
# Obtain local MSVC version
$msvc_version=Get-Content 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt'
echo "MSVC version: ${msvc_version}"
# Make sure the MSVC command line tools are installed and in the path
$msvc_path="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\${msvc_version}\bin\Hostx64\x64\cl.exe"
$msvc=&$msvc_path
if (-not $?)
{
# cl.exe not found...
echo "Could not find the MSVC compiler (cl.exe) ; searched: "
echo $msvc_path
exit 1
}
$dumpbin_path="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\${msvc_version}\bin\Hostx64\x64\dumpbin.exe"
# Use dumpbin to index functions of libc
&$dumpbin_path /exports C:\Windows\SysWOW64\msvcrt.dll

267
index.sh Executable file
View File

@@ -0,0 +1,267 @@
#!/bin/sh
gcc_dumpmachine=$(gcc -dumpmachine)
gcc_version=$(gcc -dumpversion)
gcc_program_output=/tmp/a.out
# Check for --local-system option
if [ "$1" == "--local-system" ]; then
local_system=1
# Check for local system name
if [ -z "$2" ]; then
echo "Error: local system name not specified"
echo "Usage: ./index.sh [--local-system <name> <./lib,./include path>]"
return 1 2>/dev/null || exit 1
fi
local_system_name=$2
# Check for local system path
if [ -z "$3" ]; then
echo "Error: local system path not specified"
echo "Usage: ./index.sh [--local-system <name> <./lib,./include path>]"
return 1 2>/dev/null || exit 1
fi
local_system_path=$3
else
local_system=0
fi
# LIBC
libc_names=("glibc" "musl" "uClibc-ng" "dietlibc")
# Present/Absent markers (colors)
p="\e[32m"
pe="\e[0m"
n="\e[31m"
ne="\e[0m"
# Warning markers (colors)
w="\e[33m"
we="\e[0m"
# C Standards
cstd=("c89" "c99" "c11" "c2x")
# SuS standards
sus=("susv2" "susv3" "susv4")
# Headers
sus_headers=("aio" "arpa/inet" "assert" "complex" "cpio" "ctype" "dirent" "dlfcn" "errno" "fcntl" "fenv" "float" "fmtmsg" "fnmatch" "ftw" "glob" "grp" "iconv" "inttypes" "iso646" "langinfo" "libgen" "limits" "locale" "math" "monetary" "mqueue" "ndbm" "net/if" "netdb" "netinet/in" "netinet/tcp" "nl_types" "poll" "pthread" "pwd" "regex" "sched" "search" "semaphore" "setjmp" "signal" "spawn" "stdarg" "stdbool" "stddef" "stdint" "stdio" "stdlib" "string" "strings" "stropts" "sys/ipc" "sys/mman" "sys/msg" "sys/resource" "sys/select" "sys/sem" "sys/shm" "sys/socket" "sys/stat" "sys/statvfs" "sys/time" "sys/times" "sys/types" "sys/uio" "sys/un" "sys/utsname" "sys/wait" "syslog" "tar" "termios" "tgmath" "time" "trace" "ulimit" "unistd" "utime" "utmpx" "wchar" "wctype" "wordexp")
c89=("assert" "ctype" "errno" "float" "limits" "locale" "math" "setjmp" "signal" "stdarg" "stddef" "stdio" "stdlib" "string" "time")
c99=(${c89[@]} "complex" "fenv" "inttypes" "iso646" "stdbool" "stdint" "tgmath" "wchar" "wctype")
c11=(${c99[@]} "stdalign" "stdatomic" "stdnoreturn" "threads")
c2x=(${c11[@]} "stdbit" "stdckdint")
# Headers list
combined=("${sus_headers[@]}" "${c2x[@]}")
headers=($(printf '%s\n' ${combined[@]} | sort -u))
# Import functions
source ./stdh.sh
check_std_c() {
for std in ${cstd[@]}; do
json+="\"${std}\":"
# Check if header is included in current standard
std_headers=($(eval 'echo ${'$std'[@]}'))
printf '%s\0' "${std_headers[@]}" | grep -Fxqz -- $header_name
if [ ! $? -eq 0 ]; then
json+="false,"
echo -e -n $n$std$ne" "
continue
fi
# Compile a program doing `if(function)`
echo -e "#include <${header_name}.h>\nint main()\n{\n\tif("$f") return 0; else return 1;\n}\n" | gcc -std=$std -xc - -o ${gcc_program_output} >/dev/null 2>&1
# Check gcc output
if [ $? -eq 0 ]; then
${gcc_program_output}
if [ $? -eq 0 ]; then
json+="true"
echo -e -n $p$std$pe" "
else
json+="false"
echo -e -n $n$std$ne" "
fi
else
# Check if function is in fact a macro
echo -e "#include <${header_name}.h>\nint main()\n{\n\t#ifdef ${f}\n\treturn 0;\n\t#else\n\treturn 1;\n\t#endif\n}\n" | gcc -std=$std -xc - -o ${gcc_program_output} >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
# This should never fail unless header is broken
echo -e "\nFatal: ${f}() in ${header_name} resolution as macro made gcc fail"
echo " This should never happen, please report this bug"
return 1 2>/dev/null || exit 1
fi
${gcc_program_output}
if [ $? -eq 0 ]; then
json+="true"
echo -e -n $p$std$pe" "
else
json+="false"
echo -e -n $n$std$ne" "
fi
fi
json+=","
done
}
check_for_libc() {
lib_name=$1
lib_dir=$2
lib_path=$2/lib/libc.a
# Check for symbol in libc
json+="\""$lib_name"\":"
objdump -t $lib_path | grep -w $f"$" >/dev/null
if [ $? -eq 0 ]; then
json+="true"
echo -e -n $p$lib_name$pe" "
else
# Function not found in libc : check in other libraries in the same directory
found=false
other_libs=($(find ${lib_dir}/lib -maxdepth 1 -name "*.a" '!' -name "libc.a"))
# If header is math.h/complex.h, begin searching in math library
if [ $header_name = "math" ] || [ $header_name = "complex" ] || [ $header_name = "fenv" ]; then
other_libs+=($other_libs)
other_libs[0]="${lib_dir}/lib/libm.a"
fi
# If header is threads.h/pthread.h, begin searching in libpthread
if [ $header_name = "threads" ] || [ $header_name = "pthread" ]; then
other_libs+=($other_libs)
other_libs[0]="${lib_dir}/lib/libpthread.a"
fi
# If header is aio.h, begin searching in librt
if [ $header_name = "aio" ]; then
other_libs+=($other_libs)
other_libs[0]="${lib_dir}/lib/librt.a"
fi
for lib in ${other_libs[@]}; do
objdump -t $lib 2>/dev/null | grep -w $f"$" >/dev/null 2>&1
if [ $? -eq 0 ]; then
# Obtain library name, and remove extension
olib_name=$(basename $lib)
olib_name=${olib_name%.*}
olib_name=${olib_name%-*}
found=true
json+="true"
echo -e -n $p$lib_name"(${olib_name})"$pe" "
break
fi
done
if [ $found = false ]; then
# Function not found in any library ; check in headers
# Check if header is present
if [ -f "${lib_dir}/include/${header_name}.h" ]; then
if [ $local_system -eq 0 ]; then
link_entry=""
# Check for crt1.o, crti.o and crtn.o
if [ -f "${lib_dir}/lib/crt1.o" ]; then
link_entry+="-l:crt1.o "
fi
if [ -f "${lib_dir}/lib/crti.o" ]; then
link_entry+="-l:crti.o "
fi
if [ -f "${lib_dir}/lib/crtn.o" ]; then
link_entry+="-l:crtn.o "
fi
# Check for start.o
if [ -f "${lib_dir}/lib/start.o" ]; then
link_entry+="-l:start.o "
fi
echo -e "#include <${header_name}.h>\nint main()\n{\n\t#ifdef ${f}\n\t\treturn 0;\n\t#else\n\t\treturn 1;\n\t#endif\n}" | gcc -o ${gcc_program_output} -ffreestanding -nostdlib -xc -I${lib_dir}/include/ -I/usr/lib/gcc/${gcc_dumpmachine}/${gcc_version}/include - -L${lib_dir}/lib/ ${link_entry} -lc -lgcc -lgcc_eh -static >/dev/null 2>&1
else
echo -e "#include <${header_name}.h>\nint main()\n{\n\t#ifdef ${f}\n\t\treturn 0;\n\t#else\n\t\treturn 1;\n\t#endif\n}" | gcc -o ${gcc_program_output} -xc - >/dev/null 2>&1
fi
if [ $? -eq 0 ]; then
${gcc_program_output}
if [ $? -eq 0 ]; then
json+="true"
echo -e -n $p$lib_name"(macro)"$pe" "
else
json+="false"
echo -e -n $n$lib_name$ne" "
fi
else
json+="false"
echo -e -n $n$lib_name$ne$w"(?)"$we" "
fi
else
json+="false"
echo -e -n $n$lib_name$ne" "
fi
fi
fi
json+=","
}
check_for_sus() {
# Check for function file in ./susvx/functions/$f
for s in ${sus[@]}; do
json+="\""$s"\":"
if [ -f "./$s/functions/$f.html" ] || [ -f "./$s/xsh/$f.html" ] || [ -f "./$s/xns/$f.html" ]; then
json+="true"
echo -e -n $p$s$pe" "
else
json+="false"
echo -e -n $n$s$ne" "
fi
json+=","
done
}
for i in ${!headers[@]}; do
header_name=${headers[$i]}
echo "header file "$header_name".h:"
json="["
header_name_clean=$(echo $header_name | sed 's/\//_/g')
header_fns=($(eval 'echo ${'$header_name_clean'[@]}'))
for f in ${header_fns[@]}; do
json+="{\"name\":\""$f"\",\"type\":\"function\","
echo -n "checking for "$f"()... "
# Check for symbol in libc
if [ $local_system -eq 0 ]; then
for i in ${!libc_names[@]}; do
lib_name=${libc_names[$i]}
lib_dir="./libs/${lib_name}"
check_for_libc $lib_name $lib_dir
done
else
check_for_libc $local_system_name $local_system_path
fi
# Check for standards
if [ $local_system -eq 0 ]; then
check_std_c
check_for_sus
fi
json+="\"header\":\"${header_name}\"},"
echo ""
done
# Output JSON
json+="{}"
json+=" ]"
o="output/${header_name}.json"
mkdir -p "${o%/*}"
echo -e $json >output/$header_name.json
done
# Cleanup
rm -f ${gcc_program_output}

90
main.sh Executable file
View File

@@ -0,0 +1,90 @@
#!/bin/sh
# Check if gcc is installed
if ! [ -x "$(command -v gcc)" ]; then
echo "Error: gcc is not installed"
return 1 2>/dev/null || exit 1
fi
# Check host architecture
host_triple=$(gcc -dumpmachine)
if [ $? -ne 0 ]; then
echo "Error: gcc dumpmachine failed"
return 1 2>/dev/null || exit 1
fi
if [ $host_triple != "x86_64-pc-linux-gnu" ]; then
echo "Error: host architecture is not x86_64-linux-gnu"
return 1 2>/dev/null || exit 1
fi
# Check if libs are installed
if [ ! -d "libs" ]; then
echo "Installing libs"
./getlib.sh
if [ $? -ne 0 ]; then
echo "Error: getlib failed"
return 1 2>/dev/null || exit 1
fi
fi
# Check if susvx are installed
sus=("susv2" "susv3" "susv4")
for s in ${sus[@]}; do
if [ ! -d "$s" ]; then
echo "Error: Please obtain the '$s' directory from the Open Group"
return 1 2>/dev/null || exit 1
fi
done
# Index libraries
./index.sh
# Move output
mv output/ output-index/
# Ask the user to run on multiple systems
echo "The script will ssh run on other systems (MacOS, FreeBSD, ...) and merge the results"
#echo "Usage: ./index.sh --local-system <system name> <system /lib,/include path>"
#echo "To merge multiple results : ./merge.sh <output> <input1> <input2>"
echo "------------------------------------------------------------"
echo "FreeBSD : bash index.sh --local-system freebsd-libc /usr/"
scp index.sh freebsd:/home/$USER/index.sh
scp stdh.sh freebsd:/home/$USER/stdh.sh
ssh freebsd "bash index.sh --local-system freebsd-libc /usr/"
scp -r freebsd:/home/$USER/output ./output-freebsd
echo "------------------------------------------------------------"
echo "OpenBSD : bash index.sh --local-system openbsd-libc /usr/"
scp index.sh openbsd:/home/$USER/index.sh
scp stdh.sh openbsd:/home/$USER/stdh.sh
ssh openbsd "bash index.sh --local-system openbsd-libc /usr/"
scp -r openbsd:/home/$USER/output ./output-openbsd
echo "------------------------------------------------------------"
echo "NetBSD : bash index.sh --local-system netbsd-libc /usr/"
scp index.sh netbsd:/home/$USER/index.sh
scp stdh.sh netbsd:/home/$USER/stdh.sh
ssh netbsd "bash index.sh --local-system netbsd-libc /usr/"
scp -r netbsd:/home/$USER/output ./output-netbsd
echo "------------------------------------------------------------"
echo "DragonFlyBSD : bash index.sh --local-system dragonflybsd-libc /usr/"
scp index.sh dragonflybsd:/home/$USER/index.sh
scp stdh.sh dragonflybsd:/home/$USER/stdh.sh
ssh dragonflybsd "bash index.sh --local-system dragonflybsd-libc /usr/"
scp -r dragonflybsd:/home/$USER/output ./output-dragonflybsd
echo "------------------------------------------------------------"
echo "MacOS : ./index-macos.sh"
read -p "Press enter to continue"
echo "------------------------------------------------------------"
echo "Windows : ./index-win.bat"
read -p "Press enter to continue"
echo "------------------------------------------------------------"
echo "Now merge the results : ./merge.sh <output> <input1> <input2>"
./merge.sh output-f output-index output-freebsd
./merge.sh output-ff output-f output-openbsd
./merge.sh output-fff output-ff output-netbsd
./merge.sh output-ffff output-fff output-dragonflybsd
rm -rf output-f output-ff output-fff
mv output-ffff output-f
./merge-bigjson.sh output.json output-f
echo "------------------------------------------------------------"
echo "Everything is done"

54
merge-bigjson.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/sh
# Merge all json output files into one big json file
# Usage: merge-bigjson.sh <output_file> <input_dir>
# Check if jq is installed
if ! [ -x "$(command -v jq)" ]; then
echo "Error: jq is not installed"
return 1 2>/dev/null || exit 1
fi
# Check arguments
if [ $# -lt 2 ]; then
echo "Usage: merge-bigjson.sh <output_file> <input_dir>"
return 1 2>/dev/null || exit 1
fi
# Get output file
output=$1
# Get input directory
input=$2
# Check if input directory exists
if [ ! -d $input ]; then
echo "Input directory $input does not exist"
return 1 2>/dev/null || exit 1
fi
# Merge input directory
for file in $input/*; do
# Get file name
filename=$(basename $file)
# Check if file is a directory
if [ -d $file ]; then
# Recursively merge directories
./merge-bigjson.sh $output $input/$filename
elif [ -f $file ]; then
# Merge files : we need to parse JSON
# Get file content
content=$(cat $file)
# Check if file is empty
if [ -z "$content" ]; then
continue
fi
# Merge all elements in 'content' array to 'output' array
jq -s '.[0] + .[1]' $output $file >$output.tmp 2>/dev/null
mv $output.tmp $output
fi
done

101
merge.sh Executable file
View File

@@ -0,0 +1,101 @@
#!/bin/sh
# Merge multiple indexer output into one output
# Usage: merge.sh <output> <input1> <input2>
# Check if jq is installed
if ! [ -x "$(command -v jq)" ]; then
echo "Error: jq is not installed"
return 1 2>/dev/null || exit 1
fi
# Check arguments
if [ $# -lt 3 ]; then
echo "Usage: merge.sh <output> <input1> <input2>"
return 1 2>/dev/null || exit 1
fi
# Get output directory
output=$1
# Check if output directory exists
if [ -d $output ]; then
echo "Output directory (${output}) already exists"
return 1 2>/dev/null || exit 1
fi
# Create output directory
mkdir -p $output
# Get input directories
input1=$2
input2=$3
# Check if input directories exist
if [ ! -d $input1 ]; then
echo "Input directory $input1 does not exist"
return 1 2>/dev/null || exit 1
fi
if [ ! -d $input2 ]; then
echo "Input directory $input2 does not exist"
return 1 2>/dev/null || exit 1
fi
# Merge input directories
for file in $input1/*; do
# Get file name
filename=$(basename $file)
# Check if file is a directory
if [ -d $file ]; then
if [ ! -d $input2/$filename ]; then
# Output warning
echo "Warning: $filename (dir) does not exist in $input2"
else
# Recursively merge directories
./merge.sh $output/$filename $input1/$filename $input2/$filename
fi
elif [ -f $input2/$filename ]; then
# Merge files : we need to parse JSON and merge objects
# Adding field of the first file to the second file
sample=$(cat $file)
sample2=$(cat $input2/$filename)
out=()
for e in $(echo "${sample}" | jq -r '.[] | @base64'); do
e_field=$(echo $e | base64 --decode)
# Obtain 'name' field
name=$(echo $e_field | jq -r '.name')
# Check if name == "null" : we skip {} fields
if [ "$name" == "null" ]; then
continue
fi
# Find if field exists in second file
k=$(echo "${sample2}" | jq -r ".[] | select(.name == \"${name}\")" 2>/dev/null)
if [ ! -z "${k}" ]; then
# Field exists, we need to merge
# Get field from second file
field=$k #$(echo "${sample2}" | jq -r ".[] | select(.name == \"$name\")")
# Merge fields
field=$(echo $field | jq -c ". + $e_field")
# Add field to output
out+=($field)
else
# Output warning
echo "Warning: $name field ($e_field) does not exist in $input2/$filename"
fi
done
# Write merged file
echo "${out[@]}" | jq -s '.' >$output/$filename
else
# Output warning
echo "Warning: $filename does not exist in $input2"
# Copy file
cp $file $output/$filename
fi
done

274
stdh.bat Normal file
View File

@@ -0,0 +1,274 @@
#!/bin/sh
# Helper script containing a list of standard headers functions
# Std headers
stdatomic=@("atomic_flag_test_and_set", "atomic_flag_test_and_set_explicit", "atomic_flag_clear",
"atomic_flag_clear_explicit" "atomic_init" "atomic_is_lock_free" "atomic_store"
"atomic_store_explicit" "atomic_load" "atomic_load_explicit" "atomic_exchange"
"atomic_exchange_explicit" "atomic_compare_exchange_strong"
"atomic_compare_exchange_strong_explicit" "atomic_compare_exchange_weak"
"atomic_compare_exchange_weak_explicit" "atomic_fetch_add" "atomic_fetch_add_explicit"
"atomic_fetch_sub" "atomic_fetch_sub_explicit" "atomic_fetch_or" "atomic_fetch_or_explicit"
"atomic_fetch_xor" "atomic_fetch_xor_explicit" "atomic_fetch_and" "atomic_fetch_and_explicit"
"atomic_thread_fence" "atomic_signal_fence")
threads=("thrd_create" "thrd_equal" "thrd_current" "thrd_sleep" "thrd_yield" "thrd_detach"
"thrd_exit" "thrd_join" "cnd_init" "cnd_signal" "cnd_broadcast" "cnd_wait"
"cnd_timedwait" "cnd_destroy" "mtx_init" "mtx_lock" "mtx_timedlock" "mtx_trylock"
"mtx_unlock" "mtx_destroy" "tss_create" "tss_delete" "tss_set" "tss_get")
# (POSIX) Headers content
aio=("aio_cancel" "aio_error" "aio_fsync" "aio_read" "aio_return" "aio_suspend"
"aio_write" "lio_listio")
arpa_inet=("inet_addr" "inet_aton" "inet_lnaof" "inet_makeaddr" "inet_netof"
"inet_network" "inet_ntoa" "inet_ntop" "inet_pton")
complex=("cabs" "cabsf" "cabsl" "cacos" "cacosf" "cacosh" "cacoshf" "cacoshl"
"cacosl" "casin" "casinf" "casinh" "casinhf" "casinhl" "casinl" "catan"
"catanf" "catanh" "catanhf" "catanhl" "catanl" "ccos" "ccosf" "ccosh"
"ccoshf" "ccoshl" "ccosl" "cexp" "cexpf" "cexpl" "cimag" "cimagf"
"cimagl" "clog" "clogf" "clogl" "conj" "conjf" "conjl" "cpow" "cpowf"
"cpowl" "cproj" "cprojf" "cprojl" "creal" "crealf" "creall" "csin"
"csinf" "csinh" "csinhf" "csinhl" "csinl" "csqrt" "csqrtf" "csqrtl"
"ctan" "ctanf" "ctanh" "ctanhf" "ctanhl" "ctanl")
ctype=("isalnum" "isalnum_l" "isalpha" "isalpha_l" "isascii" "isblank" "isblank_l"
"iscntrl" "iscntrl_l" "isdigit" "isdigit_l" "isgraph" "isgraph_l"
"islower" "islower_l" "isprint" "isprint_l" "ispunct" "ispunct_l"
"isspace" "isspace_l" "isupper" "isupper_l" "isxdigit" "isxdigit_l"
"tolower" "tolower_l" "toupper" "toupper_l")
dirent=("alphasort" "closedir" "dirfd" "fdopendir" "opendir" "readdir" "readdir_r"
"rewinddir" "scandir" "seekdir" "telldir")
dlfcn=("dladdr" "dlclose" "dlerror" "dlopen" "dlsym")
fcntl=("creat" "fcntl" "open" "openat" "posix_fadvise" "posix_fallocate")
fenv=("feclearexcept" "fegetenv" "fegetexceptflag" "fegetround" "feholdexcept"
"feraiseexcept" "fesetenv" "fesetexceptflag" "fesetround" "fetestexcept"
"feupdateenv")
fmtmsg=("fmtmsg")
fnmatch=("fnmatch")
ftw=("ftw" "nftw")
glob=("glob" "globfree")
grp=("endgrent" "endpwent" "fgetgrent" "fgetgrent_r"
"fgetpwent" "fgetpwent_r" "getgrent" "getgrent_r"
"getgrgid" "getgrgid_r" "getgrnam" "getgrnam_r" "getgroups" "getpwent"
"getpwent_r" "getpwnam" "getpwnam_r" "getpwuid" "getpwuid_r" "putgrent"
"putpwent" "setgrent" "setpwent")
iconv=("iconv" "iconv_close" "iconv_open")
inttypes=("imaxabs" "imaxdiv" "strtoimax" "strtoumax" "wcstoimax" "wcstoumax")
langinfo=("nl_langinfo" "nl_langinfo_l")
libgen=("basename" "dirname")
locale=("catclose" "catgets" "catopen" "duplocale" "freelocale" "localeconv"
"newlocale" "setlocale" "strcoll" "strcoll_l" "strxfrm" "strxfrm_l"
"uselocale")
math=("acos" "acosf" "acosh" "acoshf" "acoshl" "acosl" "asin" "asinf" "asinh"
"asinhf" "asinhl" "asinl" "atan" "atan2" "atan2f" "atan2l" "atanf"
"atanh" "atanhf" "atanhl" "atanl" "cbrt" "cbrtf" "cbrtl" "ceil" "ceilf"
"ceill" "copysign" "copysignf" "copysignl" "cos" "cosf" "cosh" "coshf"
"coshl" "cosl" "erf" "erff" "erfl" "exp" "exp2" "exp2f" "exp2l" "expf"
"expl" "expm1" "expm1f" "expm1l" "fabs" "fabsf" "fabsl" "fdim" "fdimf"
"fdiml" "floor" "floorf" "floorl" "fma" "fmaf" "fmal" "fmax" "fmaxf"
"fmaxl" "fmin" "fminf" "fminl" "fmod" "fmodf" "fmodl" "frexp" "frexpf"
"frexpl" "hypot" "hypotf" "hypotl" "ilogb" "ilogbf" "ilogbl" "j0" "j1" "jn"
"ldexp" "ldexpf" "ldexpl" "lgamma" "lgammaf" "lgammal" "llrint" "llrintf"
"llrintl" "llround" "llroundf" "llroundl" "log" "log10" "log10f" "log10l"
"log1p" "log1pf" "log1pl" "log2" "log2f" "log2l" "logb" "logbf" "logbl"
"logf" "logl" "lrint" "lrintf" "lrintl" "lround" "lroundf" "lroundl"
"modf" "modff" "modfl" "nan" "nanf" "nanl" "nearbyint" "nearbyintf"
"nearbyintl" "nextafter" "nextafterf" "nextafterl" "nexttoward" "nexttowardf"
"nexttowardl" "pow" "powf" "powl" "remainder" "remainderf" "remainderl"
"remquo" "remquof" "remquol" "rint" "rintf" "rintl" "round" "roundf"
"roundl" "scalbln" "scalblnf" "scalblnl" "scalbn" "scalbnf" "scalbnl"
"sin" "sinf" "sinh" "sinhf" "sinhl" "sinl" "sqrt" "sqrtf" "sqrtl" "tan"
"tanf" "tanh" "tanhf" "tanhl" "tanl" "tgamma" "tgammaf" "tgammal" "trunc"
"truncf" "truncl" "y0" "y1" "yn")
monetary=("strfmon" "strfmon_l")
mqueue=("mq_close" "mq_getattr" "mq_notify" "mq_open" "mq_receive" "mq_send"
"mq_setattr" "mq_timedreceive" "mq_timedsend" "mq_unlink")
ndbm=("dbm_clearerr" "dbm_close" "dbm_delete" "dbm_error" "dbm_fetch" "dbm_firstkey"
"dbm_nextkey" "dbm_open" "dbm_store")
net_if=("if_indextoname" "if_nameindex" "if_nametoindex" "if_freenameindex")
netdb=("endhostent" "endnetent" "endprotoent" "endpwent" "endservent" "gethostbyaddr"
"gethostbyname" "gethostent" "getnetbyaddr" "getnetbyname" "getnetent"
"getprotobyname" "getprotobynumber" "getprotoent" "getservbyname"
"getservbyport" "getservent" "gethostbyname2" "gethostbyaddr_r"
"gethostbyname_r" "gethostent_r" "getnetbyaddr_r" "getnetbyname_r"
"getnetent_r" "getprotobyname_r" "getprotobynumber_r" "getprotoent_r"
"getservbyname_r" "getservbyport_r" "getservent_r" "gethostbyname2_r"
"sethostent" "setnetent" "setprotoent" "setpwent" "setservent" "herror"
"hstrerror" "setnetgrent" "endnetgrent"
"innetgr" "getnetgrent" "getnetgrent_r")
nl_types=("catclose" "catgets" "catopen")
poll=("poll" "ppoll")
pthread=("pthread_atfork" "pthread_attr_destroy" "pthread_attr_getdetachstate"
"pthread_attr_getguardsize" "pthread_attr_getinheritsched"
"pthread_attr_getschedparam" "pthread_attr_getschedpolicy"
"pthread_attr_getscope" "pthread_attr_getstack" "pthread_attr_getstackaddr"
"pthread_attr_getstacksize" "pthread_attr_init" "pthread_attr_setdetachstate"
"pthread_attr_setguardsize" "pthread_attr_setinheritsched"
"pthread_attr_setschedparam" "pthread_attr_setschedpolicy"
"pthread_attr_setscope" "pthread_attr_setstack" "pthread_attr_setstackaddr"
"pthread_attr_setstacksize" "pthread_cancel" "pthread_cleanup_pop"
"pthread_cleanup_push" "pthread_cond_broadcast" "pthread_cond_destroy"
"pthread_cond_init" "pthread_cond_signal" "pthread_cond_timedwait"
"pthread_cond_wait" "pthread_condattr_destroy" "pthread_condattr_getclock"
"pthread_condattr_getpshared" "pthread_condattr_init"
"pthread_condattr_setclock" "pthread_condattr_setpshared"
"pthread_create" "pthread_detach" "pthread_equal" "pthread_exit"
"pthread_getconcurrency" "pthread_getcpuclockid" "pthread_getschedparam"
"pthread_getspecific" "pthread_join" "pthread_key_create" "pthread_key_delete"
"pthread_mutex_consistent" "pthread_mutex_destroy" "pthread_mutex_getprioceiling"
"pthread_mutex_init" "pthread_mutex_lock" "pthread_mutex_setprioceiling"
"pthread_mutex_timedlock" "pthread_mutex_trylock" "pthread_mutex_unlock"
"pthread_mutexattr_destroy" "pthread_mutexattr_getprioceiling"
"pthread_mutexattr_getprotocol" "pthread_mutexattr_getpshared"
"pthread_mutexattr_getrobust" "pthread_mutexattr_gettype"
"pthread_mutexattr_init" "pthread_mutexattr_setprioceiling"
"pthread_mutexattr_setprotocol" "pthread_mutexattr_setpshared"
"pthread_mutexattr_setrobust" "pthread_mutexattr_settype" "pthread_once"
"pthread_rwlock_destroy" "pthread_rwlock_init" "pthread_rwlock_rdlock"
"pthread_rwlock_timedrdlock" "pthread_rwlock_timedwrlock"
"pthread_rwlock_tryrdlock" "pthread_rwlock_trywrlock" "pthread_rwlock_unlock"
"pthread_rwlock_wrlock" "pthread_rwlockattr_destroy"
"pthread_rwlockattr_getpshared" "pthread_rwlockattr_init"
"pthread_rwlockattr_setpshared" "pthread_self" "pthread_setcancelstate"
"pthread_setcanceltype" "pthread_setconcurrency" "pthread_setschedparam"
"pthread_setschedprio" "pthread_setspecific" "pthread_spin_destroy"
"pthread_spin_init" "pthread_spin_lock" "pthread_spin_trylock"
"pthread_spin_unlock" "pthread_testcancel" "pthread_cleanup_pop"
"pthread_cleanup_push")
pwd=("endpwent" "getpwent" "getpwnam" "getpwnam_r" "getpwuid" "getpwuid_r"
"setpwent")
regex=("regcomp" "regerror" "regexec" "regfree")
sched=("sched_get_priority_max" "sched_get_priority_min" "sched_getparam"
"sched_getscheduler" "sched_rr_get_interval" "sched_setparam"
"sched_setscheduler" "sched_yield")
search=("hcreate" "hdestroy" "hsearch" "insque" "lfind" "lsearch" "remque"
"tdelete" "tfind" "tsearch" "twalk")
semaphore=("sem_close" "sem_destroy" "sem_getvalue" "sem_init" "sem_open"
"sem_post" "sem_timedwait" "sem_trywait" "sem_unlink" "sem_wait")
setjmp=("_longjmp" "longjmp" "siglongjmp")
signal=("kill" "killpg" "psiginfo" "psignal" "pthread_kill" "pthread_sigmask"
"raise" "sigaction" "sigaddset" "sigaltstack" "sigandset" "sigdelset"
"sigemptyset" "sigfillset" "sighold" "sigignore" "siginterrupt" "sigismember"
"signal" "sigpause" "sigorset" "sigpending"
"sigprocmask" "sigqueue" "sigrelse" "sigset" "sigsuspend" "sigwait" "sigwaitinfo"
"sigtimedwait")
spawn=("posix_spawn" "posix_spawnp" "posix_spawn_file_actions_addclose"
"posix_spawn_file_actions_adddup2" "posix_spawn_file_actions_addopen"
"posix_spawn_file_actions_destroy" "posix_spawn_file_actions_init"
"posix_spawnattr_destroy" "posix_spawnattr_getflags"
"posix_spawnattr_getpgroup" "posix_spawnattr_getschedparam"
"posix_spawnattr_getschedpolicy" "posix_spawnattr_getsigdefault"
"posix_spawnattr_getsigmask" "posix_spawnattr_init"
"posix_spawnattr_setflags" "posix_spawnattr_setpgroup"
"posix_spawnattr_setschedparam" "posix_spawnattr_setschedpolicy"
"posix_spawnattr_setsigdefault" "posix_spawnattr_setsigmask")
stdio=("clearerr" "ctermid" "dprintf" "fclose" "fdopen" "feof" "ferror"
"fflush" "fgetc" "fgetpos" "fgets" "fileno" "flockfile" "fopen"
"fprintf" "fputc" "fputs" "fread" "freopen" "fscanf" "fseek"
"fseeko" "fsetpos" "ftell" "ftello" "ftrylockfile" "funlockfile"
"fwrite" "getc" "getchar" "getc_unlocked" "getchar_unlocked"
"getdelim" "getline" "gets" "open_memstream" "pclose" "perror"
"popen" "printf" "putc" "putchar" "putc_unlocked"
"putchar_unlocked" "puts" "remove" "rename" "renameat" "rewind"
"scanf" "setbuf" "setvbuf" "snprintf" "sprintf" "sscanf" "tempnam"
"tmpfile" "tmpnam" "ungetc" "vdprintf" "vfprintf" "vfscanf"
"vprintf" "vscanf" "vsnprintf" "vsprintf" "vsscanf")
stdlib=("_Exit" "a64l" "abort" "abs" "atexit" "atof" "atoi" "atol" "bsearch"
"calloc" "div" "drand48" "erand48" "exit" "free" "getenv" "getsubopt"
"grantpt" "initstate" "jrand48" "l64a" "labs" "lcong48" "ldiv"
"llabs" "lldiv" "lrand48" "malloc" "mblen" "mbstowcs" "mbtowc"
"mkdtemp" "mkstemp" "mrand48" "nrand48" "posix_memalign" "posix_openpt"
"ptsname" "putenv" "qsort" "rand" "rand_r" "random" "realloc" "realpath"
"seed48" "setenv" "setkey" "setstate" "srand" "srand48" "srandom"
"strtod" "strtof" "strtol" "strtold" "strtoll" "strtoul" "strtoull"
"system" "unlockpt" "unsetenv" "wcstombs" "wctomb")
string=("memccpy" "memchr" "memcmp" "memcpy" "memmem" "memmove" "memset"
"rawmemchr" "stpcpy" "stpncpy" "strcasecmp" "strcasestr" "strcat"
"strchr" "strchrnul" "strcmp" "strcoll" "strcpy" "strcspn" "strdup"
"strerror" "strerror_r" "strfmon" "strftime" "strlen" "strncasecmp"
"strncat" "strncmp" "strncpy" "strndup" "strnlen" "strpbrk" "strptime"
"strrchr" "strsep" "strsignal" "strspn" "strstr" "strtok" "strtok_r"
"strxfrm" "swab" "strdupa" "strndupa" "strsignal_r" "strtok_r" "strverscmp"
"strxfrm_l" "strcoll_l" "strfmon_l" "strptime_l" "strerror_l" "strerror_r")
strings=("ffs" "strcasecmp" "strcasecmp_l" "strncasecmp" "strncasecmp_l")
stropts=("fattach" "fdetach" "getmsg" "getpmsg" "ioctl" "isastream" "putmsg"
"putpmsg")
sys_ipc=("ftok")
sys_mman=("mmap" "mmap64" "mremap" "msync" "munmap" "mlock" "mlockall"
"mprotect" "munlock" "munlockall" "madvise" "posix_madvise"
"shm_open" "shm_unlink" "posix_mem_offset" "posix_typed_mem_open"
"posix_typed_mem_get_info")
sys_msg=("msgctl" "msgget" "msgrcv" "msgsnd")
sys_resource=("getrlimit" "getrusage" "setrlimit" "getpriority" "setpriority")
sys_select=("pselect" "select")
sys_sem=("semctl" "semget" "semop")
sys_shm=("shmat" "shmctl" "shmdt" "shmget")
sys_socket=("accept" "accept4" "bind" "connect" "getpeername" "getsockname"
"getsockopt" "listen" "recv" "recvfrom" "recvmsg" "send" "sendmsg"
"sendto" "setsockopt" "shutdown" "socketatmark" "socket" "socketpair")
sys_stat=("chmod" "fchmod" "fchmodat" "fstat" "fstatat" "futimens" "lstat"
"mkdir" "mkdirat" "mkfifo" "mkfifoat" "mknod" "mknodat" "stat"
"umask" "utimensat")
sys_statvfs=("fstatvfs" "statvfs")
sys_time=("getitimer" "gettimeofday" "setitimer" "settimeofday" "adjtime"
"clock_adjtime" "timerfd_settime" "utimes" "select")
sys_times=("times")
sys_uio=("readv" "writev")
sys_utsname=("uname")
sys_wait=("wait" "wait3" "wait4" "waitid" "waitpid")
syslog=("openlog" "syslog" "closelog" "setlogmask")
termios=("cfgetispeed" "cfgetospeed" "cfsetispeed" "cfsetospeed" "tcdrain"
"tcflow" "tcflush" "tcgetattr" "tcgetpgrp" "tcsendbreak" "tcsetattr"
"tcsetpgrp")
time=("asctime" "asctime_r" "clock" "clock_getcpuclockid" "clock_getres"
"clock_gettime" "clock_nanosleep" "clock_settime" "ctime" "ctime_r"
"difftime" "getdate" "gmtime" "gmtime_r" "localtime" "localtime_r"
"mktime" "nanosleep" "strftime" "strptime" "time" "timegm" "timelocal"
"tzset" "timer_create" "timer_delete" "timer_getoverrun"
"timer_gettime" "timer_settime" "strftime_l")
trace=("posix_trace_attr_destroy" "posix_trace_attr_getclockres" "posix_trace_attr_getcreatetime"
"posix_trace_attr_getgenversion" "posix_trace_attr_getinherited"
"posix_trace_attr_getlogfullpolicy" "posix_trace_attr_getlogsize"
"posix_trace_attr_getmaxdatasize" "posix_trace_attr_getmaxsystemeventsize"
"posix_trace_attr_getmaxusereventsize" "posix_trace_attr_getname"
"posix_trace_attr_getstreamfullpolicy" "posix_trace_attr_getstreamsize"
"posix_trace_attr_getversion" "posix_trace_attr_init" "posix_trace_attr_setinherited"
"posix_trace_attr_setlogfullpolicy" "posix_trace_attr_setlogsize"
"posix_trace_attr_setmaxdatasize" "posix_trace_attr_setmaxsystemeventsize"
"posix_trace_attr_setmaxusereventsize" "posix_trace_attr_setname"
"posix_trace_attr_setstreamfullpolicy" "posix_trace_attr_setstreamsize"
"posix_trace_clear" "posix_trace_close" "posix_trace_create" "posix_trace_create_withlog"
"posix_trace_eventid_equal" "posix_trace_eventid_get_name" "posix_trace_eventid_open"
"posix_trace_eventset_add" "posix_trace_eventset_del" "posix_trace_eventset_empty"
"posix_trace_eventset_fill" "posix_trace_eventset_ismember" "posix_trace_eventtypelist_getnext_id"
"posix_trace_flush" "posix_trace_get_attr" "posix_trace_get_filter"
"posix_trace_get_status" "posix_trace_getnext_event" "posix_trace_open"
"posix_trace_rewind" "posix_trace_set_filter" "posix_trace_shutdown"
"posix_trace_start" "posix_trace_stop")
ulimit=("ulimit")
unistd=("access" "alarm" "chdir" "chown" "chroot" "close" "confstr" "crypt"
"ctermid" "ctermid_r" "dup" "dup2" "dup3" "_exit" "encrypt" "execl" "execle"
"execlp" "execv" "execve" "execvp" "fchdir" "fchown" "fdatasync" "fork"
"fpathconf" "fsync" "ftruncate" "getcwd" "getegid" "geteuid" "getgid"
"getgroups" "getlogin" "getlogin_r" "getpgid" "getpgrp" "getpid" "getppid"
"getresgid" "getresuid" "getsid" "getuid" "getwd" "isatty" "lchown" "link"
"linkat" "lockf" "nice" "pathconf" "pause" "pipe" "pipe2" "read" "readlink"
"readlinkat" "rmdir" "setegid" "seteuid" "setgid" "setpgid" "setpgrp"
"setregid" "setreuid" "setsid" "setuid" "sleep" "symlink" "symlinkat"
"sync" "tcgetpgrp" "tcsetpgrp" "ttyname" "ttyname_r" "unlink" "unlinkat"
"usleep" "vfork" "write" "getopt")
utime=("utime")
utmpx=("getutxent" "getutxid" "getutxline" "pututxline" "setutxent" "endutxent")
wchar=("btowc" "fgetwc" "fgetws" "fputwc" "fputws" "fwide" "fwprintf" "fwscanf"
"getwc" "getwchar" "mbrlen" "mbrtowc" "mbsinit" "mbsrtowcs" "putwc"
"putwchar" "swprintf" "swscanf" "ungetwc" "vfwprintf" "vfwscanf" "vswprintf"
"vswscanf" "vwprintf" "vwscanf" "wcrtomb" "wcscat" "wcschr" "wcscmp"
"wcscoll" "wcscpy" "wcscspn" "wcsftime" "wcslen" "wcsncat" "wcsncmp"
"wcsncpy" "wcspbrk" "wcsrchr" "wcsrtombs" "wcsspn" "wcsstr" "wcstod"
"wcstof" "wcstok" "wcstol" "wcstold" "wcstoll" "wcstoul" "wcstoull"
"wcswidth" "wcsxfrm" "wctob" "wctomb" "wctrans" "wctype" "wcwidth" "wprintf"
"wscanf")
wctype=("iswalnum" "iswalpha" "iswblank" "iswcntrl" "iswctype" "iswdigit" "iswgraph"
"iswlower" "iswprint" "iswpunct" "iswspace" "iswupper" "iswxdigit" "towlower"
"towupper" "wctrans" "wctype"
"iswalnum_l" "iswalpha_l" "iswblank_l" "iswcntrl_l" "iswctype_l" "iswdigit_l"
"iswgraph_l" "iswlower_l" "iswprint_l" "iswpunct_l" "iswspace_l" "iswupper_l"
"iswxdigit_l" "towlower_l" "towupper_l" "wctrans_l" "wctype_l")
wordexp=("wordexp" "wordfree")

274
stdh.sh Executable file
View File

@@ -0,0 +1,274 @@
#!/bin/sh
# Helper script containing a list of standard headers functions
# Std headers
stdatomic=("atomic_flag_test_and_set" "atomic_flag_test_and_set_explicit" "atomic_flag_clear"
"atomic_flag_clear_explicit" "atomic_init" "atomic_is_lock_free" "atomic_store"
"atomic_store_explicit" "atomic_load" "atomic_load_explicit" "atomic_exchange"
"atomic_exchange_explicit" "atomic_compare_exchange_strong"
"atomic_compare_exchange_strong_explicit" "atomic_compare_exchange_weak"
"atomic_compare_exchange_weak_explicit" "atomic_fetch_add" "atomic_fetch_add_explicit"
"atomic_fetch_sub" "atomic_fetch_sub_explicit" "atomic_fetch_or" "atomic_fetch_or_explicit"
"atomic_fetch_xor" "atomic_fetch_xor_explicit" "atomic_fetch_and" "atomic_fetch_and_explicit"
"atomic_thread_fence" "atomic_signal_fence")
threads=("thrd_create" "thrd_equal" "thrd_current" "thrd_sleep" "thrd_yield" "thrd_detach"
"thrd_exit" "thrd_join" "cnd_init" "cnd_signal" "cnd_broadcast" "cnd_wait"
"cnd_timedwait" "cnd_destroy" "mtx_init" "mtx_lock" "mtx_timedlock" "mtx_trylock"
"mtx_unlock" "mtx_destroy" "tss_create" "tss_delete" "tss_set" "tss_get")
# (POSIX) Headers content
aio=("aio_cancel" "aio_error" "aio_fsync" "aio_read" "aio_return" "aio_suspend"
"aio_write" "lio_listio")
arpa_inet=("inet_addr" "inet_aton" "inet_lnaof" "inet_makeaddr" "inet_netof"
"inet_network" "inet_ntoa" "inet_ntop" "inet_pton")
complex=("cabs" "cabsf" "cabsl" "cacos" "cacosf" "cacosh" "cacoshf" "cacoshl"
"cacosl" "casin" "casinf" "casinh" "casinhf" "casinhl" "casinl" "catan"
"catanf" "catanh" "catanhf" "catanhl" "catanl" "ccos" "ccosf" "ccosh"
"ccoshf" "ccoshl" "ccosl" "cexp" "cexpf" "cexpl" "cimag" "cimagf"
"cimagl" "clog" "clogf" "clogl" "conj" "conjf" "conjl" "cpow" "cpowf"
"cpowl" "cproj" "cprojf" "cprojl" "creal" "crealf" "creall" "csin"
"csinf" "csinh" "csinhf" "csinhl" "csinl" "csqrt" "csqrtf" "csqrtl"
"ctan" "ctanf" "ctanh" "ctanhf" "ctanhl" "ctanl")
ctype=("isalnum" "isalnum_l" "isalpha" "isalpha_l" "isascii" "isblank" "isblank_l"
"iscntrl" "iscntrl_l" "isdigit" "isdigit_l" "isgraph" "isgraph_l"
"islower" "islower_l" "isprint" "isprint_l" "ispunct" "ispunct_l"
"isspace" "isspace_l" "isupper" "isupper_l" "isxdigit" "isxdigit_l"
"tolower" "tolower_l" "toupper" "toupper_l")
dirent=("alphasort" "closedir" "dirfd" "fdopendir" "opendir" "readdir" "readdir_r"
"rewinddir" "scandir" "seekdir" "telldir")
dlfcn=("dladdr" "dlclose" "dlerror" "dlopen" "dlsym")
fcntl=("creat" "fcntl" "open" "openat" "posix_fadvise" "posix_fallocate")
fenv=("feclearexcept" "fegetenv" "fegetexceptflag" "fegetround" "feholdexcept"
"feraiseexcept" "fesetenv" "fesetexceptflag" "fesetround" "fetestexcept"
"feupdateenv")
fmtmsg=("fmtmsg")
fnmatch=("fnmatch")
ftw=("ftw" "nftw")
glob=("glob" "globfree")
grp=("endgrent" "endpwent" "fgetgrent" "fgetgrent_r"
"fgetpwent" "fgetpwent_r" "getgrent" "getgrent_r"
"getgrgid" "getgrgid_r" "getgrnam" "getgrnam_r" "getgroups" "getpwent"
"getpwent_r" "getpwnam" "getpwnam_r" "getpwuid" "getpwuid_r" "putgrent"
"putpwent" "setgrent" "setpwent")
iconv=("iconv" "iconv_close" "iconv_open")
inttypes=("imaxabs" "imaxdiv" "strtoimax" "strtoumax" "wcstoimax" "wcstoumax")
langinfo=("nl_langinfo" "nl_langinfo_l")
libgen=("basename" "dirname")
locale=("catclose" "catgets" "catopen" "duplocale" "freelocale" "localeconv"
"newlocale" "setlocale" "strcoll" "strcoll_l" "strxfrm" "strxfrm_l"
"uselocale")
math=("acos" "acosf" "acosh" "acoshf" "acoshl" "acosl" "asin" "asinf" "asinh"
"asinhf" "asinhl" "asinl" "atan" "atan2" "atan2f" "atan2l" "atanf"
"atanh" "atanhf" "atanhl" "atanl" "cbrt" "cbrtf" "cbrtl" "ceil" "ceilf"
"ceill" "copysign" "copysignf" "copysignl" "cos" "cosf" "cosh" "coshf"
"coshl" "cosl" "erf" "erff" "erfl" "exp" "exp2" "exp2f" "exp2l" "expf"
"expl" "expm1" "expm1f" "expm1l" "fabs" "fabsf" "fabsl" "fdim" "fdimf"
"fdiml" "floor" "floorf" "floorl" "fma" "fmaf" "fmal" "fmax" "fmaxf"
"fmaxl" "fmin" "fminf" "fminl" "fmod" "fmodf" "fmodl" "frexp" "frexpf"
"frexpl" "hypot" "hypotf" "hypotl" "ilogb" "ilogbf" "ilogbl" "j0" "j1" "jn"
"ldexp" "ldexpf" "ldexpl" "lgamma" "lgammaf" "lgammal" "llrint" "llrintf"
"llrintl" "llround" "llroundf" "llroundl" "log" "log10" "log10f" "log10l"
"log1p" "log1pf" "log1pl" "log2" "log2f" "log2l" "logb" "logbf" "logbl"
"logf" "logl" "lrint" "lrintf" "lrintl" "lround" "lroundf" "lroundl"
"modf" "modff" "modfl" "nan" "nanf" "nanl" "nearbyint" "nearbyintf"
"nearbyintl" "nextafter" "nextafterf" "nextafterl" "nexttoward" "nexttowardf"
"nexttowardl" "pow" "powf" "powl" "remainder" "remainderf" "remainderl"
"remquo" "remquof" "remquol" "rint" "rintf" "rintl" "round" "roundf"
"roundl" "scalbln" "scalblnf" "scalblnl" "scalbn" "scalbnf" "scalbnl"
"sin" "sinf" "sinh" "sinhf" "sinhl" "sinl" "sqrt" "sqrtf" "sqrtl" "tan"
"tanf" "tanh" "tanhf" "tanhl" "tanl" "tgamma" "tgammaf" "tgammal" "trunc"
"truncf" "truncl" "y0" "y1" "yn")
monetary=("strfmon" "strfmon_l")
mqueue=("mq_close" "mq_getattr" "mq_notify" "mq_open" "mq_receive" "mq_send"
"mq_setattr" "mq_timedreceive" "mq_timedsend" "mq_unlink")
ndbm=("dbm_clearerr" "dbm_close" "dbm_delete" "dbm_error" "dbm_fetch" "dbm_firstkey"
"dbm_nextkey" "dbm_open" "dbm_store")
net_if=("if_indextoname" "if_nameindex" "if_nametoindex" "if_freenameindex")
netdb=("endhostent" "endnetent" "endprotoent" "endpwent" "endservent" "gethostbyaddr"
"gethostbyname" "gethostent" "getnetbyaddr" "getnetbyname" "getnetent"
"getprotobyname" "getprotobynumber" "getprotoent" "getservbyname"
"getservbyport" "getservent" "gethostbyname2" "gethostbyaddr_r"
"gethostbyname_r" "gethostent_r" "getnetbyaddr_r" "getnetbyname_r"
"getnetent_r" "getprotobyname_r" "getprotobynumber_r" "getprotoent_r"
"getservbyname_r" "getservbyport_r" "getservent_r" "gethostbyname2_r"
"sethostent" "setnetent" "setprotoent" "setpwent" "setservent" "herror"
"hstrerror" "setnetgrent" "endnetgrent"
"innetgr" "getnetgrent" "getnetgrent_r")
nl_types=("catclose" "catgets" "catopen")
poll=("poll" "ppoll")
pthread=("pthread_atfork" "pthread_attr_destroy" "pthread_attr_getdetachstate"
"pthread_attr_getguardsize" "pthread_attr_getinheritsched"
"pthread_attr_getschedparam" "pthread_attr_getschedpolicy"
"pthread_attr_getscope" "pthread_attr_getstack" "pthread_attr_getstackaddr"
"pthread_attr_getstacksize" "pthread_attr_init" "pthread_attr_setdetachstate"
"pthread_attr_setguardsize" "pthread_attr_setinheritsched"
"pthread_attr_setschedparam" "pthread_attr_setschedpolicy"
"pthread_attr_setscope" "pthread_attr_setstack" "pthread_attr_setstackaddr"
"pthread_attr_setstacksize" "pthread_cancel" "pthread_cleanup_pop"
"pthread_cleanup_push" "pthread_cond_broadcast" "pthread_cond_destroy"
"pthread_cond_init" "pthread_cond_signal" "pthread_cond_timedwait"
"pthread_cond_wait" "pthread_condattr_destroy" "pthread_condattr_getclock"
"pthread_condattr_getpshared" "pthread_condattr_init"
"pthread_condattr_setclock" "pthread_condattr_setpshared"
"pthread_create" "pthread_detach" "pthread_equal" "pthread_exit"
"pthread_getconcurrency" "pthread_getcpuclockid" "pthread_getschedparam"
"pthread_getspecific" "pthread_join" "pthread_key_create" "pthread_key_delete"
"pthread_mutex_consistent" "pthread_mutex_destroy" "pthread_mutex_getprioceiling"
"pthread_mutex_init" "pthread_mutex_lock" "pthread_mutex_setprioceiling"
"pthread_mutex_timedlock" "pthread_mutex_trylock" "pthread_mutex_unlock"
"pthread_mutexattr_destroy" "pthread_mutexattr_getprioceiling"
"pthread_mutexattr_getprotocol" "pthread_mutexattr_getpshared"
"pthread_mutexattr_getrobust" "pthread_mutexattr_gettype"
"pthread_mutexattr_init" "pthread_mutexattr_setprioceiling"
"pthread_mutexattr_setprotocol" "pthread_mutexattr_setpshared"
"pthread_mutexattr_setrobust" "pthread_mutexattr_settype" "pthread_once"
"pthread_rwlock_destroy" "pthread_rwlock_init" "pthread_rwlock_rdlock"
"pthread_rwlock_timedrdlock" "pthread_rwlock_timedwrlock"
"pthread_rwlock_tryrdlock" "pthread_rwlock_trywrlock" "pthread_rwlock_unlock"
"pthread_rwlock_wrlock" "pthread_rwlockattr_destroy"
"pthread_rwlockattr_getpshared" "pthread_rwlockattr_init"
"pthread_rwlockattr_setpshared" "pthread_self" "pthread_setcancelstate"
"pthread_setcanceltype" "pthread_setconcurrency" "pthread_setschedparam"
"pthread_setschedprio" "pthread_setspecific" "pthread_spin_destroy"
"pthread_spin_init" "pthread_spin_lock" "pthread_spin_trylock"
"pthread_spin_unlock" "pthread_testcancel" "pthread_cleanup_pop"
"pthread_cleanup_push")
pwd=("endpwent" "getpwent" "getpwnam" "getpwnam_r" "getpwuid" "getpwuid_r"
"setpwent")
regex=("regcomp" "regerror" "regexec" "regfree")
sched=("sched_get_priority_max" "sched_get_priority_min" "sched_getparam"
"sched_getscheduler" "sched_rr_get_interval" "sched_setparam"
"sched_setscheduler" "sched_yield")
search=("hcreate" "hdestroy" "hsearch" "insque" "lfind" "lsearch" "remque"
"tdelete" "tfind" "tsearch" "twalk")
semaphore=("sem_close" "sem_destroy" "sem_getvalue" "sem_init" "sem_open"
"sem_post" "sem_timedwait" "sem_trywait" "sem_unlink" "sem_wait")
setjmp=("_longjmp" "longjmp" "siglongjmp")
signal=("kill" "killpg" "psiginfo" "psignal" "pthread_kill" "pthread_sigmask"
"raise" "sigaction" "sigaddset" "sigaltstack" "sigandset" "sigdelset"
"sigemptyset" "sigfillset" "sighold" "sigignore" "siginterrupt" "sigismember"
"signal" "sigpause" "sigorset" "sigpending"
"sigprocmask" "sigqueue" "sigrelse" "sigset" "sigsuspend" "sigwait" "sigwaitinfo"
"sigtimedwait")
spawn=("posix_spawn" "posix_spawnp" "posix_spawn_file_actions_addclose"
"posix_spawn_file_actions_adddup2" "posix_spawn_file_actions_addopen"
"posix_spawn_file_actions_destroy" "posix_spawn_file_actions_init"
"posix_spawnattr_destroy" "posix_spawnattr_getflags"
"posix_spawnattr_getpgroup" "posix_spawnattr_getschedparam"
"posix_spawnattr_getschedpolicy" "posix_spawnattr_getsigdefault"
"posix_spawnattr_getsigmask" "posix_spawnattr_init"
"posix_spawnattr_setflags" "posix_spawnattr_setpgroup"
"posix_spawnattr_setschedparam" "posix_spawnattr_setschedpolicy"
"posix_spawnattr_setsigdefault" "posix_spawnattr_setsigmask")
stdio=("clearerr" "ctermid" "dprintf" "fclose" "fdopen" "feof" "ferror"
"fflush" "fgetc" "fgetpos" "fgets" "fileno" "flockfile" "fopen"
"fprintf" "fputc" "fputs" "fread" "freopen" "fscanf" "fseek"
"fseeko" "fsetpos" "ftell" "ftello" "ftrylockfile" "funlockfile"
"fwrite" "getc" "getchar" "getc_unlocked" "getchar_unlocked"
"getdelim" "getline" "gets" "open_memstream" "pclose" "perror"
"popen" "printf" "putc" "putchar" "putc_unlocked"
"putchar_unlocked" "puts" "remove" "rename" "renameat" "rewind"
"scanf" "setbuf" "setvbuf" "snprintf" "sprintf" "sscanf" "tempnam"
"tmpfile" "tmpnam" "ungetc" "vdprintf" "vfprintf" "vfscanf"
"vprintf" "vscanf" "vsnprintf" "vsprintf" "vsscanf")
stdlib=("_Exit" "a64l" "abort" "abs" "atexit" "atof" "atoi" "atol" "bsearch"
"calloc" "div" "drand48" "erand48" "exit" "free" "getenv" "getsubopt"
"grantpt" "initstate" "jrand48" "l64a" "labs" "lcong48" "ldiv"
"llabs" "lldiv" "lrand48" "malloc" "mblen" "mbstowcs" "mbtowc"
"mkdtemp" "mkstemp" "mrand48" "nrand48" "posix_memalign" "posix_openpt"
"ptsname" "putenv" "qsort" "rand" "rand_r" "random" "realloc" "realpath"
"seed48" "setenv" "setkey" "setstate" "srand" "srand48" "srandom"
"strtod" "strtof" "strtol" "strtold" "strtoll" "strtoul" "strtoull"
"system" "unlockpt" "unsetenv" "wcstombs" "wctomb")
string=("memccpy" "memchr" "memcmp" "memcpy" "memmem" "memmove" "memset"
"rawmemchr" "stpcpy" "stpncpy" "strcasecmp" "strcasestr" "strcat"
"strchr" "strchrnul" "strcmp" "strcoll" "strcpy" "strcspn" "strdup"
"strerror" "strerror_r" "strfmon" "strftime" "strlen" "strncasecmp"
"strncat" "strncmp" "strncpy" "strndup" "strnlen" "strpbrk" "strptime"
"strrchr" "strsep" "strsignal" "strspn" "strstr" "strtok" "strtok_r"
"strxfrm" "swab" "strdupa" "strndupa" "strsignal_r" "strtok_r" "strverscmp"
"strxfrm_l" "strcoll_l" "strfmon_l" "strptime_l" "strerror_l" "strerror_r")
strings=("ffs" "strcasecmp" "strcasecmp_l" "strncasecmp" "strncasecmp_l")
stropts=("fattach" "fdetach" "getmsg" "getpmsg" "ioctl" "isastream" "putmsg"
"putpmsg")
sys_ipc=("ftok")
sys_mman=("mmap" "mmap64" "mremap" "msync" "munmap" "mlock" "mlockall"
"mprotect" "munlock" "munlockall" "madvise" "posix_madvise"
"shm_open" "shm_unlink" "posix_mem_offset" "posix_typed_mem_open"
"posix_typed_mem_get_info")
sys_msg=("msgctl" "msgget" "msgrcv" "msgsnd")
sys_resource=("getrlimit" "getrusage" "setrlimit" "getpriority" "setpriority")
sys_select=("pselect" "select")
sys_sem=("semctl" "semget" "semop")
sys_shm=("shmat" "shmctl" "shmdt" "shmget")
sys_socket=("accept" "accept4" "bind" "connect" "getpeername" "getsockname"
"getsockopt" "listen" "recv" "recvfrom" "recvmsg" "send" "sendmsg"
"sendto" "setsockopt" "shutdown" "socketatmark" "socket" "socketpair")
sys_stat=("chmod" "fchmod" "fchmodat" "fstat" "fstatat" "futimens" "lstat"
"mkdir" "mkdirat" "mkfifo" "mkfifoat" "mknod" "mknodat" "stat"
"umask" "utimensat")
sys_statvfs=("fstatvfs" "statvfs")
sys_time=("getitimer" "gettimeofday" "setitimer" "settimeofday" "adjtime"
"clock_adjtime" "timerfd_settime" "utimes" "select")
sys_times=("times")
sys_uio=("readv" "writev")
sys_utsname=("uname")
sys_wait=("wait" "wait3" "wait4" "waitid" "waitpid")
syslog=("openlog" "syslog" "closelog" "setlogmask")
termios=("cfgetispeed" "cfgetospeed" "cfsetispeed" "cfsetospeed" "tcdrain"
"tcflow" "tcflush" "tcgetattr" "tcgetpgrp" "tcsendbreak" "tcsetattr"
"tcsetpgrp")
time=("asctime" "asctime_r" "clock" "clock_getcpuclockid" "clock_getres"
"clock_gettime" "clock_nanosleep" "clock_settime" "ctime" "ctime_r"
"difftime" "getdate" "gmtime" "gmtime_r" "localtime" "localtime_r"
"mktime" "nanosleep" "strftime" "strptime" "time" "timegm" "timelocal"
"tzset" "timer_create" "timer_delete" "timer_getoverrun"
"timer_gettime" "timer_settime" "strftime_l")
trace=("posix_trace_attr_destroy" "posix_trace_attr_getclockres" "posix_trace_attr_getcreatetime"
"posix_trace_attr_getgenversion" "posix_trace_attr_getinherited"
"posix_trace_attr_getlogfullpolicy" "posix_trace_attr_getlogsize"
"posix_trace_attr_getmaxdatasize" "posix_trace_attr_getmaxsystemeventsize"
"posix_trace_attr_getmaxusereventsize" "posix_trace_attr_getname"
"posix_trace_attr_getstreamfullpolicy" "posix_trace_attr_getstreamsize"
"posix_trace_attr_getversion" "posix_trace_attr_init" "posix_trace_attr_setinherited"
"posix_trace_attr_setlogfullpolicy" "posix_trace_attr_setlogsize"
"posix_trace_attr_setmaxdatasize" "posix_trace_attr_setmaxsystemeventsize"
"posix_trace_attr_setmaxusereventsize" "posix_trace_attr_setname"
"posix_trace_attr_setstreamfullpolicy" "posix_trace_attr_setstreamsize"
"posix_trace_clear" "posix_trace_close" "posix_trace_create" "posix_trace_create_withlog"
"posix_trace_eventid_equal" "posix_trace_eventid_get_name" "posix_trace_eventid_open"
"posix_trace_eventset_add" "posix_trace_eventset_del" "posix_trace_eventset_empty"
"posix_trace_eventset_fill" "posix_trace_eventset_ismember" "posix_trace_eventtypelist_getnext_id"
"posix_trace_flush" "posix_trace_get_attr" "posix_trace_get_filter"
"posix_trace_get_status" "posix_trace_getnext_event" "posix_trace_open"
"posix_trace_rewind" "posix_trace_set_filter" "posix_trace_shutdown"
"posix_trace_start" "posix_trace_stop")
ulimit=("ulimit")
unistd=("access" "alarm" "chdir" "chown" "chroot" "close" "confstr" "crypt"
"ctermid" "ctermid_r" "dup" "dup2" "dup3" "_exit" "encrypt" "execl" "execle"
"execlp" "execv" "execve" "execvp" "fchdir" "fchown" "fdatasync" "fork"
"fpathconf" "fsync" "ftruncate" "getcwd" "getegid" "geteuid" "getgid"
"getgroups" "getlogin" "getlogin_r" "getpgid" "getpgrp" "getpid" "getppid"
"getresgid" "getresuid" "getsid" "getuid" "getwd" "isatty" "lchown" "link"
"linkat" "lockf" "nice" "pathconf" "pause" "pipe" "pipe2" "read" "readlink"
"readlinkat" "rmdir" "setegid" "seteuid" "setgid" "setpgid" "setpgrp"
"setregid" "setreuid" "setsid" "setuid" "sleep" "symlink" "symlinkat"
"sync" "tcgetpgrp" "tcsetpgrp" "ttyname" "ttyname_r" "unlink" "unlinkat"
"usleep" "vfork" "write" "getopt")
utime=("utime")
utmpx=("getutxent" "getutxid" "getutxline" "pututxline" "setutxent" "endutxent")
wchar=("btowc" "fgetwc" "fgetws" "fputwc" "fputws" "fwide" "fwprintf" "fwscanf"
"getwc" "getwchar" "mbrlen" "mbrtowc" "mbsinit" "mbsrtowcs" "putwc"
"putwchar" "swprintf" "swscanf" "ungetwc" "vfwprintf" "vfwscanf" "vswprintf"
"vswscanf" "vwprintf" "vwscanf" "wcrtomb" "wcscat" "wcschr" "wcscmp"
"wcscoll" "wcscpy" "wcscspn" "wcsftime" "wcslen" "wcsncat" "wcsncmp"
"wcsncpy" "wcspbrk" "wcsrchr" "wcsrtombs" "wcsspn" "wcsstr" "wcstod"
"wcstof" "wcstok" "wcstol" "wcstold" "wcstoll" "wcstoul" "wcstoull"
"wcswidth" "wcsxfrm" "wctob" "wctomb" "wctrans" "wctype" "wcwidth" "wprintf"
"wscanf")
wctype=("iswalnum" "iswalpha" "iswblank" "iswcntrl" "iswctype" "iswdigit" "iswgraph"
"iswlower" "iswprint" "iswpunct" "iswspace" "iswupper" "iswxdigit" "towlower"
"towupper" "wctrans" "wctype"
"iswalnum_l" "iswalpha_l" "iswblank_l" "iswcntrl_l" "iswctype_l" "iswdigit_l"
"iswgraph_l" "iswlower_l" "iswprint_l" "iswpunct_l" "iswspace_l" "iswupper_l"
"iswxdigit_l" "towlower_l" "towupper_l" "wctrans_l" "wctype_l")
wordexp=("wordexp" "wordfree")

56
web/table.css Normal file
View File

@@ -0,0 +1,56 @@
/* Search */
#searchHeader {
color: #6d6d6d;
font-weight: normal;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
vertical-align: middle;
height: 30px;
font-size: 30px;
}
input[type=text] {
padding: 5px;
font-size: 20px;
}
input[type=submit] {
padding: 5px;
font-size: 20px;
}
/* Table */
#bodyHeader {
color: #6d6d6d;
font-weight: normal;
font-size: 26px;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
vertical-align: middle;
height: 40px;
}
#headerRow {
background-color: #6d6d6d;
color: #FFFFFF;
font-weight: bold;
font-size: 20px;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
vertical-align: middle;
height: 40px;
}
.row {
cursor: pointer;
background-color: #FFFFFF;
color: #000000;
border: 1px solid #dddddd;
height: 40px;
font-weight: normal;
font-size: 20px;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
vertical-align: middle;
transition: background-color 0.2s ease-in-out;
}

216
web/table.html Normal file
View File

@@ -0,0 +1,216 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Table</title>
<link rel="stylesheet" href="table.css">
</head>
<body style="text-align:center;" id="body">
<form action="table.html" method="get">
<input type="text" name="search" placeholder="Function name...">
&nbsp;
<input type="submit" value="Search">
</form>
</body>
<script>
/* Obtain an element color based on (true, false, ...) value
*/
function getColor(value) {
switch (value) {
case "true":
case true:
return "green";
case "false":
case false:
return "red";
default:
return "orange";
}
}
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
let header = params.header;
if (header === "" || header === "null") header = null;
// JSON path to use
let path;
if (header == null) {
path = "../output.json";
}
else {
path = "../output-f/" + header;
path = path.substring(0, path.length - 1);
path = path + "json";
}
let func = params.function;
let search = params.search;
if (search === "") search = null;
// Set title
document.title = (func == null ? (header == null ? "All indexed functions" : header) : func);
if (search != null) document.title += " - Search for '" + search + "'"
// Add body header
let bodyHeader = document.createElement("h1");
bodyHeader.setAttribute("id", "bodyHeader");
bodyHeader.innerHTML = document.title;
document.getElementById("body").appendChild(bodyHeader);
// Open and read json file
let request = new XMLHttpRequest();
request.open("GET", path, false);
request.send(null);
if (request.status != 200) {
// Set body to error message
document.getElementById("body").innerHTML = "Error " + request.status + " occurred when trying to access \"" + path + "\"";
throw new Error("Error " + request.status + " occurred when trying to access \"" + path + "\"");
}
let json = JSON.parse(request.responseText);
// Create table
let table = document.createElement("table");
table.setAttribute("id", "table");
document.getElementById("body").appendChild(table);
// Set centered
document.getElementById("table").style.marginLeft = "auto";
document.getElementById("table").style.marginRight = "auto";
// Set row border collapse
document.getElementById("table").style.borderCollapse = "collapse";
// Set row width
document.getElementById("table").style.width = "900px";
// Create header row
let headerRow = document.createElement("tr");
headerRow.setAttribute("id", "headerRow");
document.getElementById("table").appendChild(headerRow);
// Create header cells
let headerCell = document.createElement("th");
headerCell.setAttribute("id", "headerCell");
headerCell.innerHTML = "Function";
document.getElementById("headerRow").appendChild(headerCell);
headerCell = document.createElement("th");
headerCell.setAttribute("id", "headerCell");
headerCell.innerHTML = "C Standard";
document.getElementById("headerRow").appendChild(headerCell);
headerCell = document.createElement("th");
headerCell.setAttribute("id", "headerCell");
headerCell.innerHTML = "SuS";
document.getElementById("headerRow").appendChild(headerCell);
headerCell = document.createElement("th");
headerCell.setAttribute("id", "headerCell");
headerCell.innerHTML = "Library";
document.getElementById("headerRow").appendChild(headerCell);
// Create rows
if (func != null) {
for (let i = 0; i < json.length; i++) {
if (json[i].name == func) {
json = [json[i]];
break;
}
}
json.length = 1;
}
for (let i = 0; i < json.length; i++) {
// Ignore empty elements
if (json[i].name == null)
continue;
// Ignore elements that does not comply to search string
if (search != null) {
if (!json[i].name.includes(search))
continue;
}
let row = document.createElement("tr");
row.setAttribute("id", "row");
document.getElementById("table").appendChild(row);
// Function name cell
let cell = document.createElement("td");
cell.setAttribute("id", "cell");
cell.innerHTML = json[i].name;
document.getElementById("row").appendChild(cell);
// C Standard cell
let c89 = json[i].c89;
let c99 = json[i].c99;
let c11 = json[i].c11;
let c2x = json[i].c2x;
cell = document.createElement("td");
cell.setAttribute("id", "cell");
cell.innerHTML = "<p style=\"color:" + getColor(c89) + ";\">C89</p>" +
"<p style=\"color:" + getColor(c99) + ";\">C99</p>" +
"<p style=\"color:" + getColor(c11) + ";\">C11</p>" +
"<p style=\"color:" + getColor(c2x) + ";\">C2x</p>";
document.getElementById("row").appendChild(cell);
// SuS cell
let susv2 = json[i].susv2;
let susv3 = json[i].susv3;
let susv4 = json[i].susv4;
cell = document.createElement("td");
cell.setAttribute("id", "cell");
cell.innerHTML = "<p style=\"color:" + getColor(susv2) + ";\">SuSv2</p>" +
"<p style=\"color:" + getColor(susv3) + "\">SuSv3</p>" +
"<p style=\"color:" + getColor(susv4) + "\">SuSv4</p>";
document.getElementById("row").appendChild(cell);
// Library cell
let glibc = json[i].glibc;
let musl = json[i].musl;
let uclibc = json[i]["uClibc-ng"];
let dietlibc = json[i].dietlibc;
let apple = json[i]["apple-libc"];
let msvcrt = json[i]["msvcrt"];
let ucrt = json[i]["ucrt"];
let freebsd = json[i]["freebsd-libc"];
let openbsd = json[i]["openbsd-libc"];
let netbsd = json[i]["netbsd-libc"];
let dragonflybsd = json[i]["dragonflybsd-libc"];
let mingw = json[i]["mingw"];
let cygwin = json[i]["cygwin"];
cell = document.createElement("td");
cell.setAttribute("id", "cell");
cell.innerHTML = "<p style=\"color:" + getColor(glibc) + "\">glibc</p>" +
"<p style=\"color:" + getColor(musl) + "\">musl</p>" +
"<p style=\"color:" + getColor(uclibc) + "\">uClibc-ng</p>" +
"<p style=\"color:" + getColor(dietlibc) + "\">dietlibc</p>" +
"<p style=\"color:" + getColor(apple) + "\">Apple libc</p>" +
"<p style=\"color:" + getColor(msvcrt) + "\">Windows MSVCRT</p>" +
"<p style=\"color:" + getColor(ucrt) + "\">Windows UCRT</p>" +
"<p style=\"color:" + getColor(freebsd) + "\">FreeBSD libc</p>" +
"<p style=\"color:" + getColor(netbsd) + "\">NetBSD libc</p>" +
"<p style=\"color:" + getColor(openbsd) + "\">OpenBSD libc</p>" +
"<p style=\"color:" + getColor(dragonflybsd) + "\">DragonFly BSD libc</p>" +
"<p style=\"color:" + getColor(mingw) + "\">MinGW-w64</p>" +
"<p style=\"color:" + getColor(cygwin) + "\">Cygwin</p>";
document.getElementById("row").appendChild(cell);
// Set row id
row.setAttribute("id", "row" + i);
// Set row class
row.setAttribute("class", "row");
// Set row onclick
if (func == null)
row.setAttribute("onclick", "window.location.href = 'table.html?header=" + header + "&function=" + json[i].name + "';");
// Set row hover
row.setAttribute("onmouseover", "document.getElementById('row" + i + "').style.backgroundColor = '#e6e6e6';");
// Set row hover out
row.setAttribute("onmouseout", "document.getElementById('row" + i + "').style.backgroundColor = 'white';");
}
</script>
</html>